Home / Docs / Diagnostics
U6009: The host gave no random bytes for keyed hashing
The host gives no random bytes for the secret key of hash tables. una run, una test and native executables read the key before main and before any effect, and abort with U6009, exit code 1, when the host gives no random bytes.
Why Una rejects it
A program that can make a hash table, a HashMap or a HashSet of std.collections (edition 0.5, a preview), needs a secret key for the hash of its keys: 128 bits from the operating system's cryptographic random source, read once when the run starts (spec/28 §1, ADR 0119 rule 9).
No fixed or guessable key ever replaces the random one. A key that an attacker could know would let them choose keys that all land in one place, which turns each operation of a table from constant expected time into time linear in its size: a denial of service.
Only a run whose code can reach a hash table reads the key. A package of edition 0.1 to 0.4, or one that makes no hash table, never reads it and never reports U6009.
How to fix it
The cause is the host, not the program, so there is no failing example to show here: no program text causes it, and no change to the program removes it.
- On Linux, the kernel's random pool must be seeded, and a sandbox must allow the
getrandomsystem call or reading/dev/randomand/dev/urandom. - On macOS,
getentropy.