[GH-ISSUE #1158] --input-encoding: asan error #724

Closed
opened 2026-10-14 03:21:26 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @loverszhaokai on GitHub (Mar 26, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1158

This bug is found by fuzzzing the options of John.
#1. Prepare

1.1 content of 7z_fmt

$7z$0$19$0$1122$8$d1f50227759415890000000000000000$1412385885$112$112$5e5b8b734adf52a64c541a5a5369023d7cccb78bd910c0092535dfb013a5df84ac692c5311d2e7bbdc580f5b867f7b5dd43830f7b4f37e41c7277e228fb92a6dd854a31646ad117654182253706dae0c069d3f4ce46121d52b6f20741a0bb39fc61113ce14d22f9184adafd6b5333fb1

1.2 compile with asan

$ export ASAN_OPTIONS='abort_on_error=1'
$ AFL_USE_ASAN=1 AFL_HARDEN=1 ./configure --enable-asan && make -sj8
#2. Reproduce

$ ./john 7z_fmt --input-encoding=CP720
Loaded 1 password hash (7z, 7-Zip [SHA256 AES 32/64])
Will run 8 OpenMP threads
Note: This format may emit false positives, so it will keep trying even after
finding a possible candidate.

==65339== ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000094ecfb at pc 0x77ebcc bp 0x7fff5e96f110 sp 0x7fff5e96f108
READ of size 1 at 0x00000094ecfb thread T0
#0 0x77ebcb (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x77ebcb)
#1 0x77f0fc (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x77f0fc)
#2 0x781c75 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x781c75)
#3 0x789891 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x789891)
#4 0x78baa4 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x78baa4)
#5 0x7341f0 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x7341f0)
#6 0x73431c (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x73431c)
#7 0x75a6f2 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x75a6f2)
#8 0x75b23e (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x75b23e)
#9 0x7fcab8875ec4 (/lib/x86_64-linux-gnu/libc-2.19.so+0x21ec4)
#10 0x406632 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x406632)
0x00000094ecfb is located 37 bytes to the left of global variable '.LC38 (rules.c)' (0x94ed20) of size 163
0x00000094ecfb is located 0 bytes to the right of global variable '
.LC37 (rules.c)' (0x94ece0) of size 27
'*.LC37 (rules.c)' is ascii string 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Shadow bytes around the buggy address:
0x000080121d40: 05 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 05 f9 f9 f9
0x000080121d50: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
0x000080121d60: 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
0x000080121d70: 00 00 00 00 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00
0x000080121d80: 00 00 00 00 00 00 00 00 00 03 f9 f9 f9 f9 f9 f9
=>0x000080121d90: 00 00 00 00 07 f9 f9 f9 f9 f9 f9 f9 00 00 00[03]
0x000080121da0:f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
0x000080121db0: 00 00 00 00 00 00 00 00 03 f9 f9 f9 f9 f9 f9 f9
0x000080121dc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000080121dd0: 00 00 00 00 03 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
0x000080121de0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap righ redzone: fb
Freed Heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
ASan internal: fe
==65339== ABORTING
Aborted

$ asan_symbolize.py
#0 0x77ebcb in rules_init_conv /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/rules.c:804

#1 0x77f0fc in rules_init_convs /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/rules.c:924
#2 0x781c75 in rules_init /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/rules.c:1141
#3 0x789891 in single_init /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/single.c:127
#4 0x78baa4 in do_single_crack /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/single.c:529
#5 0x7341f0 in do_single_pass /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/batch.c:26
#6 0x73431c in do_batch_crack /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/batch.c:52
#7 0x75a6f2 in john_run /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/john.c:1415
#8 0x75b23e in main /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/john.c:1687
#9 0x7fcab8875ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287

pen_wall/JohnTheRipper_test_options_asan/run/john+0x406632)
#10 0x406632 in _start ??:?

Originally created by @loverszhaokai on GitHub (Mar 26, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1158 This bug is found by fuzzzing the options of John. #1. Prepare ## 1.1 content of 7z_fmt $7z$0$19$0$1122$8$d1f50227759415890000000000000000$1412385885$112$112$5e5b8b734adf52a64c541a5a5369023d7cccb78bd910c0092535dfb013a5df84ac692c5311d2e7bbdc580f5b867f7b5dd43830f7b4f37e41c7277e228fb92a6dd854a31646ad117654182253706dae0c069d3f4ce46121d52b6f20741a0bb39fc61113ce14d22f9184adafd6b5333fb1 ## 1.2 compile with asan $ export ASAN_OPTIONS='abort_on_error=1' $ AFL_USE_ASAN=1 AFL_HARDEN=1 ./configure --enable-asan && make -sj8 #2. Reproduce $ ./john 7z_fmt --input-encoding=CP720 Loaded 1 password hash (7z, 7-Zip [SHA256 AES 32/64]) Will run 8 OpenMP threads Note: This format may emit false positives, so it will keep trying even after finding a possible candidate. ==65339== **ERROR**: AddressSanitizer: global-buffer-overflow on address 0x00000094ecfb at pc 0x77ebcc bp 0x7fff5e96f110 sp 0x7fff5e96f108 READ of size 1 at 0x00000094ecfb thread T0 #0 0x77ebcb (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x77ebcb) #1 0x77f0fc (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x77f0fc) #2 0x781c75 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x781c75) #3 0x789891 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x789891) #4 0x78baa4 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x78baa4) #5 0x7341f0 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x7341f0) #6 0x73431c (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x73431c) #7 0x75a6f2 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x75a6f2) #8 0x75b23e (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x75b23e) #9 0x7fcab8875ec4 (/lib/x86_64-linux-gnu/libc-2.19.so+0x21ec4) #10 0x406632 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/run/john+0x406632) 0x00000094ecfb is located 37 bytes to the left of global variable '_.LC38 (rules.c)' (0x94ed20) of size 163 0x00000094ecfb is located 0 bytes to the right of global variable '_.LC37 (rules.c)' (0x94ece0) of size 27 '*.LC37 (rules.c)' is ascii string 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' Shadow bytes around the buggy address: 0x000080121d40: 05 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 05 f9 f9 f9 0x000080121d50: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00 0x000080121d60: 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00 0x000080121d70: 00 00 00 00 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00 0x000080121d80: 00 00 00 00 00 00 00 00 00 03 f9 f9 f9 f9 f9 f9 =>0x000080121d90: 00 00 00 00 07 f9 f9 f9 f9 f9 f9 f9 00 00 00[03] 0x000080121da0:f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00 0x000080121db0: 00 00 00 00 00 00 00 00 03 f9 f9 f9 f9 f9 f9 f9 0x000080121dc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000080121dd0: 00 00 00 00 03 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 0x000080121de0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Heap righ redzone: fb Freed Heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack partial redzone: f4 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 ASan internal: fe ==65339== ABORTING Aborted $ asan_symbolize.py #0 0x77ebcb in rules_init_conv /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/rules.c:804 ``` #1 0x77f0fc in rules_init_convs /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/rules.c:924 #2 0x781c75 in rules_init /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/rules.c:1141 #3 0x789891 in single_init /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/single.c:127 #4 0x78baa4 in do_single_crack /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/single.c:529 #5 0x7341f0 in do_single_pass /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/batch.c:26 #6 0x73431c in do_batch_crack /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/batch.c:52 #7 0x75a6f2 in john_run /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/john.c:1415 #8 0x75b23e in main /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_options_asan/src/john.c:1687 #9 0x7fcab8875ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287 ``` pen_wall/JohnTheRipper_test_options_asan/run/john+0x406632) #10 0x406632 in _start ??:?
bsakaguchi 2026-10-14 03:21:26 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Mar 26, 2015):

static char *rules_init_conv(char *src, char *dst)
{
    char *conv;
    int pos;

    conv = mem_alloc_tiny(0x100, MEM_ALIGN_NONE);
    for (pos = 0; pos < 0x100; pos++) conv[pos] = pos;

    while (*src)
        conv[ARCH_INDEX(*src++)] = *dst++;

    return conv;
}

We could hide the bug using while (*src && *dst) but even better would be to bail out with error. This function assumes that src and dst are of same length.

<!-- gh-comment-id:86503658 --> @magnumripper commented on GitHub (Mar 26, 2015): ``` C static char *rules_init_conv(char *src, char *dst) { char *conv; int pos; conv = mem_alloc_tiny(0x100, MEM_ALIGN_NONE); for (pos = 0; pos < 0x100; pos++) conv[pos] = pos; while (*src) conv[ARCH_INDEX(*src++)] = *dst++; return conv; } ``` We could hide the bug using `while (*src && *dst)` but even better would be to bail out with error. This function assumes that src and dst are of same length.
Author
Owner

@magnumripper commented on GitHub (Mar 26, 2015):

OK the real problem is this, in encoding_data.h

// éâàçêëèïîôûù
#define CHARS_LOWER_CP720 "\x82\x83\x85\x87\x88\x89\x8A\x8B\x8C\x93\x96\x97"

// µ
#define CHARS_LOW_ONLY_CP720 "\xE6"

//
#define CHARS_UPPER_CP720 ""

//
#define CHARS_UP_ONLY_CP720

CHARS_LOWER and CHARS_UPPER are supposed to map exactly. In this case, all of CHARS_LOWER should have been placed in CHARS_LOW_ONLY since they have no upper-case mapping.

But encoding_data.h is auto-generated from the Unicode database - I need to look into the generator.

<!-- gh-comment-id:86508213 --> @magnumripper commented on GitHub (Mar 26, 2015): OK the real problem is this, in encoding_data.h ``` // éâàçêëèïîôûù #define CHARS_LOWER_CP720 "\x82\x83\x85\x87\x88\x89\x8A\x8B\x8C\x93\x96\x97" // µ #define CHARS_LOW_ONLY_CP720 "\xE6" // #define CHARS_UPPER_CP720 "" // #define CHARS_UP_ONLY_CP720 ``` CHARS_LOWER and CHARS_UPPER are supposed to map exactly. In this case, all of CHARS_LOWER should have been placed in CHARS_LOW_ONLY since they have no upper-case mapping. But encoding_data.h is auto-generated from the Unicode database - I need to look into the generator.
Author
Owner

@magnumripper commented on GitHub (Mar 26, 2015):

OK the problem was that CP720 is not supported in Perl so that part of encoding_data.h was not auto generated - and the manual implementation was not correct.

Thank you for finding this bug!

<!-- gh-comment-id:86512874 --> @magnumripper commented on GitHub (Mar 26, 2015): OK the problem was that CP720 is not supported in Perl so that part of encoding_data.h was not auto generated - and the manual implementation was not correct. Thank you for finding this bug!
Author
Owner

@loverszhaokai commented on GitHub (Mar 26, 2015):

@magnumripper 👍

<!-- gh-comment-id:86513106 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper :+1:
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#724
No description provided.