[GH-ISSUE #1744] Single-mode ASan segfault (in rules.c) #1153

Closed
opened 2026-10-14 03:37:01 +07:00 by bsakaguchi · 18 comments
Owner

Originally created by @magnumripper on GitHub (Sep 11, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1744

$ cat test.in
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEF:@dynamic=md4($s.$p)@f3ccd788277509feff0a5cac743d8920$85b68792

$ ../run/john -form:dynamic='md4($s.$p)' test.in
Using default input encoding: UTF-8
Loaded 1 password hash (dynamic=md4($s.$p) [128/128 AVX 4x3])
Warning: no OpenMP support for this hash type, consider --fork=8
=================================================================
==24220==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff5ab28521 at pc 0x00010620f348 bp 0x7fff5ab28420 sp 0x7fff5ab27bd0
READ of size 255 at 0x7fff5ab28521 thread T0
    #1 0x10562ea08 in rules_apply rules.c:1895
    #2 0x105630050 in rules_reject rules.c:1306
    #3 0x1056302c5 in rules_check rules.c:2072
    #4 0x10563079c in rules_count rules.c:2250
    #5 0x105631f06 in single_init single.c:136
    #6 0x105634489 in do_single_crack single.c:537
    #7 0x1055cec9c in do_single_pass batch.c:26
    #8 0x1055cee03 in do_batch_crack batch.c:52
    #9 0x1055fe812 in john_run john.c:1599
    #10 0x1055ff3d6 in main john.c:1857
    #11 0x7fff8a49b5c8 in start (in libdyld.dylib) + 0
    #12 0x2  (<unknown module>)

Address 0x7fff5ab28521 is located in stack of thread T0 at offset 161 in frame
    #0 0x10562a78d  (/Users/magnum/src/john/src/../run/john+0x10055678d)

  This frame has 1 object(s):
    [32, 161) 'cpword' <== Memory access at offset 161 overflows 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 ??:0 ??
Shadow bytes around the buggy address:
  0x1fffeb565050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb565060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb565070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb565080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb565090: f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00 00
=>0x1fffeb5650a0: 00 00 00 00[01]f4 f4 f4 f3 f3 f3 f3 00 00 00 00
  0x1fffeb5650b0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
  0x1fffeb5650c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb5650d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb5650e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeb5650f0: 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
==24220==ABORTING

Note: It's only a read, not necessarily a real problem.

Originally created by @magnumripper on GitHub (Sep 11, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1744 ``` $ cat test.in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEF:@dynamic=md4($s.$p)@f3ccd788277509feff0a5cac743d8920$85b68792 $ ../run/john -form:dynamic='md4($s.$p)' test.in Using default input encoding: UTF-8 Loaded 1 password hash (dynamic=md4($s.$p) [128/128 AVX 4x3]) Warning: no OpenMP support for this hash type, consider --fork=8 ================================================================= ==24220==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff5ab28521 at pc 0x00010620f348 bp 0x7fff5ab28420 sp 0x7fff5ab27bd0 READ of size 255 at 0x7fff5ab28521 thread T0 #1 0x10562ea08 in rules_apply rules.c:1895 #2 0x105630050 in rules_reject rules.c:1306 #3 0x1056302c5 in rules_check rules.c:2072 #4 0x10563079c in rules_count rules.c:2250 #5 0x105631f06 in single_init single.c:136 #6 0x105634489 in do_single_crack single.c:537 #7 0x1055cec9c in do_single_pass batch.c:26 #8 0x1055cee03 in do_batch_crack batch.c:52 #9 0x1055fe812 in john_run john.c:1599 #10 0x1055ff3d6 in main john.c:1857 #11 0x7fff8a49b5c8 in start (in libdyld.dylib) + 0 #12 0x2 (<unknown module>) Address 0x7fff5ab28521 is located in stack of thread T0 at offset 161 in frame #0 0x10562a78d (/Users/magnum/src/john/src/../run/john+0x10055678d) This frame has 1 object(s): [32, 161) 'cpword' <== Memory access at offset 161 overflows 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 ??:0 ?? Shadow bytes around the buggy address: 0x1fffeb565050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1fffeb565060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1fffeb565070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1fffeb565080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1fffeb565090: f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00 00 =>0x1fffeb5650a0: 00 00 00 00[01]f4 f4 f4 f3 f3 f3 f3 00 00 00 00 0x1fffeb5650b0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 0x1fffeb5650c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1fffeb5650d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1fffeb5650e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1fffeb5650f0: 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 ==24220==ABORTING ``` Note: It's only a read, not necessarily a real problem.
bsakaguchi 2026-10-14 03:37:01 +07:00
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

This is the rule: (one of the new ones @frank-dittrich helped with, which I added to the single rules)

(?a )?d /?d 'p Xpz0

what is dying is in the X command. What it is trying to do, is copy data from the last 'find' to an infinite length into a buffer.

infinite is 0xff
buffer length is 0x80

So, you can see the 'problem' We are doing a memcpy that is about 100% assured to overflow.

We need to figure this out. Yes, the rule should be changed. BUT we should not be allowing buffer overflows either. The ASAN error is 100% valid.

<!-- gh-comment-id:139647929 --> @jfoug commented on GitHub (Sep 11, 2015): This is the rule: (one of the new ones @frank-dittrich helped with, which I added to the single rules) (?a )?d /?d 'p Xpz0 what is dying is in the X command. What it is trying to do, is copy data from the last 'find' to an infinite length into a buffer. infinite is 0xff buffer length is 0x80 So, you can see the 'problem' We are doing a memcpy that is about 100% assured to overflow. We need to figure this out. Yes, the rule should be changed. BUT we should not be allowing buffer overflows either. The ASAN error is 100% valid.
Author
Owner

@frank-dittrich commented on GitHub (Sep 11, 2015):

Actually, if the current word is shorter than length z (of [0-9A-Za-z]), then that command should copy to the end of the current word.
At least that's how I understand the rule.

Can this be reproduced in master?

<!-- gh-comment-id:139649270 --> @frank-dittrich commented on GitHub (Sep 11, 2015): Actually, if the current word is shorter than length z (of `[0-9A-Za-z]`), then that command should copy to the end of the current word. At least that's how I understand the rule. Can this be reproduced in master?
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

This causes the crash to go away. I am not 100% sure it is the correct fix however

[ghost@localhost src]$ git diff rules.c
diff --git a/src/rules.c b/src/rules.c
index 725b650..f61ef6e 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -1890,6 +1890,11 @@ char *rules_apply(char *word_in, char *rule, int split, char *last)
                                        count = mleft;
                                if (count <= 0)
                                        break;
+                               if (count+length > sizeof(memory)-1) {
+                                       count = (sizeof(memory)-1)-length;
+                                       if (count < 0)
+                                               break;
+                               }
                                mp = memory + mpos;
                                if (ipos >= length) {
                                        memcpy(&in[length], mp, count);

Note, I also found this in code, and think this is very buggy

/*
 * This assumes that RULE_WORD_SIZE is small enough that length can't reach or
 * exceed INVALID_LENGTH.
 */
    rules_vars['l'] = length;
    rules_vars['m'] = (unsigned char)length - 1;

<!-- gh-comment-id:139655538 --> @jfoug commented on GitHub (Sep 11, 2015): This causes the crash to go away. I am not 100% sure it is the correct fix however ``` diff [ghost@localhost src]$ git diff rules.c diff --git a/src/rules.c b/src/rules.c index 725b650..f61ef6e 100644 --- a/src/rules.c +++ b/src/rules.c @@ -1890,6 +1890,11 @@ char *rules_apply(char *word_in, char *rule, int split, char *last) count = mleft; if (count <= 0) break; + if (count+length > sizeof(memory)-1) { + count = (sizeof(memory)-1)-length; + if (count < 0) + break; + } mp = memory + mpos; if (ipos >= length) { memcpy(&in[length], mp, count); ``` Note, I also found this in code, and think this is very buggy ``` C /* * This assumes that RULE_WORD_SIZE is small enough that length can't reach or * exceed INVALID_LENGTH. */ rules_vars['l'] = length; rules_vars['m'] = (unsigned char)length - 1; ```
Author
Owner

@magnumripper commented on GitHub (Sep 11, 2015):

We should definitely try to reproduce this in John Proper

<!-- gh-comment-id:139655896 --> @magnumripper commented on GitHub (Sep 11, 2015): We should definitely try to reproduce this in John Proper
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

now I have to figure out how to 'patch' makefile to do ASAN (or do we have an asan target already?)

<!-- gh-comment-id:139656508 --> @jfoug commented on GitHub (Sep 11, 2015): now I have to figure out how to 'patch' makefile to do ASAN (or do we have an asan target already?)
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

Ok, here is an easier to test example

echo ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEF | ../run/john -pipe -rules:single -stdout

That trips the bug. So we simply have to make a rule with the bad item (in master, which is the new name I will use for john-proper, lol), and run some tests to check for ASAN

<!-- gh-comment-id:139659236 --> @jfoug commented on GitHub (Sep 11, 2015): Ok, here is an easier to test example ``` echo ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEF | ../run/john -pipe -rules:single -stdout ``` That trips the bug. So we simply have to make a rule with the bad item (in master, which is the new name I will use for john-proper, lol), and run some tests to check for ASAN
Author
Owner

@magnumripper commented on GitHub (Sep 11, 2015):

Except john proper doesn't have -pipe :duh:

<!-- gh-comment-id:139659593 --> @magnumripper commented on GitHub (Sep 11, 2015): Except john proper doesn't have -pipe :duh:
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

Master crashes with ASAN just the same

$ ../run/john -rules in.txt -word=../../JtR/src/in1 -format=lm
Loaded 3 password hashes with no different salts (LM [DES 128/128 AVX-16])
=================================================================
==10343==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000047f481 at pc 0x7fd29fc5bdf5 bp 0x7fff4c3c8140 sp 0x7fff4c3c78e8
READ of size 255 at 0x00000047f481 thread T0
    #0 0x7fd29fc5bdf4 in __asan_memcpy (/lib64/libasan.so.2+0x8cdf4)
    #1 0x466e41  (/home/ghost/JtR-master/run/john+0x466e41)
    #2 0x468dc0  (/home/ghost/JtR-master/run/john+0x468dc0)
    #3 0x46900e  (/home/ghost/JtR-master/run/john+0x46900e)
    #4 0x469105  (/home/ghost/JtR-master/run/john+0x469105)
    #5 0x46e33c  (/home/ghost/JtR-master/run/john+0x46e33c)
    #6 0x403ab6  (/home/ghost/JtR-master/run/john+0x403ab6)
    #7 0x7fd29f5f96ff in __libc_start_main (/lib64/libc.so.6+0x206ff)
    #8 0x404e68  (/home/ghost/JtR-master/run/john+0x404e68)

0x00000047f481 is located 0 bytes to the right of global variable '*.LC13' defined in 'rules.c' (0x47f480) of size 1
  '*.LC13' is ascii string ''
0x00000047f481 is located 63 bytes to the left of global variable '*.LC14' defined in 'rules.c' (0x47f4c0) of size 95
  '*.LC14' is ascii string '~!@#$%^&*()_+|QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?`1234567890-=\qwertyuiop[]asdfghjkl;'zxcvbnm,./'
SUMMARY: AddressSanitizer: global-buffer-overflow ??:0 __asan_memcpy
Shadow bytes around the buggy address:
  0x000080087e40: 00 03 f9 f9 f9 f9 f9 f9 03 f9 f9 f9 f9 f9 f9 f9
  0x000080087e50: 00 02 f9 f9 f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9
  0x000080087e60: 00 00 00 03 f9 f9 f9 f9 00 00 00 03 f9 f9 f9 f9
  0x000080087e70: 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 05 f9
  0x000080087e80: f9 f9 f9 f9 00 00 00 00 00 00 00 07 f9 f9 f9 f9
=>0x000080087e90:[01]f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x000080087ea0: 00 00 00 07 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x000080087eb0: 00 00 00 07 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x000080087ec0: 00 00 00 07 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x000080087ed0: 00 00 00 07 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x000080087ee0: 00 00 00 07 f9 f9 f9 f9 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
==10343==ABORTING
<!-- gh-comment-id:139660080 --> @jfoug commented on GitHub (Sep 11, 2015): Master crashes with ASAN just the same ``` $ ../run/john -rules in.txt -word=../../JtR/src/in1 -format=lm Loaded 3 password hashes with no different salts (LM [DES 128/128 AVX-16]) ================================================================= ==10343==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000047f481 at pc 0x7fd29fc5bdf5 bp 0x7fff4c3c8140 sp 0x7fff4c3c78e8 READ of size 255 at 0x00000047f481 thread T0 #0 0x7fd29fc5bdf4 in __asan_memcpy (/lib64/libasan.so.2+0x8cdf4) #1 0x466e41 (/home/ghost/JtR-master/run/john+0x466e41) #2 0x468dc0 (/home/ghost/JtR-master/run/john+0x468dc0) #3 0x46900e (/home/ghost/JtR-master/run/john+0x46900e) #4 0x469105 (/home/ghost/JtR-master/run/john+0x469105) #5 0x46e33c (/home/ghost/JtR-master/run/john+0x46e33c) #6 0x403ab6 (/home/ghost/JtR-master/run/john+0x403ab6) #7 0x7fd29f5f96ff in __libc_start_main (/lib64/libc.so.6+0x206ff) #8 0x404e68 (/home/ghost/JtR-master/run/john+0x404e68) 0x00000047f481 is located 0 bytes to the right of global variable '*.LC13' defined in 'rules.c' (0x47f480) of size 1 '*.LC13' is ascii string '' 0x00000047f481 is located 63 bytes to the left of global variable '*.LC14' defined in 'rules.c' (0x47f4c0) of size 95 '*.LC14' is ascii string '~!@#$%^&*()_+|QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?`1234567890-=\qwertyuiop[]asdfghjkl;'zxcvbnm,./' SUMMARY: AddressSanitizer: global-buffer-overflow ??:0 __asan_memcpy Shadow bytes around the buggy address: 0x000080087e40: 00 03 f9 f9 f9 f9 f9 f9 03 f9 f9 f9 f9 f9 f9 f9 0x000080087e50: 00 02 f9 f9 f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9 0x000080087e60: 00 00 00 03 f9 f9 f9 f9 00 00 00 03 f9 f9 f9 f9 0x000080087e70: 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 05 f9 0x000080087e80: f9 f9 f9 f9 00 00 00 00 00 00 00 07 f9 f9 f9 f9 =>0x000080087e90:[01]f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00 0x000080087ea0: 00 00 00 07 f9 f9 f9 f9 00 00 00 00 00 00 00 00 0x000080087eb0: 00 00 00 07 f9 f9 f9 f9 00 00 00 00 00 00 00 00 0x000080087ec0: 00 00 00 07 f9 f9 f9 f9 00 00 00 00 00 00 00 00 0x000080087ed0: 00 00 00 07 f9 f9 f9 f9 00 00 00 00 00 00 00 00 0x000080087ee0: 00 00 00 07 f9 f9 f9 f9 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 ==10343==ABORTING ```
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

I tried running asan_symbolize.py and it did not get file/lines. Likely I do not have the asan stuff right. BUT none the less, the same type issue is present in master as we are seeing in jumbo.

I was almost certain this was the case, since I have started to get pretty familiar with rules, since I have (almost) rewritten the whole thing in a different language (re-write, not a port).

<!-- gh-comment-id:139660668 --> @jfoug commented on GitHub (Sep 11, 2015): I tried running asan_symbolize.py and it did not get file/lines. Likely I do not have the asan stuff right. BUT none the less, the same type issue is present in master as we are seeing in jumbo. I was almost certain this was the case, since I have started to get pretty familiar with rules, since I have (almost) rewritten the whole thing in a different language (re-write, not a port).
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

May not be the same bug (but an ASAN none the less). I put the same 'patch' in that removed the asan error from jumbo, did not remove the asan problem I show above for master. But master is having some rules problem when working with data unlike what it was tested with

<!-- gh-comment-id:139664266 --> @jfoug commented on GitHub (Sep 11, 2015): May not be the same bug (but an ASAN none the less). I put the same 'patch' in that removed the asan error from jumbo, did not remove the asan problem I show above for master. But master is having some rules problem when working with data unlike what it was tested with
Author
Owner

@jfoug commented on GitHub (Sep 11, 2015):

We might need to fuzz the rules.

<!-- gh-comment-id:139664327 --> @jfoug commented on GitHub (Sep 11, 2015): We might need to fuzz the rules.
Author
Owner

@magnumripper commented on GitHub (Dec 2, 2015):

I was considering applying your patch but after carefully inspecting the code I don't get this. The original code already has this:

                mleft = (int)(rules_vars['m'] + 1) - mpos;
                if (count > mleft)
                    count = mleft;

The rules_vars('m') is the "initial or memorized word's last character position" so after the above, count should have shrinked from infinite z to actual word length.

So why is your patch needed? It should be a no-op. I take your word on it that it isn't, but how come?

The trigger rule was allegedly (?a )?d /?d 'p Xpz0.

(?a reject the word unless its first character is a letter [a-zA-Z]
)?d reject the word unless its last character is a digit [0-9]
/?d reject the word unless it contains a character in digits class (or set variable p to first such character)
'p  truncate the word at position given by the previous /?d (ie. at the first digit)
z   constant: "infinite" position or length (beyond end of word)
Xpz0    extract substring pz from memory and insert into current word at 0

But it can't be this rule. Given this input word [that lacks digits], it would simply reject the word before reaching the X command.

<!-- gh-comment-id:161468921 --> @magnumripper commented on GitHub (Dec 2, 2015): I was considering applying your patch but after carefully inspecting the code I don't get this. The original code already has this: ``` c mleft = (int)(rules_vars['m'] + 1) - mpos; if (count > mleft) count = mleft; ``` The `rules_vars('m')` is the "initial or memorized word's last character position" so after the above, `count` should have shrinked from infinite `z` to actual word length. So why is your patch needed? It should be a no-op. I take your word on it that it isn't, but how come? The trigger rule was allegedly `(?a )?d /?d 'p Xpz0`. ``` (?a reject the word unless its first character is a letter [a-zA-Z] )?d reject the word unless its last character is a digit [0-9] /?d reject the word unless it contains a character in digits class (or set variable p to first such character) 'p truncate the word at position given by the previous /?d (ie. at the first digit) z constant: "infinite" position or length (beyond end of word) Xpz0 extract substring pz from memory and insert into current word at 0 ``` But it can't be this rule. Given this input word [that lacks digits], it would simply reject the word before reaching the X command.
Author
Owner

@magnumripper commented on GitHub (Dec 2, 2015):

I tried running asan_symbolize.py and it did not get file/lines. Likely I do not have the asan stuff right. BUT none the less, the same type issue is present in master as we are seeing in jumbo.

Did you add a -g to get debug info?

<!-- gh-comment-id:161469421 --> @magnumripper commented on GitHub (Dec 2, 2015): > I tried running asan_symbolize.py and it did not get file/lines. Likely I do not have the asan stuff right. BUT none the less, the same type issue is present in master as we are seeing in jumbo. Did you add a `-g` to get debug info?
Author
Owner

@magnumripper commented on GitHub (Dec 3, 2015):

In fact, none of those "jumbosingle" rules would touch this input word. All of them requires digits. Some other rule must have triggered ASan.

<!-- gh-comment-id:161473009 --> @magnumripper commented on GitHub (Dec 3, 2015): In fact, **none** of those "jumbosingle" rules would touch this input word. All of them requires digits. Some other rule must have triggered ASan.
Author
Owner

@frank-dittrich commented on GitHub (Dec 3, 2015):

Has this ASan error for master been reported to john-users or john-dev?

<!-- gh-comment-id:161522265 --> @frank-dittrich commented on GitHub (Dec 3, 2015): Has this ASan error for master been reported to john-users or john-dev?
Author
Owner

@magnumripper commented on GitHub (Dec 3, 2015):

I think not. We should first confirm it's still there (Solar has made changes to rules.c since OP).

<!-- gh-comment-id:161544877 --> @magnumripper commented on GitHub (Dec 3, 2015): I think not. We should first confirm it's still there (Solar has made changes to rules.c since OP).
Author
Owner

@magnumripper commented on GitHub (Dec 3, 2015):

OK I figured this out. It is that rule, but it doesn't bork over that input word but even before being fed any words (in some enumeration phase).

So input word is an empty string. l (length) gets initialized to 0, and unfortunately m (last char pos) gets initialized to length - 1 but since m is unsigned char, it ends up as 255.

Here's a "proper" patch (although with line numbers from master branch) unless there is some intended behavior that breaks from it:

diff --git a/src/rules.c b/src/rules.c
index 35cfe15..7eae64e 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -825,7 +825,7 @@ char *rules_apply(char *word, char *rule, int split, char *last)
                                POSITION(mpos)
                                POSITION(count)
                                POSITION(ipos)
-                               mleft = (int)(rules_vars['m'] + 1) - mpos;
+                               mleft = (int)(rules_vars['l']) - mpos;
                                if (count > mleft)
                                        count = mleft;
                                if (count <= 0)

I posted to john-dev, consulting Solar about this.

<!-- gh-comment-id:161734059 --> @magnumripper commented on GitHub (Dec 3, 2015): OK I figured this out. It _is_ that rule, but it doesn't bork over that input word but even before being fed any words (in some enumeration phase). So input word is an empty string. `l` (length) gets initialized to 0, and unfortunately `m` (last char pos) gets initialized to `length - 1` but since `m` is unsigned char, it ends up as 255. Here's a "proper" patch (although with line numbers from master branch) unless there is some intended behavior that breaks from it: ``` diff diff --git a/src/rules.c b/src/rules.c index 35cfe15..7eae64e 100644 --- a/src/rules.c +++ b/src/rules.c @@ -825,7 +825,7 @@ char *rules_apply(char *word, char *rule, int split, char *last) POSITION(mpos) POSITION(count) POSITION(ipos) - mleft = (int)(rules_vars['m'] + 1) - mpos; + mleft = (int)(rules_vars['l']) - mpos; if (count > mleft) count = mleft; if (count <= 0) ``` I posted to [john-dev, consulting Solar about this](http://www.openwall.com/lists/john-dev/2015/12/03/1).
Author
Owner

@magnumripper commented on GitHub (Dec 3, 2015):

My patch was incorrect for the case when memorized word != current word. Obvious in hindsight but this is tricky stuff. Final fix in 9aed2223

<!-- gh-comment-id:161779438 --> @magnumripper commented on GitHub (Dec 3, 2015): My patch was incorrect for the case when memorized word != current word. Obvious in hindsight but this is tricky stuff. Final fix in 9aed2223
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#1153
No description provided.