32
Arc vs String, is Arc really faster?
(blocklisted.github.io)
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Credits
Probably not for ddos/security reasons. Would need to use something like nohasher to get noops.
Hmm, I was wondering, if there's an overlap with using hashes for security stuff. Do you happen to know of an exploit that makes use of something like predictable placement in a hashmap?
Or is your assumption rather that they wouldn't include special treatment for primitive types in the hashmap implementation?
It definitely feels a bit freaky to me, too, since you'd rob users of the ability to customize the
Hasher
implementation, but I also felt like they almost have to do it, because it might make a massive difference in performance....but after thinking about it some more, I guess, you'd typically use a BTreeMap when your keys are primitives. So, now I'm on board with the guess, that they wouldn't include special treatment into HashMap. ๐
It is talked about in the hashmap docs:
Basically, if the attacker has control over the key inserted into a hashmap then with a simple hashing algorithm they can force collisions which results in the hashmap falling back to a much slower linear lookup. This can be enough to stress a server and slow down all requests going through it or even cause it to crash. So a lot of effort is made in the default hasher to mitigate against this. There are faster hashing implementations out there if you are not worried about this that you can opt into. But the default is to be secure.
Thanks. :)