[GH-ISSUE #2249] KeePass format: ASan error (stack-buffer-overflow) with fuzzed input #1505

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

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

Originally assigned to: @frank-dittrich on GitHub.

Found with american fuzzy lop, https://github.com/mirrorer/afl:

$ cat fail_KeePass.pw1
$keepass$*1*50000*124*60eed105dac456cfc37d89d950ca846e*72ffef7c0bc3698b8eca65184774f6cd91a9356d338e5140e47e319a87f5e46a*8725bdfd3580cf054a1564dc724aaffe*8e58cc08af2462ddffe2ee39735ad14b15e8cb96dc05ef70d8e64d475eca7bf5*2
$ ./john fail_KeePass.pw1
Using default input encoding: UTF-8
Loaded 1 password hash (KeePass [SHA256 AES 32/64 OpenSSL])
Press 'q' or Ctrl-C to abort, almost any other key for status
=================================================================
==7799==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffe2d662abf at pc 0x000000a4e0a1 bp 0x7ffe2d661630 sp 0x7ffe2d661620
READ of size 1 at 0x7ffe2d662abf thread T0
    #0 0xa4e0a0 in crypt_all /home/ubuntuadm/git/JtR/src/keepass_fmt_plug.c:452
    #1 0xd070f8 in crk_password_loop /home/ubuntuadm/git/JtR/src/cracker.c:790
    #2 0xd0c58f in crk_salt_loop /home/ubuntuadm/git/JtR/src/cracker.c:955
    #3 0xdf8e98 in do_wordlist_crack /home/ubuntuadm/git/JtR/src/wordlist.c:1392
    #4 0xcd4727 in do_wordlist_pass /home/ubuntuadm/git/JtR/src/batch.c:38
    #5 0xcd4727 in do_batch_crack /home/ubuntuadm/git/JtR/src/batch.c:58
    #6 0x41f7e1 in john_run /home/ubuntuadm/git/JtR/src/john.c:1724
    #7 0x41f7e1 in main /home/ubuntuadm/git/JtR/src/john.c:1967
    #8 0x7f7e6ff7982f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #9 0x422668 in _start (/home/ubuntuadm/git/JtR/run/john+0x422668)

Address 0x7ffe2d662abf is located in stack of thread T0 at offset 5183 in frame
    #0 0xa4cc5f in crypt_all /home/ubuntuadm/git/JtR/src/keepass_fmt_plug.c:410

  This frame has 9 object(s):
    [32, 144) 'ctx'
    [192, 304) 'composite_ctx'
    [352, 596) 'akey'
    [640, 4896) 'tkey'
    [4928, 4944) 'iv'
    [4992, 5024) 'final_key'
    [5056, 5088) 'hash'
    [5120, 5152) 'temphash'
    [5184, 201792) 'decrypted_content' <== Memory access at offset 5183 underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/ubuntuadm/git/JtR/src/keepass_fmt_plug.c:452 crypt_all
Shadow bytes around the buggy address:
  0x100045ac4500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100045ac4510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100045ac4520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100045ac4530: 00 00 00 00 f2 f2 f2 f2 00 00 f4 f4 f2 f2 f2 f2
  0x100045ac4540: 00 00 00 00 f2 f2 f2 f2 00 00 00 00 f2 f2 f2 f2
=>0x100045ac4550: 00 00 00 00 f2 f2 f2[f2]00 00 00 00 00 00 00 00
  0x100045ac4560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100045ac4570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100045ac4580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100045ac4590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100045ac45a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
==7799==ABORTING

Another hash (also found using afl) causing what looks like the same problem:

$keepass$*1*50000*124*60eed105dac456cfc37d89d950ca846e*72ffef7c0bc3698b8eca65184774f6cd91a9356d338e5140e47e319a87f5e46a*8725bdfd3580cf054a1564dc724aaffe*8e58cc08af2462ddffe2ee39735ad14b15e8cb96dc05ef70d8e64d475eca7bf5*2�711fe86e7a7285d5ac9d5ffd07798b83673b06f34180b7f5f3d05222ebf909c67e6580c646bcb64ad039fcdc6f33178fe475739a562dc78012f6be3104da9af69e0e12c2c9c5cd7134bb99d5278f2738a40155acbe941ff2f88db18daf772c7b5fc1855ff9e93ceb35a1db2c30cabe97a96c58b07c16912b2e095e530cc8c24041e7d4876b842f2e7c6df41d08da8c5c4f2402dd3241c3367b6e6e06cd0fa369934e78a6aab1479756a15264af09e3c8e1037f07a58f70f4bf634737ff58725414db10d7b2f61a7ed69878bc0de8bb99f3795bf9980d87992848cd9b9abe0fa6205a117ab1dd5165cf11ffa10b765e8723251ea0907bbc5f3eef8cf1f08bb89e193842b40c95922f38c44d0c3197033a5c7c926a33687aa71c482c48381baa4a34a46b8a4f78715f42eccbc8df80ee3b43335d92bdeb3bb0667cf6da83a018e4c0cd5803004bf6c300b9bee029246d16bd817ff235fcc22bb8c729929499afbf90bf787e98479db5ff571d3d727059d34c1f14454ff5f0a1d2d025437c2d8db4a7be7b901c067b929a0028fe8bb74fa96cb84831ccd89138329708d12c76bd4f5f371e43d0a2d234e5db2b3d6d5164e773594ab201dc9498078b48d4303dd8a89bf81c76d1424084ebf8d96107cb2623fb1cb67617257a5c7c6e56a8614271256b9dd80c76b6d668de4ebe17574ad617f5b1133f45a6d8621e127fcc99d8e788c535da9f557d91903b4e388108f02e9539a681d42e61f8e2f8b06654d4dec308690902a5c76f55b3d79b7c9a0ce994494bc60eff79ff41debc3f2684f40fc912f09035aae022148238ba6f5cfb92f54a5fb28cbb417ff01f39cc464e95929fba5e19be0251bef59879303063e6392c3a49032af3d03d5c9027868d5d6a187698dd75dfc295d2789a0e6cf391a380cc625b0a49f3084f45558ac273b0bbe62a8614db194983b2e207cef7deb1fa6a0bd39b0215d72bf646b599f187ee0009b7b458bb4930a1aea55222099446a0250a975447ff52
Originally created by @frank-dittrich on GitHub (Aug 29, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2249 Originally assigned to: @frank-dittrich on GitHub. Found with american fuzzy lop, https://github.com/mirrorer/afl: ``` $ cat fail_KeePass.pw1 $keepass$*1*50000*124*60eed105dac456cfc37d89d950ca846e*72ffef7c0bc3698b8eca65184774f6cd91a9356d338e5140e47e319a87f5e46a*8725bdfd3580cf054a1564dc724aaffe*8e58cc08af2462ddffe2ee39735ad14b15e8cb96dc05ef70d8e64d475eca7bf5*2 $ ./john fail_KeePass.pw1 Using default input encoding: UTF-8 Loaded 1 password hash (KeePass [SHA256 AES 32/64 OpenSSL]) Press 'q' or Ctrl-C to abort, almost any other key for status ================================================================= ==7799==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffe2d662abf at pc 0x000000a4e0a1 bp 0x7ffe2d661630 sp 0x7ffe2d661620 READ of size 1 at 0x7ffe2d662abf thread T0 #0 0xa4e0a0 in crypt_all /home/ubuntuadm/git/JtR/src/keepass_fmt_plug.c:452 #1 0xd070f8 in crk_password_loop /home/ubuntuadm/git/JtR/src/cracker.c:790 #2 0xd0c58f in crk_salt_loop /home/ubuntuadm/git/JtR/src/cracker.c:955 #3 0xdf8e98 in do_wordlist_crack /home/ubuntuadm/git/JtR/src/wordlist.c:1392 #4 0xcd4727 in do_wordlist_pass /home/ubuntuadm/git/JtR/src/batch.c:38 #5 0xcd4727 in do_batch_crack /home/ubuntuadm/git/JtR/src/batch.c:58 #6 0x41f7e1 in john_run /home/ubuntuadm/git/JtR/src/john.c:1724 #7 0x41f7e1 in main /home/ubuntuadm/git/JtR/src/john.c:1967 #8 0x7f7e6ff7982f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) #9 0x422668 in _start (/home/ubuntuadm/git/JtR/run/john+0x422668) Address 0x7ffe2d662abf is located in stack of thread T0 at offset 5183 in frame #0 0xa4cc5f in crypt_all /home/ubuntuadm/git/JtR/src/keepass_fmt_plug.c:410 This frame has 9 object(s): [32, 144) 'ctx' [192, 304) 'composite_ctx' [352, 596) 'akey' [640, 4896) 'tkey' [4928, 4944) 'iv' [4992, 5024) 'final_key' [5056, 5088) 'hash' [5120, 5152) 'temphash' [5184, 201792) 'decrypted_content' <== Memory access at offset 5183 underflows this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-overflow /home/ubuntuadm/git/JtR/src/keepass_fmt_plug.c:452 crypt_all Shadow bytes around the buggy address: 0x100045ac4500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100045ac4510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100045ac4520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100045ac4530: 00 00 00 00 f2 f2 f2 f2 00 00 f4 f4 f2 f2 f2 f2 0x100045ac4540: 00 00 00 00 f2 f2 f2 f2 00 00 00 00 f2 f2 f2 f2 =>0x100045ac4550: 00 00 00 00 f2 f2 f2[f2]00 00 00 00 00 00 00 00 0x100045ac4560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100045ac4570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100045ac4580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100045ac4590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100045ac45a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 ==7799==ABORTING ``` Another hash (also found using afl) causing what looks like the same problem: ``` $keepass$*1*50000*124*60eed105dac456cfc37d89d950ca846e*72ffef7c0bc3698b8eca65184774f6cd91a9356d338e5140e47e319a87f5e46a*8725bdfd3580cf054a1564dc724aaffe*8e58cc08af2462ddffe2ee39735ad14b15e8cb96dc05ef70d8e64d475eca7bf5*2�711fe86e7a7285d5ac9d5ffd07798b83673b06f34180b7f5f3d05222ebf909c67e6580c646bcb64ad039fcdc6f33178fe475739a562dc78012f6be3104da9af69e0e12c2c9c5cd7134bb99d5278f2738a40155acbe941ff2f88db18daf772c7b5fc1855ff9e93ceb35a1db2c30cabe97a96c58b07c16912b2e095e530cc8c24041e7d4876b842f2e7c6df41d08da8c5c4f2402dd3241c3367b6e6e06cd0fa369934e78a6aab1479756a15264af09e3c8e1037f07a58f70f4bf634737ff58725414db10d7b2f61a7ed69878bc0de8bb99f3795bf9980d87992848cd9b9abe0fa6205a117ab1dd5165cf11ffa10b765e8723251ea0907bbc5f3eef8cf1f08bb89e193842b40c95922f38c44d0c3197033a5c7c926a33687aa71c482c48381baa4a34a46b8a4f78715f42eccbc8df80ee3b43335d92bdeb3bb0667cf6da83a018e4c0cd5803004bf6c300b9bee029246d16bd817ff235fcc22bb8c729929499afbf90bf787e98479db5ff571d3d727059d34c1f14454ff5f0a1d2d025437c2d8db4a7be7b901c067b929a0028fe8bb74fa96cb84831ccd89138329708d12c76bd4f5f371e43d0a2d234e5db2b3d6d5164e773594ab201dc9498078b48d4303dd8a89bf81c76d1424084ebf8d96107cb2623fb1cb67617257a5c7c6e56a8614271256b9dd80c76b6d668de4ebe17574ad617f5b1133f45a6d8621e127fcc99d8e788c535da9f557d91903b4e388108f02e9539a681d42e61f8e2f8b06654d4dec308690902a5c76f55b3d79b7c9a0ce994494bc60eff79ff41debc3f2684f40fc912f09035aae022148238ba6f5cfb92f54a5fb28cbb417ff01f39cc464e95929fba5e19be0251bef59879303063e6392c3a49032af3d03d5c9027868d5d6a187698dd75dfc295d2789a0e6cf391a380cc625b0a49f3084f45558ac273b0bbe62a8614db194983b2e207cef7deb1fa6a0bd39b0215d72bf646b599f187ee0009b7b458bb4930a1aea55222099446a0250a975447ff52 ```
Author
Owner

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

1a06e3a Reverted The prior change caused the format to not self test properly

<!-- gh-comment-id:243227171 --> @jfoug commented on GitHub (Aug 29, 2016): 1a06e3a Reverted The prior change caused the format to not self test properly
Author
Owner

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

0b005fe

<!-- gh-comment-id:243243285 --> @jfoug commented on GitHub (Aug 29, 2016): 0b005fe
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#1505
No description provided.