mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #1744] Single-mode ASan segfault (in rules.c) #1153
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#1153
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 @magnumripper on GitHub (Sep 11, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1744
Note: It's only a read, not necessarily a real problem.
@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.
@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?
@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
Note, I also found this in code, and think this is very buggy
@magnumripper commented on GitHub (Sep 11, 2015):
We should definitely try to reproduce this in John Proper
@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?)
@jfoug commented on GitHub (Sep 11, 2015):
Ok, here is an easier to test example
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
@magnumripper commented on GitHub (Sep 11, 2015):
Except john proper doesn't have -pipe :duh:
@jfoug commented on GitHub (Sep 11, 2015):
Master crashes with ASAN just the same
@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).
@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
@jfoug commented on GitHub (Sep 11, 2015):
We might need to fuzz the rules.
@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:
The
rules_vars('m')is the "initial or memorized word's last character position" so after the above,countshould have shrinked from infinitezto 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.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.
@magnumripper commented on GitHub (Dec 2, 2015):
Did you add a
-gto get debug info?@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.
@frank-dittrich commented on GitHub (Dec 3, 2015):
Has this ASan error for master been reported to john-users or john-dev?
@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).
@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 unfortunatelym(last char pos) gets initialized tolength - 1but sincemis 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:
I posted to john-dev, consulting Solar about this.
@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