GitHub advisory · crates.io
cookie: Private cookie nonces can repeat in processes that fork
Description
Only applications that call fork() and then add private (encrypted) cookies on the thread that forked, in more than one of the resulting processes. This is an uncommon way to deploy a Rust web application. In particular:
SignedJar) are not affected.The exact conditions are listed under "Conditions" below.
Private cookies are sealed with AES-256-GCM using a random 96-bit nonce. Affected versions drew the nonce from rand's thread-local generator, rand::thread_rng(). That generator hands out bytes from an internal buffer and only notices that the process has forked when the buffer is refilled. A process that forks therefore continues, in both the parent and the child, from the same buffered bytes, and the private cookies sealed first on each side of the fork use the same nonces.
Reusing a nonce under the same key breaks AES-GCM. From two private cookies that share a nonce, an attacker can:
The nonce is the first 12 bytes of a private cookie's (base64-decoded) value, so a repeated nonce is visible to anyone who holds two such cookies.
Exploitation requires the uncommon deployment described above, and only the first private cookies added after a fork are affected: at most 21 per process. An attacker must obtain two of them, from two different processes.
All of the following must hold:
Manual fix · crates.io
cargo update -p cookie --precise 0.18.3Sources