[GH-ISSUE #2003] ASan error on scrypt format with --fuzz #1344

Closed
opened 2026-10-14 03:45:01 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @frank-dittrich on GitHub (Jan 22, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2003

Originally assigned to: @jfoug on GitHub.

Unfortunately, this error doesn't occur when just running

./john --fuzz --format=scrypt

I tried reproducing the error with disabling individual formats which are tested before scrypt and only succeeded when disabling descrypt, but keeping the others disabled.

(bleeding-jumbo)run $ ./john --fuzz
Fuzzing: bsdicrypt, BSDI crypt(3) ("_J9..", 725 iterations) [DES 128/128 AVX-16]... 
Fuzzing: md5crypt, crypt(3) $1$ [MD5 128/128 AVX 4x3]... 
Warning: excessive partial hash collisions detected
Fuzzing: bcrypt ("$2a$05", 32 iterations) [Blowfish 32/64 X3]... 
Fuzzing: scrypt (16384, 8, 1) [Salsa20/8 128/128 AVX]... 
=================================================================
==13067==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6310006dc800 at pc 0x7fe14c0f6a96 bp 0x7fff608ae9c0 sp 0x7fff608ae168
READ of size 256 at 0x6310006dc800 thread T0
    #0 0x7fe14c0f6a95 in memcmp (/lib64/libasan.so.2+0x77a95)
    #1 0x7ae63a in dyna_salt_cmp /home/fd/git/JtR/src/dyna_salt.c:105
    #2 0x7ec2e9 in ldr_load_pw_line /home/fd/git/JtR/src/loader.c:918
    #3 0x8628ac in fuzz_test /home/fd/git/JtR/src/fuzz.c:564
    #4 0x862d97 in fuzz /home/fd/git/JtR/src/fuzz.c:668
    #5 0x7e5a4c in john_run /home/fd/git/JtR/src/john.c:1592
    #6 0x7e72d0 in main /home/fd/git/JtR/src/john.c:1973
    #7 0x7fe14a67d6ff in __libc_start_main (/lib64/libc.so.6+0x206ff)
    #8 0x406638 in _start (/home/fd/git/JtR/run/john+0x406638)

0x6310006dc800 is located 0 bytes to the right of 65536-byte region [0x6310006cc800,0x6310006dc800)
allocated by thread T0 here:
    #0 0x7fe14c11796a in malloc (/lib64/libasan.so.2+0x9896a)
    #1 0x80f7b1 in mem_alloc_func /home/fd/git/JtR/src/memory.c:90
    #2 0x80f99a in mem_alloc_tiny_func /home/fd/git/JtR/src/memory.c:197
    #3 0x7ec810 in ldr_load_pw_line /home/fd/git/JtR/src/loader.c:962
    #4 0x8628ac in fuzz_test /home/fd/git/JtR/src/fuzz.c:564
    #5 0x862d97 in fuzz /home/fd/git/JtR/src/fuzz.c:668
    #6 0x7e5a4c in john_run /home/fd/git/JtR/src/john.c:1592
    #7 0x7e72d0 in main /home/fd/git/JtR/src/john.c:1973
    #8 0x7fe14a67d6ff in __libc_start_main (/lib64/libc.so.6+0x206ff)

SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 memcmp
Shadow bytes around the buggy address:
  0x0c62800d38b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c62800d38c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c62800d38d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c62800d38e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c62800d38f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c62800d3900:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c62800d3910: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c62800d3920: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c62800d3930: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c62800d3940: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c62800d3950: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
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 right 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
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==13067==ABORTING
(bleeding-jumbo)run $ ./john --list=build-info 
Version: 1.8.0.6-jumbo-1-1893-gc183301
Build: linux-gnu 64-bit AVX-ac ASan UbSan
SIMD: AVX, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1
$JOHN is ./
Format interface version: 13
Max. number of reported tunable costs: 3
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
SALT_HASH_SIZE: 1048576
Max. Markov mode level: 400
Max. Markov mode password length: 30
gcc version: 5.3.1
GNU libc version: 2.21 (loaded: 2.21)
Crypto library: OpenSSL
OpenSSL library version: 0100010bf
OpenSSL 1.0.1k-fips 8 Jan 2015
GMP library version: 6.0.0
Regex library version: 1.3  (loaded: 1.3.1)
File locking: fcntl()
fseek(): fseek
ftell(): ftell
fopen(): fopen
memmem(): System's
Built with these debugging options
    ASan (Address Sanitizer debugging)
    UbSan (Undefined Behavior Sanitizer debugging)

Originally created by @frank-dittrich on GitHub (Jan 22, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2003 Originally assigned to: @jfoug on GitHub. Unfortunately, this error doesn't occur when just running ``` ./john --fuzz --format=scrypt ``` I tried reproducing the error with disabling individual formats which are tested before scrypt and only succeeded when disabling descrypt, but keeping the others disabled. ``` (bleeding-jumbo)run $ ./john --fuzz Fuzzing: bsdicrypt, BSDI crypt(3) ("_J9..", 725 iterations) [DES 128/128 AVX-16]... Fuzzing: md5crypt, crypt(3) $1$ [MD5 128/128 AVX 4x3]... Warning: excessive partial hash collisions detected Fuzzing: bcrypt ("$2a$05", 32 iterations) [Blowfish 32/64 X3]... Fuzzing: scrypt (16384, 8, 1) [Salsa20/8 128/128 AVX]... ================================================================= ==13067==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6310006dc800 at pc 0x7fe14c0f6a96 bp 0x7fff608ae9c0 sp 0x7fff608ae168 READ of size 256 at 0x6310006dc800 thread T0 #0 0x7fe14c0f6a95 in memcmp (/lib64/libasan.so.2+0x77a95) #1 0x7ae63a in dyna_salt_cmp /home/fd/git/JtR/src/dyna_salt.c:105 #2 0x7ec2e9 in ldr_load_pw_line /home/fd/git/JtR/src/loader.c:918 #3 0x8628ac in fuzz_test /home/fd/git/JtR/src/fuzz.c:564 #4 0x862d97 in fuzz /home/fd/git/JtR/src/fuzz.c:668 #5 0x7e5a4c in john_run /home/fd/git/JtR/src/john.c:1592 #6 0x7e72d0 in main /home/fd/git/JtR/src/john.c:1973 #7 0x7fe14a67d6ff in __libc_start_main (/lib64/libc.so.6+0x206ff) #8 0x406638 in _start (/home/fd/git/JtR/run/john+0x406638) 0x6310006dc800 is located 0 bytes to the right of 65536-byte region [0x6310006cc800,0x6310006dc800) allocated by thread T0 here: #0 0x7fe14c11796a in malloc (/lib64/libasan.so.2+0x9896a) #1 0x80f7b1 in mem_alloc_func /home/fd/git/JtR/src/memory.c:90 #2 0x80f99a in mem_alloc_tiny_func /home/fd/git/JtR/src/memory.c:197 #3 0x7ec810 in ldr_load_pw_line /home/fd/git/JtR/src/loader.c:962 #4 0x8628ac in fuzz_test /home/fd/git/JtR/src/fuzz.c:564 #5 0x862d97 in fuzz /home/fd/git/JtR/src/fuzz.c:668 #6 0x7e5a4c in john_run /home/fd/git/JtR/src/john.c:1592 #7 0x7e72d0 in main /home/fd/git/JtR/src/john.c:1973 #8 0x7fe14a67d6ff in __libc_start_main (/lib64/libc.so.6+0x206ff) SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 memcmp Shadow bytes around the buggy address: 0x0c62800d38b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c62800d38c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c62800d38d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c62800d38e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c62800d38f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x0c62800d3900:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c62800d3910: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c62800d3920: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c62800d3930: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c62800d3940: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c62800d3950: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 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 right 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 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe ==13067==ABORTING ``` ``` (bleeding-jumbo)run $ ./john --list=build-info Version: 1.8.0.6-jumbo-1-1893-gc183301 Build: linux-gnu 64-bit AVX-ac ASan UbSan SIMD: AVX, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1 $JOHN is ./ Format interface version: 13 Max. number of reported tunable costs: 3 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 SALT_HASH_SIZE: 1048576 Max. Markov mode level: 400 Max. Markov mode password length: 30 gcc version: 5.3.1 GNU libc version: 2.21 (loaded: 2.21) Crypto library: OpenSSL OpenSSL library version: 0100010bf OpenSSL 1.0.1k-fips 8 Jan 2015 GMP library version: 6.0.0 Regex library version: 1.3 (loaded: 1.3.1) File locking: fcntl() fseek(): fseek ftell(): ftell fopen(): fopen memmem(): System's Built with these debugging options ASan (Address Sanitizer debugging) UbSan (Undefined Behavior Sanitizer debugging) ```
bsakaguchi 2026-10-14 03:45:01 +07:00
  • closed this issue
  • added the
    fuzz bug
    label
Author
Owner

@kholia commented on GitHub (Aug 15, 2017):

This code from loader.c seems to be problematic?

salt = format->methods.salt(piece);
dyna_salt_create(salt);
salt_hash = format->methods.salt_hash(salt);

if ((current_salt = db->salt_hash[salt_hash])) {
        do {
                if (!dyna_salt_cmp(current_salt->salt, salt, format->params.salt_size)) // site [1]
                        break;
        }  while ((current_salt = current_salt->next));
}

...
if (!current_salt) {
       ...
       current_salt->salt = mem_alloc_copy(salt,  // site [2]
                format->params.salt_size,
                format->params.salt_align);

Is the db->salt_hash structure reset after testing of each individual format?

Update: I traced the allocations at site [2] and the usage at site [1] in the above code. At some point during the scrypt testing, current_salt->salt at site [1] points to a very old allocation which was allocated during the testing of some previous format. This is what is causing the problems.

<!-- gh-comment-id:322438719 --> @kholia commented on GitHub (Aug 15, 2017): This code from loader.c seems to be problematic? ``` C salt = format->methods.salt(piece); dyna_salt_create(salt); salt_hash = format->methods.salt_hash(salt); if ((current_salt = db->salt_hash[salt_hash])) { do { if (!dyna_salt_cmp(current_salt->salt, salt, format->params.salt_size)) // site [1] break; } while ((current_salt = current_salt->next)); } ... if (!current_salt) { ... current_salt->salt = mem_alloc_copy(salt, // site [2] format->params.salt_size, format->params.salt_align); ``` Is the `db->salt_hash` structure reset after testing of each individual format? Update: I traced the allocations at site [2] and the usage at site [1] in the above code. At some point during the scrypt testing, `current_salt->salt` at site [1] points to a very old allocation which was allocated during the testing of some previous format. This is what is causing the problems.
Author
Owner

@magnumripper commented on GitHub (Aug 15, 2017):

We should bisect this and find what commit caused the problem.

<!-- gh-comment-id:322517916 --> @magnumripper commented on GitHub (Aug 15, 2017): We should bisect this and find what commit caused the problem.
Author
Owner

@magnumripper commented on GitHub (Aug 15, 2017):

Is there some way to trigger the problem with something more specific than fuzzing shit?

<!-- gh-comment-id:322518194 --> @magnumripper commented on GitHub (Aug 15, 2017): Is there some way to trigger the problem with something more specific than fuzzing shit?
Author
Owner

@kholia commented on GitHub (Aug 15, 2017):

I haven't found an alternate way to trigger this crash. Also, it shouldn't impact normal JtR jumbo usage I think.

<!-- gh-comment-id:322520300 --> @kholia commented on GitHub (Aug 15, 2017): I haven't found an alternate way to trigger this crash. Also, it shouldn't impact normal JtR jumbo usage I think.
Author
Owner

@magnumripper commented on GitHub (Aug 15, 2017):

Perhaps it's a bug in the very fuzzing code? 🤣

<!-- gh-comment-id:322521802 --> @magnumripper commented on GitHub (Aug 15, 2017): Perhaps it's a bug in the very fuzzing code? 🤣
Author
Owner

@magnumripper commented on GitHub (Dec 15, 2018):

Closing because it's a shame people love to fuzz but hate to help fixing bugs

<!-- gh-comment-id:447595792 --> @magnumripper commented on GitHub (Dec 15, 2018): Closing because it's a shame people love to fuzz but hate to help fixing bugs
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#1344
No description provided.