[GH-ISSUE #1667] Bitcoin format -- EVP_DecryptFinal_ex() double free or corruption #1102

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

Originally created by @loverszhaokai on GitHub (Aug 15, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1667

This bug can not be reproduced every time. There is at least 1 crash when you run 200 times.
Also can not reproduced in my local machine, since I can not make the bitcoin. max_keys_per_crypt = 64.

This bug is found on super by Solar. See http://www.openwall.com/lists/john-dev/2015/08/06/13

If your bitcoin. max_keys_per_crypt is not 64, please set this "OMP_NUM_THREADS=32".
#1. Reproduce

$ cat pwd.lst

3133731337!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3133731337""""""""""""""""""""""""""""""""""""""""""""""""""""""
3133731337######################################################
3133731337$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
3133731337%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3133731337&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
3133731337''''''''''''''''''''''''''''''''''''''''''''''''''''''
3133731337((((((((((((((((((((((((((((((((((((((((((((((((((((((
3133731337))))))))))))))))))))))))))))))))))))))))))))))))))))))
3133731337******************************************************
3133731337++++++++++++++++++++++++++++++++++++++++++++++++++++++
3133731337,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3133731337------------------------------------------------------
3133731337......................................................
3133731337//////////////////////////////////////////////////////
3133731337000000000000000000000000000000000000000000000000000000
3133731337111111111111111111111111111111111111111111111111111111
3133731337222222222222222222222222222222222222222222222222222222
3133731337333333333333333333333333333333333333333333333333333333
3133731337444444444444444444444444444444444444444444444444444444
3133731337555555555555555555555555555555555555555555555555555555
3133731337666666666666666666666666666666666666666666666666666666
3133731337777777777777777777777777777777777777777777777777777777
3133731337888888888888888888888888888888888888888888888888888888
3133731337999999999999999999999999999999999999999999999999999999
3133731337::::::::::::::::::::::::::::::::::::::::::::::::::::::
3133731337;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3133731337<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
3133731337======================================================
3133731337>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
3133731337??????????????????????????????????????????????????????
3133731337@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
3133731337!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3133731337""""""""""""""""""""""""""""""""""""""""""""""""""""""
3133731337######################################################
3133731337$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
3133731337%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3133731337&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
3133731337''''''''''''''''''''''''''''''''''''''''''''''''''''''
3133731337((((((((((((((((((((((((((((((((((((((((((((((((((((((
3133731337))))))))))))))))))))))))))))))))))))))))))))))))))))))
3133731337******************************************************
3133731337++++++++++++++++++++++++++++++++++++++++++++++++++++++
3133731337,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3133731337------------------------------------------------------
3133731337......................................................
3133731337//////////////////////////////////////////////////////
3133731337000000000000000000000000000000000000000000000000000000
3133731337111111111111111111111111111111111111111111111111111111
3133731337222222222222222222222222222222222222222222222222222222
3133731337333333333333333333333333333333333333333333333333333333
3133731337444444444444444444444444444444444444444444444444444444
3133731337555555555555555555555555555555555555555555555555555555
3133731337666666666666666666666666666666666666666666666666666666
3133731337777777777777777777777777777777777777777777777777777777
3133731337888888888888888888888888888888888888888888888888888888
3133731337999999999999999999999999999999999999999999999999999999
3133731337::::::::::::::::::::::::::::::::::::::::::::::::::::::
3133731337;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3133731337<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
3133731337======================================================
3133731337>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
3133731337??????????????????????????????????????????????????????
openwall

$ cat pwfile

$bitcoin$96$169ce74743c260678fbbba92e926198702fd84e46ba555190f6f3d82f6852e4adeaa340d2ac065288e8605f13d1d7c86$16$26049c64dda292d5$177864$96$62aee49c1967b5635b663fc3b047d8bc562f7000921453ab15b98e5a5f2d2adc74393e789fe15c5a3fbc4625536be98a$66$020027f255fbfa6d4c010a1a5984e487443c68e1b32869ccfde92e92005814fd27

$ rm -f ./john.pot && ./john pwfile --format=bitcoin --wordlist=pwd.lst --skip-self-test

*** glibc detected *** ./john: double free or corruption (out): 0x00007f60b4000cf0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x75e66)[0x7f60d0c0de66]
/lib64/libc.so.6(+0x789b3)[0x7f60d0c109b3]
/lib64/libc.so.6(+0x7b880)[0x7f60d0c13880]
/lib64/libc.so.6(realloc+0xe5)[0x7f60d0c13af5]
/usr/lib64/libcrypto.so.10(CRYPTO_realloc+0x5f)[0x7f60d20ffccf]
/usr/lib64/libcrypto.so.10(lh_insert+0xee)[0x7f60d217a58e]
/usr/lib64/libcrypto.so.10(+0xe7c71)[0x7f60d217cc71]
/usr/lib64/libcrypto.so.10(ERR_get_state+0xce)[0x7f60d217d10e]
/usr/lib64/libcrypto.so.10(ERR_put_error+0x2f)[0x7f60d217d8df]
/usr/lib64/libcrypto.so.10(EVP_DecryptFinal_ex+0x1c1)[0x7f60d217f841]
./john[0x52d66e]
/usr/lib64/libgomp.so.1(+0xe0c5)[0x7f60d11570c5]
/lib64/libpthread.so.0(+0x79d1)[0x7f60d0f339d1]
/lib64/libc.so.6(clone+0x6d)[0x7f60d0c808fd]
======= Memory map: ========
00400000-00827000 r-xp 00000000 09:7f 22418558                           /home/kai/workspace/john_jumbo/JohnTheRipper/run/john
00a27000-00aa8000 rw-p 00427000 09:7f 22418558                           /home/kai/workspace/john_jumbo/JohnTheRipper/run/john
00aa8000-00fb0000 rw-p 00000000 00:00 0
0183e000-01b52000 rw-p 00000000 00:00 0                                  [heap]
7f602c000000-7f602c021000 rw-p 00000000 00:00 0
7f602c021000-7f6030000000 ---p 00000000 00:00 0
7f6030000000-7f6030021000 rw-p 00000000 00:00 0

sometimes it reports another error

Using default input encoding: UTF-8
Loaded 1 password hash (Bitcoin [SHA512 AES 128/128 AVX 2x])
Will run 32 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
crypt_all(*pcount=64)
openwall         (?)
*** glibc detected *** ./john: malloc(): memory corruption: 0x0000000002b04060 ***
*** glibc detected *** ./john: malloc(): memory corruption: 0x0000000002b04060 ***

Here I wrote a simple script to run 50 times, maybe you can use it.
$ cat loop.sh

#!/bin/bash

c=1

while [ $c -le 50 ]
do

    echo ""
    echo $c
    rm -f ./john.pot && ./john pwfile --format=bitcoin --wordlist=pwd.lst --skip-self-test

    ((c++))
done
Originally created by @loverszhaokai on GitHub (Aug 15, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1667 This bug can not be reproduced every time. There is at least 1 crash when you run 200 times. Also can not reproduced in my local machine, since I can not make the **bitcoin. max_keys_per_crypt = 64**. This bug is found on super by Solar. See http://www.openwall.com/lists/john-dev/2015/08/06/13 If your **bitcoin. max_keys_per_crypt** is not **64**, please set this "OMP_NUM_THREADS=32". #1. Reproduce $ cat pwd.lst ``` 3133731337!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3133731337"""""""""""""""""""""""""""""""""""""""""""""""""""""" 3133731337###################################################### 3133731337$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 3133731337%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3133731337&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 3133731337'''''''''''''''''''''''''''''''''''''''''''''''''''''' 3133731337(((((((((((((((((((((((((((((((((((((((((((((((((((((( 3133731337)))))))))))))))))))))))))))))))))))))))))))))))))))))) 3133731337****************************************************** 3133731337++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3133731337,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 3133731337------------------------------------------------------ 3133731337...................................................... 3133731337////////////////////////////////////////////////////// 3133731337000000000000000000000000000000000000000000000000000000 3133731337111111111111111111111111111111111111111111111111111111 3133731337222222222222222222222222222222222222222222222222222222 3133731337333333333333333333333333333333333333333333333333333333 3133731337444444444444444444444444444444444444444444444444444444 3133731337555555555555555555555555555555555555555555555555555555 3133731337666666666666666666666666666666666666666666666666666666 3133731337777777777777777777777777777777777777777777777777777777 3133731337888888888888888888888888888888888888888888888888888888 3133731337999999999999999999999999999999999999999999999999999999 3133731337:::::::::::::::::::::::::::::::::::::::::::::::::::::: 3133731337;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3133731337<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 3133731337====================================================== 3133731337>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3133731337?????????????????????????????????????????????????????? 3133731337@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3133731337!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3133731337"""""""""""""""""""""""""""""""""""""""""""""""""""""" 3133731337###################################################### 3133731337$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 3133731337%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3133731337&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 3133731337'''''''''''''''''''''''''''''''''''''''''''''''''''''' 3133731337(((((((((((((((((((((((((((((((((((((((((((((((((((((( 3133731337)))))))))))))))))))))))))))))))))))))))))))))))))))))) 3133731337****************************************************** 3133731337++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3133731337,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 3133731337------------------------------------------------------ 3133731337...................................................... 3133731337////////////////////////////////////////////////////// 3133731337000000000000000000000000000000000000000000000000000000 3133731337111111111111111111111111111111111111111111111111111111 3133731337222222222222222222222222222222222222222222222222222222 3133731337333333333333333333333333333333333333333333333333333333 3133731337444444444444444444444444444444444444444444444444444444 3133731337555555555555555555555555555555555555555555555555555555 3133731337666666666666666666666666666666666666666666666666666666 3133731337777777777777777777777777777777777777777777777777777777 3133731337888888888888888888888888888888888888888888888888888888 3133731337999999999999999999999999999999999999999999999999999999 3133731337:::::::::::::::::::::::::::::::::::::::::::::::::::::: 3133731337;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3133731337<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 3133731337====================================================== 3133731337>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3133731337?????????????????????????????????????????????????????? openwall ``` $ cat pwfile ``` $bitcoin$96$169ce74743c260678fbbba92e926198702fd84e46ba555190f6f3d82f6852e4adeaa340d2ac065288e8605f13d1d7c86$16$26049c64dda292d5$177864$96$62aee49c1967b5635b663fc3b047d8bc562f7000921453ab15b98e5a5f2d2adc74393e789fe15c5a3fbc4625536be98a$66$020027f255fbfa6d4c010a1a5984e487443c68e1b32869ccfde92e92005814fd27 ``` $ rm -f ./john.pot && ./john pwfile --format=bitcoin --wordlist=pwd.lst --skip-self-test ``` *** glibc detected *** ./john: double free or corruption (out): 0x00007f60b4000cf0 *** ======= Backtrace: ========= /lib64/libc.so.6(+0x75e66)[0x7f60d0c0de66] /lib64/libc.so.6(+0x789b3)[0x7f60d0c109b3] /lib64/libc.so.6(+0x7b880)[0x7f60d0c13880] /lib64/libc.so.6(realloc+0xe5)[0x7f60d0c13af5] /usr/lib64/libcrypto.so.10(CRYPTO_realloc+0x5f)[0x7f60d20ffccf] /usr/lib64/libcrypto.so.10(lh_insert+0xee)[0x7f60d217a58e] /usr/lib64/libcrypto.so.10(+0xe7c71)[0x7f60d217cc71] /usr/lib64/libcrypto.so.10(ERR_get_state+0xce)[0x7f60d217d10e] /usr/lib64/libcrypto.so.10(ERR_put_error+0x2f)[0x7f60d217d8df] /usr/lib64/libcrypto.so.10(EVP_DecryptFinal_ex+0x1c1)[0x7f60d217f841] ./john[0x52d66e] /usr/lib64/libgomp.so.1(+0xe0c5)[0x7f60d11570c5] /lib64/libpthread.so.0(+0x79d1)[0x7f60d0f339d1] /lib64/libc.so.6(clone+0x6d)[0x7f60d0c808fd] ======= Memory map: ======== 00400000-00827000 r-xp 00000000 09:7f 22418558 /home/kai/workspace/john_jumbo/JohnTheRipper/run/john 00a27000-00aa8000 rw-p 00427000 09:7f 22418558 /home/kai/workspace/john_jumbo/JohnTheRipper/run/john 00aa8000-00fb0000 rw-p 00000000 00:00 0 0183e000-01b52000 rw-p 00000000 00:00 0 [heap] 7f602c000000-7f602c021000 rw-p 00000000 00:00 0 7f602c021000-7f6030000000 ---p 00000000 00:00 0 7f6030000000-7f6030021000 rw-p 00000000 00:00 0 ``` sometimes it reports another error ``` Using default input encoding: UTF-8 Loaded 1 password hash (Bitcoin [SHA512 AES 128/128 AVX 2x]) Will run 32 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status crypt_all(*pcount=64) openwall (?) *** glibc detected *** ./john: malloc(): memory corruption: 0x0000000002b04060 *** *** glibc detected *** ./john: malloc(): memory corruption: 0x0000000002b04060 *** ``` Here I wrote a simple script to run 50 times, maybe you can use it. $ cat loop.sh ``` #!/bin/bash c=1 while [ $c -le 50 ] do echo "" echo $c rm -f ./john.pot && ./john pwfile --format=bitcoin --wordlist=pwd.lst --skip-self-test ((c++)) done ```
bsakaguchi 2026-10-14 03:35:04 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Aug 19, 2015):

All EVP AES CBC crap in this format (and other ones) should be replaced with our local "aes.h" and the functions declared in it (lower level interface, run-time detection of AES-NI and usually much faster for our use).

<!-- gh-comment-id:132731671 --> @magnumripper commented on GitHub (Aug 19, 2015): All EVP AES CBC crap in this format (and other ones) should be replaced with our local "aes.h" and the functions declared in it (lower level interface, run-time detection of AES-NI and usually much faster for our use).
Author
Owner

@magnumripper commented on GitHub (Aug 19, 2015):

All EVP AES CBC crap in this format (and other ones) should be replaced with our local "aes.h"

Done in 0e2beec.

@loverszhaokai please re-test. I'm pretty sure the bug is fixed now. If there's indeed a bug still in our code, it's probably easier to detect now, and ASan might be able to trigger on it.

<!-- gh-comment-id:132752887 --> @magnumripper commented on GitHub (Aug 19, 2015): > All EVP AES CBC crap in this format (and other ones) should be replaced with our local "aes.h" Done in 0e2beec. @loverszhaokai please re-test. I'm pretty sure the bug is fixed now. If there's indeed a bug still in our code, it's probably easier to detect now, and ASan might be able to trigger on it.
Author
Owner

@magnumripper commented on GitHub (Aug 19, 2015):

See also #1686

<!-- gh-comment-id:132760247 --> @magnumripper commented on GitHub (Aug 19, 2015): See also #1686
Author
Owner

@loverszhaokai commented on GitHub (Aug 20, 2015):

@magnumripper I have run "./john --test-full=0 --format=bitcoin" about 500 times and it did not crash. I think this bug is fixed. Thanks.

<!-- gh-comment-id:132880330 --> @loverszhaokai commented on GitHub (Aug 20, 2015): @magnumripper I have run "./john --test-full=0 --format=bitcoin" about 500 times and it did not crash. I think this bug is fixed. Thanks.
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#1102
No description provided.