-
Notifications
You must be signed in to change notification settings - Fork 49
Pathological worstcase when password is a hex string #15
Comments
Since the initial data came from my laptop, I've also tried it on my workstation. It could not complete the 32 characters before it ran out of memory:
I've updated the data comment in the gist, including top output from shortly before it ended. Memory consumption was around 14.5GByte for the 32 character string at that time. |
hmmm. Ill have to play with it and see if I can figure out where its spending the most time, and why its eating so much memory. |
So I found where its spending the time. Im not sure if this is where the memory issue is. https://gist.github.com/nbutton23/b11f57561c6471890bd95ac5a3b52a75 |
Okay after some more digging. I have found that the issue is not in the above code. using pprof I can see that it is in matching.leet.go:getAllPermutationsOfLeetSubstitutions. Since the the string has an abnormally hi number of leet characters (0, 1, 2, 3, 4, 5, 6, 7) it is generating an insane number of permutations. |
I ran into this when running against a MD5 hash. Is there a workaround or an option to skip the leet permutations? |
So @TheMacies just added the ability to filter out matchers. the call would look like |
Hello @nbutton23, I'm using your library to an interactive password check in a commandline application https://gist.github.com/nbutton23/b11f57561c6471890bd95ac5a3b52a75 I'm not sure if all permutations of the string need to be checked there. Alternatively one could also try to call this function less often (still Sorry for hijacking the issue, just wanted to ask if this is a valid way to go. |
I ran into the same issue with a similiar string. For testing purposes, I've used UUIDs as passwords, like so:
After a few minutes I've noticed I still had no response from the API only to find that it was consuming nearly 11 GByte of RAM. This issue needs to be addressed, as it allows for pretty trivial DoS attacks against any software using this library. |
As a temporary solution, try out the feature I added a while ago. |
@TheMacies I've seen that and it works, thank you. But this bug needs to be fixed, not worked around. The obvious quick fix would be to remove L33tMatcher (and others, if the problem exists in more than this one) from the list of matchers enabled by default, and release a bugfix version of this library. |
Yes. Although i did not want to change the behaviour of this lib after someone updates vendor. That was my primary goal |
@TheMacies , @cerlestes , @sahib , It was created a pull request ( #28 ) aiming to solve this issue. It would be great if you could check. |
@edwincarlo Very nice work, thank you. Code is looking good. I'll give the patch a try next week and report back. |
@edwincarlo: Great work, I see definite improvements. For a hash string like For reference, the pprof output I made while testing the change: |
Awesome! Instead of killing the process after 60 seconds and 14GB of RAM consumed, my tests are now running through in ~0.1s, when the patch was applied (taken from current master branch). @edwincarlo Thanks again! |
Is this still an issue? The last couple of comments suggest that it's been resolved. |
Hi,
I think I hit an algorithmic pathological worst case, if the supplied password string is a hex encoded string. I have not been able to reproduce this behavior with other, way longer passphrases.
I've created a gist with a testcase: Gist
At the point where I aborted (password length 32 characters), it is was consuming around 7GBytes of RAM.
The text was updated successfully, but these errors were encountered: