rand
Affected
- introduced
0.9.0, fixed0.9.3(semver)
Fixed versions
0.9.3
Fix
- Fixed version
0.9.3cargo update -p rand --precise 0.9.3
Advisory
Also known as: RUSTSEC-2026-0097
Rand is unsound with a custom logger using rand::rng()
It has been reported (by @lopopolo) that the rand library is unsound (i.e. that safe code using the public API can cause Undefined Behaviour) when all the following conditions are met:
log and thread_rng features are enabledrand::rng() (previously rand::thread_rng()) and calls any TryRng (previously RngCore) methods on ThreadRngThreadRng (attempts to) reseed while called from the custom logger (this happens every 64 kB of generated data)getrandom crate) is unable to provide a new seedTryRng (previously RngCore) methods for ThreadRng use unsafe code to cast *mut BlockRng<ReseedingCore> to &mut BlockRng<ReseedingCore>. When all the above conditions are met this results in an aliased mutable reference, violating the Stacked Borrows rules. Miri is able to detect this violation in sample code. Since construction of aliased mutable references is Undefined Behaviour, the behaviour of optimized builds is hard to predict.
Low Basis: The source's own band: LOW
0.9.0, fixed 0.9.3 (semver)0.9.3
0.9.3cargo update -p rand --precise 0.9.30.10.0, fixed 0.10.1 (semver)0.10.1
0.10.1cargo update -p rand --precise 0.10.10.7.0, fixed 0.8.6 (semver)0.8.6
0.8.6cargo update -p rand --precise 0.8.6Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0