Why Python Randomizes Its Hash Salt at Startup
What attack the Language Summit 2026 write-up says the random hash salt defends against, how Python adopted it and when the salt is randomized.
For: Learners curious about language security.
The attack
The issue was one that was familiar to Python and many other languages: denial-of-service through hash algorithm collisions.[1]
The defense
Python fixed this issue in Python 3.3, as did many other programming languages, by adding a random “salt” to hash() calculations.[1]
When the salt is chosen
The salt is randomized at program startup to prevent remote attackers from controlling the hash values of inputs, and thus causing a CPU denial-of-service by creating extremely unbalanced data structures that rely on object hash values being evenly distributed, like dict and set.[1]
Sources
- Memory Snapshots for CPython (Python Language Summit 2026) (blog.python.org · checked )
More articles
- LearningHow a Username and Any API Key Became Admin AccessWhat the Python Security Response Team says was reported, what supplying an admin username with any key did and how quickly the fix was confirmed.
- LearningHow the Python Security Response Team Handles VulnerabilitiesWhat a Python.org post says the Python Security Response Team triages and coordinates and why it involves project experts in fixes.
- LearningWhy Rust for CPython, and What It Will Not FixThe reasons the Language Summit 2026 write-up gives for proposing Rust in CPython, what it says Rust does not remove and how the team proposes to reduce the risk.