-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
randomize hash values per process #37166
Comments
+1 for this. To be honest this is also tremendously useful for catching bugs where people depend on unreliable ordering of the stuff in Dict/Set/unique/... . Technically I'd even consider randomizing the order to be a good practice (there's no performance hit and problems get exposed sooner than later). (Related thread in the slack: https://julialang.slack.com/archives/C6A044SQH/p1674933909186449 -- as a user you could currently try to replace |
(btw, I can probably write a patch; any hint on the randomness source would be very welcome though. PID+localtime could work?) |
It depends on how fancy you want to get here. If |
There is also |
We should likely do this since:
https://docs.python.org/3/using/cmdline.html Python randomizes and e.g. this turns it off: PYTHONHASHSEED=1 python3 Python has -R to control this (to enable, but now on by default, so I'm not sure this is ever used, except to disable the env var). It seems like we might want a way to disable for debugging reasons. I noticed Python randomizes hashes for strings too. So likely all hashes are just randomized. I'm not strictly sure that's needed, but is simplest implementation. Would non-randomzised hashes for e.g. strings and integers be any risk on its own, or only when used in a Dict? |
Other languages randomize their hash values per process to protect against DOS attacks on hash tables by intentionally causing hash table collisions. This also forces users not to rely on accidental dictionary ordering in their code. Even in languages where dictionaries are ordered, it's a good DOS prevention measure to randomize the hashing per process: the change becomes invisible (because of ordering), but since attackers can't predict hash collisions, they can't force them. Regardless of whether we go with ordered dicts or not, we may want to do this.
The text was updated successfully, but these errors were encountered: