[GH-ISSUE #1160] asaMD5_fmt: asan error #726

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

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

This bug is found by fuzzzing John using AFL.
#1. Prepare

1.1 content of asaMD5_fmt

$dynamic_20$h3mJrcH0901pqX/m$alex
$dynamic_20$3USUcOPFUiMCO4Jk$cisc
$dynamic_20$lZt7HSIXw3.QP7.R$admc
$dynamic_20$hN7LzeyYjw12FSIU$john
$dynamic_20$7DrfeZ7cyOj/PslD$jack

1.2 compile with asan

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

Note: you should press Ctrl-C to abort john, and after cancel you will see the asan error

$ ./john asaMD5_fmt
Warning: detected hash type "dynamic_20", but the string is also recognized as "asa-md5"
Use the "--format=asa-md5" option to force loading these as that type instead
Loaded 5 password hashes with 5 different salts (dynamic_20 [Cisco ASA (MD5 salted) 128/128 AVX (480*1)x4x3])
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
ripper (?)
Warning: MaxLen = 13 is too large for the current hash type, reduced to 12
1g 0:00:00:00 0.00% 3/3 (ETA: 21:29:46) 1.098g/s 199327p/s 804061c/s 804061C/s 013356..036666
Use the "--show" option to display all of the cracked passwords reliably

==21438==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x0000022a6080 in thread T0
#0 0x7fb3c2f465c7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x545c7)
#1 0x7a6c62 in MEMDBG_off_free /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/memdbg.c:1099
#2 0x49137b in done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/dynamic_fmt.c:861
#3 0x732358 in fmt_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/formats.c:112
#4 0x73fecb in john_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1478
#5 0x740633 in main /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1688
#6 0x7fb3c1785ec4 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
#7 0x406cb2 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/run/john+0x406cb2)

AddressSanitizer can not describe address in more detail (wild memory access suspected).
SUMMARY: AddressSanitizer: bad-free ??:0 __interceptor_free
==21438==ABORTING
Aborted (core dumped)

Originally created by @loverszhaokai on GitHub (Mar 26, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1160 This bug is found by fuzzzing John using AFL. #1. Prepare ## 1.1 content of asaMD5_fmt $dynamic_20$h3mJrcH0901pqX/m$alex $dynamic_20$3USUcOPFUiMCO4Jk$cisc $dynamic_20$lZt7HSIXw3.QP7.R$admc $dynamic_20$hN7LzeyYjw12FSIU$john $dynamic_20$7DrfeZ7cyOj/PslD$jack ## 1.2 compile with asan $ export ASAN_OPTIONS='abort_on_error=1' $ AFL_USE_ASAN=1 AFL_HARDEN=1 ./configure **CC=gcc-4.9** --enable-asan && make -sj8 #2. Reproduce Note: you should press **Ctrl-C** to abort john, and after cancel you will see the asan error $ ./john asaMD5_fmt Warning: detected hash type "dynamic_20", but the string is also recognized as "asa-md5" Use the "--format=asa-md5" option to force loading these as that type instead Loaded 5 password hashes with 5 different salts (dynamic_20 [Cisco ASA (MD5 salted) 128/128 AVX (480*1)x4x3]) Will run 8 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status ripper (?) Warning: MaxLen = 13 is too large for the current hash type, reduced to 12 1g 0:00:00:00 0.00% 3/3 (ETA: 21:29:46) 1.098g/s 199327p/s 804061c/s 804061C/s 013356..036666 Use the "--show" option to display all of the cracked passwords reliably ==21438==**ERROR**: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x0000022a6080 in thread T0 #0 0x7fb3c2f465c7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x545c7) #1 0x7a6c62 in MEMDBG_off_free /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/memdbg.c:1099 #2 0x49137b in done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/dynamic_fmt.c:861 #3 0x732358 in fmt_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/formats.c:112 #4 0x73fecb in john_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1478 #5 0x740633 in main /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1688 #6 0x7fb3c1785ec4 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) #7 0x406cb2 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/run/john+0x406cb2) AddressSanitizer can not describe address in more detail (wild memory access suspected). SUMMARY: AddressSanitizer: bad-free ??:0 __interceptor_free ==21438==ABORTING Aborted (core dumped)
bsakaguchi 2026-10-14 03:21:27 +07:00
Author
Owner

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

You list contents of aix_smd5_fmt but you run with asaMD5_fmt... which is it?

<!-- gh-comment-id:86498404 --> @magnumripper commented on GitHub (Mar 26, 2015): You list contents of aix_smd5_fmt but you run with asaMD5_fmt... which is it?
Author
Owner

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

@magnumripper Thanks. It should be asaMD5_fmt. Updated.

<!-- gh-comment-id:86499627 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper Thanks. It should be **asaMD5_fmt**. Updated.
Author
Owner

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

I can not reproduce. I suspect this too is the gcc 4.8 bug.

<!-- gh-comment-id:86501089 --> @magnumripper commented on GitHub (Mar 26, 2015): I can not reproduce. I suspect this too is the gcc 4.8 bug.
Author
Owner

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

@magnumripper I am going to check it. Thanks.

<!-- gh-comment-id:86501648 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper I am going to check it. Thanks.
Author
Owner

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

@magnumripper gcc-4.9 can reproduce. I have updated the issue.

<!-- gh-comment-id:86514685 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper gcc-4.9 can reproduce. I have updated the issue.
Author
Owner

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

OK, I still can't reproduce so I can't debug it... if you revert to 2804be376 or dc6159870, can you reproduce it? I still suspect this is an ASan problem and not a bug in our code.

<!-- gh-comment-id:86517264 --> @magnumripper commented on GitHub (Mar 26, 2015): OK, I still can't reproduce so I can't debug it... if you revert to 2804be376 or dc6159870, can you reproduce it? I still suspect this is an ASan problem and not a bug in our code.
Author
Owner

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

@magnumripper

Both github.com/magnumripper/JohnTheRipper@2804be3762 and github.com/magnumripper/JohnTheRipper@dc6159870e can not reproduce. The bug seems to be introduced days ago.

<!-- gh-comment-id:86520651 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper Both https://github.com/magnumripper/JohnTheRipper/commit/2804be3762a818b833ee7b7155b3165c1c9c93d7 and https://github.com/magnumripper/JohnTheRipper/commit/dc6159870e53467fb90acb54105497dd4acc87fa **can not reproduce**. The bug seems to be introduced days ago.
Author
Owner

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

Both 2804be3 and dc61598 can not reproduce. The bug seems to be introduced days ago.

Not necessarily, it might be that it was hidden before.

Try this (using latest commit again):

diff --git a/src/dynamic_fmt.c b/src/dynamic_fmt.c
index 3c86fd5..1875fe6 100644
--- a/src/dynamic_fmt.c
+++ b/src/dynamic_fmt.c
@@ -725,6 +725,7 @@ static void init(struct fmt_main *pFmt)
        input_buf2 = mem_calloc_align(1, MMX_INP_BUF2_SZ, MEM_ALIGN_SIMD);
        crypt_key  = mem_calloc_align(1, MMX_CRYPT_KEY_SZ, MEM_ALIGN_SIMD);
        crypt_key2 = mem_calloc_align(1, MMX_CRYPT_KEY2_SZ, MEM_ALIGN_SIMD);
+       fprintf(stderr, "%s(): crypt_key2 is at %p\n", __FUNCTION__, crypt_key2);
 #endif
        crypt_key_X86  = (MD5_OUT *)mem_calloc(((MAX_KEYS_PER_CRYPT_X86>>MD5_X2)+1), sizeof(*crypt_key_X86));
        crypt_key2_X86 = (MD5_OUT *)mem_calloc(((MAX_KEYS_PER_CRYPT_X86>>MD5_X2)+1), sizeof(*crypt_key2_X86));
@@ -858,6 +859,7 @@ static void done(void)
        MEM_FREE(crypt_key2_X86);
        MEM_FREE(crypt_key_X86);
 #ifdef SIMD_COEF_32
+       fprintf(stderr, "%s(): crypt_key2 is at %p\n", __FUNCTION__, crypt_key2);
        MEM_FREE(crypt_key2);
        MEM_FREE(crypt_key);
        MEM_FREE(input_buf2);

When I run it, same address is printed (and obviously ASan does not crash). What is the output you get, right before it crashes?

<!-- gh-comment-id:86522312 --> @magnumripper commented on GitHub (Mar 26, 2015): > Both 2804be3 and dc61598 can not reproduce. The bug seems to be introduced days ago. Not necessarily, it might be that it was hidden before. Try this (using latest commit again): ``` diff diff --git a/src/dynamic_fmt.c b/src/dynamic_fmt.c index 3c86fd5..1875fe6 100644 --- a/src/dynamic_fmt.c +++ b/src/dynamic_fmt.c @@ -725,6 +725,7 @@ static void init(struct fmt_main *pFmt) input_buf2 = mem_calloc_align(1, MMX_INP_BUF2_SZ, MEM_ALIGN_SIMD); crypt_key = mem_calloc_align(1, MMX_CRYPT_KEY_SZ, MEM_ALIGN_SIMD); crypt_key2 = mem_calloc_align(1, MMX_CRYPT_KEY2_SZ, MEM_ALIGN_SIMD); + fprintf(stderr, "%s(): crypt_key2 is at %p\n", __FUNCTION__, crypt_key2); #endif crypt_key_X86 = (MD5_OUT *)mem_calloc(((MAX_KEYS_PER_CRYPT_X86>>MD5_X2)+1), sizeof(*crypt_key_X86)); crypt_key2_X86 = (MD5_OUT *)mem_calloc(((MAX_KEYS_PER_CRYPT_X86>>MD5_X2)+1), sizeof(*crypt_key2_X86)); @@ -858,6 +859,7 @@ static void done(void) MEM_FREE(crypt_key2_X86); MEM_FREE(crypt_key_X86); #ifdef SIMD_COEF_32 + fprintf(stderr, "%s(): crypt_key2 is at %p\n", __FUNCTION__, crypt_key2); MEM_FREE(crypt_key2); MEM_FREE(crypt_key); MEM_FREE(input_buf2); ``` When I run it, same address is printed (and obviously ASan does not crash). What is the output you get, right before it crashes?
Author
Owner

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

@magnumripper What's the commit of the John ?

<!-- gh-comment-id:86523292 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper What's the commit of the John ?
Author
Owner

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

latest

<!-- gh-comment-id:86523373 --> @magnumripper commented on GitHub (Mar 26, 2015): latest
Author
Owner

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

@magnumripper

0g 0:00:00:04 3/3 0g/s 1186Kp/s 1186Kc/s 1186KC/s pr12346..plaurra
done(): crypt_key2 is at 0x2e8a080

==58621==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000002e8a080 in thread T0

<!-- gh-comment-id:86526545 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper 0g 0:00:00:04 3/3 0g/s 1186Kp/s 1186Kc/s 1186KC/s pr12346..plaurra **done(): crypt_key2 is at 0x2e8a080** ==58621==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000002e8a080 in thread T0
Author
Owner

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

OK this is clearly an ASan bug. The pointer is fine.

<!-- gh-comment-id:86526945 --> @magnumripper commented on GitHub (Mar 26, 2015): OK this is clearly an ASan bug. The pointer is fine.
Author
Owner

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

OK this is clearly an ASan bug. The pointer is fine.

Scrap that, I misread your post. You need to look at both prints. I get this:

$ ../run/john asaMD5_fmt
init(): crypt_key2 is at 0x63300001c800
Warning: detected hash type "dynamic_20", but the string is also recognized as "asa-md5"
Use the "--format=asa-md5" option to force loading these as that type instead
Loaded 5 password hashes with 5 different salts (dynamic_20 [Cisco ASA (MD5 salted) 128/128 AVX (480x1)x4x3])
Remaining 1 password hash
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
Warning: MaxLen = 13 is too large for the current hash type, reduced to 12
0g 0:00:00:03 3/3 0g/s 108096p/s 108096c/s 108096C/s chessed..sonas13
done(): crypt_key2 is at 0x63300001c800
Session aborted

<!-- gh-comment-id:86527717 --> @magnumripper commented on GitHub (Mar 26, 2015): > OK this is clearly an ASan bug. The pointer is fine. Scrap that, I misread your post. You need to look at **both** prints. I get this: $ ../run/john asaMD5_fmt **init(): crypt_key2 is at 0x63300001c800** Warning: detected hash type "dynamic_20", but the string is also recognized as "asa-md5" Use the "--format=asa-md5" option to force loading these as that type instead Loaded 5 password hashes with 5 different salts (dynamic_20 [Cisco ASA (MD5 salted) 128/128 AVX (480x1)x4x3]) Remaining 1 password hash Will run 8 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status Warning: MaxLen = 13 is too large for the current hash type, reduced to 12 0g 0:00:00:03 3/3 0g/s 108096p/s 108096c/s 108096C/s chessed..sonas13 **done(): crypt_key2 is at 0x63300001c800** Session aborted
Author
Owner

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

@magnumripper

init(): crypt_key2 is at 0x2e8a080
Warning: detected hash type "dynamic_20", but the string is also recognized as "asa-md5"
Use the "--format=asa-md5" option to force loading these as that type instead
Loaded 5 password hashes with 5 different salts (dynamic_20 [Cisco ASA (MD5 salted) 128/128 AVX (480_1)x4x3])
Remaining 1 password hash
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
Warning: MaxLen = 13 is too large for the current hash type, reduced to 12
0g 0:00:00:04 3/3 0g/s 1186Kp/s 1186Kc/s 1186KC/s pr12346..plaurra
_done(): crypt_key2 is at 0x2e8a080*

==58621==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000002e8a080 in thread T0
#0 0x7f95b13775c7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x545c7)
#1 0x7a6e08 in MEMDBG_off_free /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/memdbg.c:1099
#2 0x4913be in done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/dynamic_fmt.c:863
#3 0x7323db in fmt_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/formats.c:112
#4 0x73ff4e in john_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1478
#5 0x7406b6 in main /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1688
#6 0x7f95afbb6ec4 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
#7 0x406cb2 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/run/john+0x406cb2)

AddressSanitizer can not describe address in more detail (wild memory access suspected).
SUMMARY: AddressSanitizer: bad-free ??:0 __interceptor_free
==58621==ABORTING
Aborted

<!-- gh-comment-id:86528584 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper **init(): crypt_key2 is at 0x2e8a080** Warning: detected hash type "dynamic_20", but the string is also recognized as "asa-md5" Use the "--format=asa-md5" option to force loading these as that type instead Loaded 5 password hashes with 5 different salts (dynamic_20 [Cisco ASA (MD5 salted) 128/128 AVX (480_1)x4x3]) Remaining 1 password hash Will run 8 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status Warning: MaxLen = 13 is too large for the current hash type, reduced to 12 0g 0:00:00:04 3/3 0g/s 1186Kp/s 1186Kc/s 1186KC/s pr12346..plaurra *_done(): crypt_key2 is at 0x2e8a080** ==58621==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000002e8a080 in thread T0 #0 0x7f95b13775c7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x545c7) #1 0x7a6e08 in MEMDBG_off_free /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/memdbg.c:1099 #2 0x4913be in done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/dynamic_fmt.c:863 #3 0x7323db in fmt_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/formats.c:112 #4 0x73ff4e in john_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1478 #5 0x7406b6 in main /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1688 #6 0x7f95afbb6ec4 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) #7 0x406cb2 (/home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/run/john+0x406cb2) AddressSanitizer can not describe address in more detail (wild memory access suspected). SUMMARY: AddressSanitizer: bad-free ??:0 __interceptor_free ==58621==ABORTING Aborted
Author
Owner

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

If you get same address printed from init() and done(), you probably just see an ASan bug. You can verify this by running a build without ASan - it should definitely segfault if there was an actual problem.

<!-- gh-comment-id:86529034 --> @magnumripper commented on GitHub (Mar 26, 2015): If you get same address printed from init() and done(), you probably just see an ASan bug. You can verify this by running a build without ASan - it should definitely segfault if there was an actual problem.
Author
Owner

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

@magnumripper Thanks. 👍

<!-- gh-comment-id:86530133 --> @loverszhaokai commented on GitHub (Mar 26, 2015): @magnumripper Thanks. :+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#726
No description provided.