[GH-ISSUE #2237] ASAN error in whirlpool formats #1494

Closed
opened 2026-10-15 04:18:39 +07:00 by bsakaguchi · 10 comments
Owner

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

  • whirlpool
  • whirlpool0
  • whirlpool1
$ ./john --skip-self-tests --format=whirlpool ../test/*.in
=================================================================
==18371==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000000f619cc at pc 0x00000040659d bp 0x7ffcd9d12500 sp 0x7ffcd9d124f0
READ of size 1 at 0x000000f619cc thread T0
    #0 0x40659c in strupr /home/fd/git/JtR/src/jumbo.c:308
    #1 0x75c596 in split /home/fd/git/JtR/src/whirlpool_fmt_plug.c:127
    #2 0x79e01a in ldr_load_pw_line /home/fd/git/JtR/src/loader.c:945
    #3 0x79f3af in read_file /home/fd/git/JtR/src/loader.c:226
    #4 0x7a27c6 in ldr_load_pw_file /home/fd/git/JtR/src/loader.c:1115
    #5 0x795841 in john_load /home/fd/git/JtR/src/john.c:1169
    #6 0x797069 in john_init /home/fd/git/JtR/src/john.c:1496
    #7 0x798eb7 in main /home/fd/git/JtR/src/john.c:1954
    #8 0x7f657d960730 in __libc_start_main (/lib64/libc.so.6+0x20730)
    #9 0x405df8 in _start (/home/fd/git/JtR/run/john+0x405df8)

0x000000f619cc is located 52 bytes to the left of global variable 'buf' defined in 'whirlpool_fmt_plug.c:136:4' (0xf61a00) of size 64
0x000000f619cc is located 0 bytes to the right of global variable 'out' defined in 'whirlpool_fmt_plug.c:120:14' (0xf61940) of size 140
SUMMARY: AddressSanitizer: global-buffer-overflow /home/fd/git/JtR/src/jumbo.c:308 in strupr
Shadow bytes around the buggy address:
  0x0000801e42e0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 f9
  0x0000801e42f0: f9 f9 f9 f9 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9
  0x0000801e4300: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0000801e4310: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x0000801e4320: 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
=>0x0000801e4330: 00 00 00 00 00 00 00 00 00[04]f9 f9 f9 f9 f9 f9
  0x0000801e4340: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 f9 f9 f9
  0x0000801e4350: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0000801e4360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0000801e4370: 01 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x0000801e4380: 00 00 00 00 00 00 00 00 00 00 00 00 01 f9 f9 f9
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
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==18371==ABORTING

Same problem with --format=whirlpool0 and --format=whirlpool1.

Originally created by @frank-dittrich on GitHub (Aug 25, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2237 - [x] whirlpool - [x] whirlpool0 - [x] whirlpool1 ``` $ ./john --skip-self-tests --format=whirlpool ../test/*.in ================================================================= ==18371==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000000f619cc at pc 0x00000040659d bp 0x7ffcd9d12500 sp 0x7ffcd9d124f0 READ of size 1 at 0x000000f619cc thread T0 #0 0x40659c in strupr /home/fd/git/JtR/src/jumbo.c:308 #1 0x75c596 in split /home/fd/git/JtR/src/whirlpool_fmt_plug.c:127 #2 0x79e01a in ldr_load_pw_line /home/fd/git/JtR/src/loader.c:945 #3 0x79f3af in read_file /home/fd/git/JtR/src/loader.c:226 #4 0x7a27c6 in ldr_load_pw_file /home/fd/git/JtR/src/loader.c:1115 #5 0x795841 in john_load /home/fd/git/JtR/src/john.c:1169 #6 0x797069 in john_init /home/fd/git/JtR/src/john.c:1496 #7 0x798eb7 in main /home/fd/git/JtR/src/john.c:1954 #8 0x7f657d960730 in __libc_start_main (/lib64/libc.so.6+0x20730) #9 0x405df8 in _start (/home/fd/git/JtR/run/john+0x405df8) 0x000000f619cc is located 52 bytes to the left of global variable 'buf' defined in 'whirlpool_fmt_plug.c:136:4' (0xf61a00) of size 64 0x000000f619cc is located 0 bytes to the right of global variable 'out' defined in 'whirlpool_fmt_plug.c:120:14' (0xf61940) of size 140 SUMMARY: AddressSanitizer: global-buffer-overflow /home/fd/git/JtR/src/jumbo.c:308 in strupr Shadow bytes around the buggy address: 0x0000801e42e0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 f9 0x0000801e42f0: f9 f9 f9 f9 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9 0x0000801e4300: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9 0x0000801e4310: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 0x0000801e4320: 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00 =>0x0000801e4330: 00 00 00 00 00 00 00 00 00[04]f9 f9 f9 f9 f9 f9 0x0000801e4340: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 f9 f9 f9 0x0000801e4350: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 0x0000801e4360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0000801e4370: 01 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00 0x0000801e4380: 00 00 00 00 00 00 00 00 00 00 00 00 01 f9 f9 f9 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 Left alloca redzone: ca Right alloca redzone: cb ==18371==ABORTING ``` Same problem with `--format=whirlpool0` and `--format=whirlpool1`.
Author
Owner

@jfoug commented on GitHub (Aug 25, 2016):

Please simply add formats which have this problem (--skip-self-test) when run against a ton of random crap. I figure there will be numerous formats. No need to have 20 issues for the same thing.

<!-- gh-comment-id:242498377 --> @jfoug commented on GitHub (Aug 25, 2016): Please simply add formats which have this problem (--skip-self-test) when run against a ton of random crap. I figure there will be numerous formats. No need to have 20 issues for the same thing.
Author
Owner

@frank-dittrich commented on GitHub (Aug 25, 2016):

@jfoug actually I think these were the only formats except the oracle9i format (now renamed), at least when tested against all the other jtrts hashes. May be more formats will come up if I really feed them "random crap".

<!-- gh-comment-id:242545147 --> @frank-dittrich commented on GitHub (Aug 25, 2016): @jfoug actually I think these were the only formats except the oracle9i format (now renamed), at least when tested against all the other jtrts hashes. May be more formats will come up if I really feed them "random crap".
Author
Owner

@jfoug commented on GitHub (Aug 25, 2016):

Ok. Well, what it ended up being was the valid was made 'invalid' by a recent change (to the hexlen)

Hexlen function was converted from int to a size_t (unsigned). This was for longer hashes (that may be over 2gb). But in doing so, a 'special' return was removed. That return was -length IF the string was not pure. Now the return is simply the length seen, without the negative. So in this case, hexlen != PT_LEN was not failing any more. So a line with a 128 byte raw hex value, followed by crap would trigger the buffer overflow in split, since there was no null byte.

We should audit the other valid() functions, and see if usage like this is in other places. It would be the 'last' element in the hash usually.

<!-- gh-comment-id:242550594 --> @jfoug commented on GitHub (Aug 25, 2016): Ok. Well, what it ended up being was the valid was made 'invalid' by a recent change (to the hexlen) Hexlen function was converted from int to a size_t (unsigned). This was for longer hashes (that may be over 2gb). But in doing so, a 'special' return was removed. That return was -length IF the string was not pure. Now the return is simply the length seen, without the negative. So in this case, hexlen != PT_LEN was not failing any more. So a line with a 128 byte raw hex value, followed by crap would trigger the buffer overflow in split, since there was no null byte. We should audit the other valid() functions, and see if usage like this is in other places. It would be the 'last' element in the hash usually.
Author
Owner

@frank-dittrich commented on GitHub (Aug 25, 2016):

We should audit the other valid() functions, and see if usage like this is in other places. It would be the 'last' element in the hash usually.

I assume hexlenl() and hexlenu() may cause the same problem now.

<!-- gh-comment-id:242554299 --> @frank-dittrich commented on GitHub (Aug 25, 2016): > We should audit the other valid() functions, and see if usage like this is in other places. It would be the 'last' element in the hash usually. I assume hexlenl() and hexlenu() may cause the same problem now.
Author
Owner

@jfoug commented on GitHub (Aug 25, 2016):

that is a correct assumption.

<!-- gh-comment-id:242559583 --> @jfoug commented on GitHub (Aug 25, 2016): that is a correct assumption.
Author
Owner

@frank-dittrich commented on GitHub (Aug 25, 2016):

@jfoug your latest commit fixes the whirlpool issue.

Should we keep this issue open for the review of hexlen() / hexlenu() / hexlenl() usage in valid?
Or should that be a new issue?

<!-- gh-comment-id:242562963 --> @frank-dittrich commented on GitHub (Aug 25, 2016): @jfoug your latest commit fixes the whirlpool issue. Should we keep this issue open for the review of hexlen() / hexlenu() / hexlenl() usage in valid? Or should that be a new issue?
Author
Owner

@jfoug commented on GitHub (Aug 25, 2016):

Why not rename it. We have the discussion started here.

<!-- gh-comment-id:242580762 --> @jfoug commented on GitHub (Aug 25, 2016): Why not rename it. We have the discussion started here.
Author
Owner

@jfoug commented on GitHub (Aug 26, 2016):

I think the only way to fix this properly, is to again make hexlen() hexlenu() and hexlenl() return information (optionally) about whether the hex length was 'solid' (i.e. the length of the hex is the same length as the string). I will add an int pointer param. If that is not set to NULL, then on return, that int will be set to 0 or 1, depending upon full or partial length. Full will set 0, partial will set 1. It is the same 1 bit of information we were returning as a negative number.

<!-- gh-comment-id:242587057 --> @jfoug commented on GitHub (Aug 26, 2016): I think the only way to fix this properly, is to again make hexlen() hexlenu() and hexlenl() return information (optionally) about whether the hex length was 'solid' (i.e. the length of the hex is the same length as the string). I will add an int pointer param. If that is not set to NULL, then on return, that int will be set to 0 or 1, depending upon full or partial length. Full will set 0, partial will set 1. It is the same 1 bit of information we were returning as a negative number.
Author
Owner

@jfoug commented on GitHub (Aug 26, 2016):

dace1b3

<!-- gh-comment-id:242613300 --> @jfoug commented on GitHub (Aug 26, 2016): dace1b3
Author
Owner

@jfoug commented on GitHub (Aug 26, 2016):

Any errors or crashes or asan's opened up due to change in the hexlen?() returning size_t should be corrected in the dace1b3 commit. I did not check that each location required knowledge of being 'solid' or not, but every one (in valid or prepare) that 'could' check that the hex was solid, now does, and fails if not solid. There were a few locations which could not check, because it was 2 pointers walking the hash, vs chopping up a temp allocated var. But with this new variable, all needed checks should now only allow proper hex parts of the hash to pass.

<!-- gh-comment-id:242614826 --> @jfoug commented on GitHub (Aug 26, 2016): Any errors or crashes or asan's opened up due to change in the hexlen?() returning size_t should be corrected in the dace1b3 commit. I did not check that each location required knowledge of being 'solid' or not, but every one (in valid or prepare) that 'could' check that the hex was solid, now does, and fails if not solid. There were a few locations which could not check, because it was 2 pointers walking the hash, vs chopping up a temp allocated var. But with this new variable, all needed checks should now only allow proper hex parts of the hash to pass.
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#1494
No description provided.