-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: hash function should be randomized to prevent DOS attacks #2630
Labels
Milestone
Comments
Randomizing the hash function could be as simple as replacing the hash initialization values (runtime/alg.c:20,22) with ones generated when the runtime starts. Is there anything special about the magic numbers 2860486313 and 33054211828000289? They have 19 and 27 set bits, respectively. I suspect any number with around half the bits set and evenly distributed would have very similar performance. |
Labels changed: added priority-go1, removed priority-triage. Owner changed to @rsc. Status changed to Accepted. |
Owner changed to builder@golang.org. |
This may be of interest if the hash function is being altered anyway: http://code.google.com/p/cityhash/source/browse/trunk/README |
Cityhash is overkill for a runtime hash function, and probably isn't sufficiently random for the lengths of data we're likely to be using as map keys. Jenkins one-at-a-time has much simpler code and would be good enough here. It's also what Perl uses for their hashes. As a side note, there's already an implementation of Jenkins at http://github.com/dgryski/dgohash . |
ENOCOFFEE: Forgot the runtime is in C. Anyways, the original Jenkins' C code is in the public domain anyway: http://burtleburtle.net/bob/hash/doobs.html |
This issue was closed by revision 8e765da. Status changed to Fixed. |
It helps, but the IV only adds so much randomness. A more long-term solution would be to e.g. use https://131002.net/siphash/ down the road. |
I don't understand the benefit that would bring, but I do know this: if this is an important issue that should be addressed, please open a new issue about it, rather than adding a comment to an issue that is marked fixed. Please don't simply reopen this issue, as I believe the issue described in the original comment is indeed fixed. Please open a new issue describing the problem and the proposal. Thanks. |
SipHash has similar speed to non-cryptographic hash functions, but it's about as hard to find collisions as it is with cryptographically strong hash functions, rendering pre-compute efforts futile even if the attacker guesses the IV/salt (or precomputes for the set of all possible salts.) I don't think it's terribly important, or that Go should adopt it yet--it's pretty new--but point taken. I will, thanks. (FWIW, the Perl community was the first by far to adopt IV randomization, and they've switched.) |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: