-
Notifications
You must be signed in to change notification settings - Fork 9
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
http.headers module needs a better hash function #4
Comments
Several other languages use siphash-2-4 (or siphash-1-3), with randomized key on startup, as an attempt to avoid denial-of-service attacks (which is important for http servers). refs: |
I'd be happy with that. Zig even already has a SipHash implementation, so it should just be a matter of using it in the http.headers module. |
@daurnimator Looking into it a bit, SipHash returns a Additionally, Since Finally,
Any thoughts? |
Just
Have
Have Also have a look at open PR ziglang/zig#2797 |
Ah. I guess that works.
Ok.
Not sure that will work, as the index_hashmap has to exist first or the type signature will be wrong due to the Indeed, I get this:
I'll look at it further though.
I'm not very familiar with Wyhash and how well it avoids the DoS issues that SipHash attempts to avoid. Looks like the author there ran into the same issue with the seed, and just hardcoded for now. |
Wyhash source says nothing about DoS so I would not assume it is secure in this regard. My reasonning in this PR was that the usecase hashmaps have to be optimized for, ie. the most common, is small keys. And that applications needing specific hash functions will anyway use their own. In this case, we don't really care about the seed being hardcoded, as it's a best effort without strong guaranties. However it can be debated wether we would instead want the default hash be a best effort for security. |
With respect to hash tables, hash functions, and security, I am aware of Reini Urban's (@rurban) comments at the |
The http.headers type
HeaderIndex
currently usesAutoHashMap
, it should use a better hash function, possibly parametized.Originally posted by @daurnimator in #2263
The text was updated successfully, but these errors were encountered: