4 ms·
As is mentioned in the article, using cryptographically secure hash functions doesn't help - unless you also provide some salt or otherwise randomize the functi
by mjb 15y ago
As is mentioned in the article, using cryptographically secure hash functions doesn't help - unless you also provide some salt or otherwise randomize the function in some way. On the other hand, if you are already randomizing the function in some way, using a cryptographically secure hash is unlikely to help - as long as the salt/seed is has a range substantially larger than the table size.
Using a balanced tree in place of a list in a separately chained hash table is possible - but adds much complexity and reduced average-case performance to solve a problem that seems better to solve in a different way. Dynamic perfect hashing works too, but opens you up to a new memory exhaustion attack.
A combination of limiting header size and adding a seed to the hash function, as mentioned in the article, seems like the right way. Limiting header sizes and counts is something that servers should be doing anyways, and seeding the hash function seems to close this hole quite neatly.
- willvarfar 15y agountil the attacker picks on your JSON parser or such, of course. Adding a balanced tree does not touch on average-case performance in any meaningful way, which is why I'm advocating it. Everyone is using simple hashes for hash tables in order to get very good average-case performance. If you keep that fast hash function, and only go to a tree when getting pathological input, you'll be impervious. That was my meaning.