mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #1159] aix_smd5_fmt: asan error #725
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#725
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @loverszhaokai on GitHub (Mar 26, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1159
This bug is found by fuzzzing John using AFL.
#1. Prepare
1.1 content of aix_smd5_fmt
{smd5}s8/xSJ/v$uGam4GB8hOjTLQqvBfxJ2/
{smd5}alRJaSLb$aKM3H1.h1ycXl5GEVDH1e1
{smd5}eLB0QWeS$Eg.YfWY8clZuCxF0xNrKg.
$1$JVDbGx8K$T9h8HK4LZxeLPMTAxCfpc1
$1$1Cu6fEvv$42kuaJ5fMEqyVStPuFG040
$1$ql5x.xXL$vYVDhExol2xUBBpERRWcn1
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 aix_smd5_fmt
Warning: detected hash type "md5crypt", but the string is also recognized as "aix-smd5"
Use the "--format=aix-smd5" option to force loading these as that type instead
Loaded 6 password hashes with 6 different salts (md5crypt, crypt(3)
1[MD5 128/128 AVX 12x])Remaining 4 password hashes with 4 different salts
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:01 2/3 0g/s 5907p/s 24287c/s 24287C/s Sss..rogers
==21362==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000002d3e040 in thread T0
#0 0x7f0bb6f805c7 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 0x426ce1 in done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/MD5_fmt.c:119
#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 0x7f0bb57bfec4 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
==21362==ABORTING
Aborted (core dumped)
@magnumripper commented on GitHub (Mar 26, 2015):
I can not reproduce. Are you still using gcc 4.8? Like I said, it seems you can't reliably use ASan with gcc older than 4.9 since we introduced posix_memalign in
f22ab24c7@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper I will reproduce again with gcc 4.8 to ensure. If I can reproduce, I will update my gcc.
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper
I tested again with gcc-4.8 and gcc-4.9, both can reproduce. I have updated the issue. The gcc-4.9 is good than gcc-4.8 for it does not need asan_symbolize.py.
Have you pay attention to the note: "you should press Ctrl-C to abort john, and after cancel you will see the asan error"
$ ./john aix_smd5_fmt
$ Ctrl-C
@magnumripper commented on GitHub (Mar 26, 2015):
Yes, and I tried several times. Does it happen every time for you?
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper
Yes. And I used test latest commit.
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper
Same as the asaMD5_fmt. Both
github.com/magnumripper/JohnTheRipper@2804be3762andgithub.com/magnumripper/JohnTheRipper@dc6159870ecan not reproduce. The bug seems to be introduced days ago.@magnumripper commented on GitHub (Mar 26, 2015):
This is probably same ASan problem as seen in #1160. ASan mentions MD5_fmt.c:119
...so just put debug prints after line 107 and before line 119. If they show the same (I bet they do) you merely have the ASan bug showing up.
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper
And the output is below, they are the same address.
init(): saved_key is at 0x2521040
Warning: detected hash type "md5crypt", but the string is also recognized as "aix-smd5"
Use the "--format=aix-smd5" option to force loading these as that type instead
Loaded 6 password hashes with 6 different salts (md5crypt, crypt(3)
1[MD5 128/128 AVX 12x])Remaining 4 password hashes with 4 different salts
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:02 2/3 0g/s 6087p/s 24819c/s 24819C/s Inuyasha1..Supra1
done(): saved_key is at 0x2521040
==61195==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000002521040 in thread T0
#0 0x7fb5814cd5c7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x545c7)
#1 0x7a6e09 in MEMDBG_off_free /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/memdbg.c:1099
#2 0x426d24 in done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/MD5_fmt.c:121
#3 0x7323dc in fmt_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/formats.c:112
#4 0x73ff4f in john_done /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1478
#5 0x7406b7 in main /home/zhaokai/WorkSpace/open_wall/JohnTheRipper_test_valid/src/john.c:1688
#6 0x7fb57fd0cec4 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
==61195==ABORTING
Aborted
@magnumripper commented on GitHub (Mar 26, 2015):
Assuming you run 64-bit Linux, here's a patch that will mitigate this ASan bug from showing up:
(edit: the second part of the patch was not needed so I deleted it)
This relies on the fact that 64-bit Linux (and any OSX) will always align to 16. Please try this. If your problems with ASan go away, we can commit this.
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper
Yes, my ubuntu is 64 bit.
$ uname -a
Linux ubuntu 4.0.0-rc1+ #2 SMP Sun Mar 1 10:08:08 CST 2015 x86_64 x86_64 x86_64 GNU/Linux
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper
I tested, but there is still ASan error.
@magnumripper commented on GitHub (Mar 26, 2015):
OK That is really strange. Why would ASan not recognize a simple malloc/free?
Maybe this isn't an ASan bug after all but Jim's memdbg macros are interfering in some way. I never liked the fact they "show up" at all in a non-memdbg build. @jfoug what do you think?
@magnumripper commented on GitHub (Mar 26, 2015):
@loverszhaokai try a memdbg AND ASan build:
...and see how that one behaves.
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper Should I use gcc-4.9 ?
@magnumripper commented on GitHub (Mar 26, 2015):
Yes, or 4.8 - doesn't matter
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper There is still ASan error with both gcc-4.8 and gcc-4.9
@magnumripper commented on GitHub (Mar 26, 2015):
I have absolutely no idea what is happening here. Please try to debug it and see what is really happening. At some point we get a pointer from an actual libc function and not a wrapper. What is that pointer? Are we not freeing the very same address?
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper I just get many ASan errors like aix_smd5_fmt which seems alike.
@magnumripper commented on GitHub (Mar 26, 2015):
Yes. I'd just like to be really sure it's an ASan bug and not some memdbg header bug. So you should concentrate on one (perhaps this one) and try to explain it too 100%.
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper Thanks. I will try to make it sure in recent days.
@magnumripper commented on GitHub (Mar 26, 2015):
@loverszhaokai did you get accounts on Openwall's hosts yet? I just tried to reproduce this bug on "well" (64-bit Linux) but I still see no problem. I used gcc version 4.9.2.
@loverszhaokai commented on GitHub (Mar 26, 2015):
@magnumripper I have not got an account on Openwall's hosts.
Do you mean you can not see ASan error ?
@loverszhaokai commented on GitHub (Mar 28, 2015):
@magnumripper
Thanks for your help. It's really a asan bug, 👍
[asan] is not intercepting aligned_alloc, here is the link for asan bug of gcc: https://gcc.gnu.org/ml/gcc-bugs/2014-07/msg00198.html
The mem_calloc_align() in MD5_fmt.c line 106 invokes aligned_alloc()
@magnumripper commented on GitHub (Mar 28, 2015):
Oh, I see now the bug is only when aligned_alloc() is used. So we can prefer posix_memalign() when both are available (we currently prefer aligned_alloc) and problem is practically 100% worked around! This also explains why I did not see the bug on OSX - on that platform we use posix_memalign since aligned_alloc is not yet available. Will commit a workaround ASAP. I searched gcc bug tracker but did not find the bug you mention.
This also explains why problem was not seen on "well". That machine has an older libc so ends up using posix_memalign.
@magnumripper commented on GitHub (Mar 28, 2015):
@loverszhaokai please verify that
8c56cb2fc55245gets rid of the false positives, and thanks for finding this out!@magnumripper commented on GitHub (Mar 28, 2015):
Stupid me, I googled for "asan posix_memalign"... I should have googled "asan aligned_alloc" and I would have got it in the very first hit o.O
@magnumripper commented on GitHub (Mar 28, 2015):
OK I had to modify configure too because it did not look for posix_memalign after seeing aligned_alloc.
fc55245should be the definitve solution (and you have to re-run configure).@loverszhaokai commented on GitHub (Mar 29, 2015):
@magnumripper Great! 👍
Google: gcc asan aligned_alloc, and here is the link: https://gcc.gnu.org/ml/gcc-bugs/2014-07/msg00198.html
Good!
github.com/magnumripper/JohnTheRipper@fc552453a3has solved this problem.