mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #953] Audit salted formats failing to remove dupe salts. #553
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#553
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 @jfoug on GitHub (Dec 25, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/953
see #951 / #952 There may be numerous other formats like this. IF the data is allocated due to it being some unknown length, then we may have to go the dyna_salt way. But for many, it likely will be that we change the char *item to be char item[ProperSize] and remove the mem_alloc_tiny in the salt() function.
THESE are the ones needing fixed. Check them when done:
@magnumripper I am not getting failures on pbkdf2-hmac-sha256, ssh or pbkdf2-hmac-sha256-opencl, not even intermittently. However, I did get kwallet problem which you did not list.
NOTE, SSH should probably find SOME way to also close the BIO and EVP stuff. We free memory, but I think these resources get leaked.
@magnumripper commented on GitHub (Dec 26, 2014):
Could we make the TS find these for us? It might be as easy as looking at the output for number of loaded salts.
@jfoug commented on GitHub (Dec 26, 2014):
That actually should be easy. Just take a single hash, replicate it 5 times. Then if a test run shows 1, we are fine. If it shows > 1, then we have problems.
Good addition to 'internal' 👍
@jfoug commented on GitHub (Dec 26, 2014):
I am not sure how to get this to auto fail. BUT it is easy to see which ones do fail.
The ones with guess of 6 are failing to remove dupe salts. (7z and agilekeychain in this example).
But notice that IKE and HDAA are not in this list. I am very surprised with that, but will dig deeper.
The algorithm is:
I 'think' that algorithm should show the problem formats. But I expected HDAA and IKE, since they had pointers. Possibly they have a salt_hash or some other format method that allows them to 'salt-dupe' remove properly.
@magnumripper commented on GitHub (Dec 26, 2014):
I do not think salt_hash() is involved. That would not make sense. An extreme comparison would be checking for dupe hashes with get_binary_hash_0() which would produce a false hit out of 16...
@jfoug commented on GitHub (Dec 26, 2014):
Looks like we might need to hash strings to auto test this (I think). In loader, it looks like there is code to auto dump same hash. I am not sure if I can alternate 2 salts x number of times, and have it work. I 'might' have to smash the binary to get the same salt to work, meaning I would have to have information on what part of the hash is the binary. That means this auto method 'may' not be able to be auto done. Too bad, this seemed like a simple way to find this information.
@magnumripper commented on GitHub (Dec 26, 2014):
Then it might be easier to do this in a JtR self-test. We can get_salt() twice with same data and see if they return the same thing. If they do not, and it's not a DYNA_SALT format, we have a fail.
@magnumripper commented on GitHub (Dec 26, 2014):
Result
@magnumripper commented on GitHub (Dec 26, 2014):
All CUDA formats pass without the warning
@magnumripper commented on GitHub (Dec 26, 2014):
The PBKDF2-HMAC-SHA256 formats does not have pointers in the salts. And they do clean their buffers. Not sure what the real problem is.
@magnumripper commented on GitHub (Dec 26, 2014):
Is this a bug in base64_convert()?
@magnumripper commented on GitHub (Dec 26, 2014):
I'm taking a break. This self-test is committed, but no fix to any format.
@jfoug commented on GitHub (Dec 26, 2014):
for dynasalt we should do dyna compare.
@jfoug commented on GitHub (Dec 26, 2014):
I will test it. I think I need to validate that any 'extra' junk bytes are force set to null, or possibly, I should pre-null the entire buffer. part of the problem lies with having to provide a max-length, AND having to provide a buffer that is longer. Exactly what should I count on, within convert, OR should I ask for 2 lengths. One is max length of string, one is true length of buffer? Or should the caller be tasked with buffer pre-cleaning ???
I will dig in and find the problem and a general working fix for it. I will also smoke these other salt dupe stuff.
@jfoug commented on GitHub (Dec 26, 2014):
I added all of them you found to the first post in this issue, as a checkbox list of what needs done.
@jfoug commented on GitHub (Dec 26, 2014):
I got the compare to work with all salts. Simply remove the check for dyna_salt, and replace memcmp with dyna_salt_cmp() The dyna_salt_cmp() takes same params as memcmp, but smart enough to handle a format with dyna_salt, by doing the dyna_salt compare, and if the format does not have dyna_salt, then it falls back to original memcmp call. I will get that checked in (same end results, none of the dyna_salt hashes had issues).
@magnumripper commented on GitHub (Dec 26, 2014):
I think this is a proper fix for the pbkdf2-hmac-sha256 problem.
This might need to be copied to other sections too - and the allocs should be callocs. OR we could use strncpy instead of strnzcpy. @jfoug what do you think?
@magnumripper commented on GitHub (Dec 26, 2014):
I found some unrelated off-by-one problems too. Committing some fixes.
@jfoug commented on GitHub (Dec 26, 2014):
Go for it. I will be on the road the next 4 to 6 hours, so I am down for now.
@magnumripper commented on GitHub (Dec 26, 2014):
OK so that fixed pbkdf2-hmac-sha256 and pbkdf2-hmac-sha256-opencl but no other fails disappeared.
@jfoug commented on GitHub (Dec 26, 2014):
I may audit this some, and try for a solution that does not cause such a heavy overhead as a full memset.
@jfoug commented on GitHub (Dec 26, 2014):
I am glad you found the problems in pbkdf2-hmac-sha256, since it does not trigger a problem on my builds (it may for linux, I was just using cygwin this morning, and it showed no failures). Good that you could find/fix it. This is just like kwallet. It was a problem on mine, but did not show up on yours. But I could find/fix it, so it is gone. I am sure there will be others that get triggered on other systems (just like that alignment stuff). I would think we would have fewer of these 'hidden' salt-dupe failures, but we could have some.
@magnumripper commented on GitHub (Dec 26, 2014):
That's fine but OTOH if we are calling that function in hot code we probably want to rewrite the caller.
@magnumripper commented on GitHub (Dec 26, 2014):
This was auto-closed by a commit message including "This does not fix #953", lol.
@jfoug commented on GitHub (Dec 26, 2014):
I do not believe there is any call in hot code, other than something like scrypt, which is so slow, that the hot code overhead is acceptable, and will get only a few extra cracks per day trying to speed it up. But a full buffer memset is rarely 'needed', but often used because someone does not want to take the time to figure out proper cleanup of buffer. Its like turning off the light by shooting it with a shotgun. It works, but ..... lol.
@magnumripper commented on GitHub (Dec 28, 2014):
That's fool-proof, me like. Few end-users problems - but you just had me put some more attention to the liability clauses in JtR license o.O
@magnumripper commented on GitHub (Jan 9, 2015):
The SSH format seems to need dynamic salt, not because size varies but because we need to skip comparing the darn BIO structures. I tried to do it (looking at rar and zip) but somehow it does not work at all.
@jfoug commented on GitHub (Jan 9, 2015):
The 'real' hard one was PKZIP. That was a mo-fo. It has 3 possible files, in a array. Each of those has a variable length allocated pointer. There were also other non-static data. The other non-static is easy. Simply move it to the start of the struct, then skip it. The other, what i had to do was make all the pointers NULL at build time. I then allocated enough to store ALL of the data into a trailing 1 byte array (allocated large enough to hold things). Then in set_salt, I 'late' set the pointers. set_salt is called AFTER all salt dupe stuff if done. So in the salt dupe, all pointers are null, and thus compare properly.
@jfoug commented on GitHub (Jan 9, 2015):
Only 1 left.
@jfoug commented on GitHub (Jan 20, 2015):
I think these are all done. when I test, I see no 'dupe salt' warnings any more.