All vulnerabilities

crates.io

CVE-2026-140014

cookie: Private cookie nonces can repeat in processes that fork

Severity
Medium 6.5
Published
1 Dec 2026
Last changed
1 Dec 2026
Added to UpHeron
1 Dec 2026
Fixed in
0.18.3
Exploit chance
0.4% in the next 30 daysHigher than 39% of CVEs. EPSS by FIRST, 1 Dec 2026
Weakness
CWE-323
Attack
Over the network · Only under certain conditions · No login needed · No user action needed
Attacker can
Read some data · Change data
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N
Also known as
GHSA-8wcq-xq25-7fhm, RUSTSEC-2026-0594
Sources
OSV.dev and GitHub

Description

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:

  • recover the XOR of the two plaintexts, and thus either plaintext if the other is known, and
  • recover the GHASH authentication key and forge private cookies, with a name and value of their choosing, that the application accepts as authentic.

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.

From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Workarounds

If upgrading is not possible, any one of the following prevents the reuse:

  • Do not use rand::thread_rng(), directly or indirectly, on the forking thread before forking. In particular, create the Key with Key::from() or Key::derive_from() rather than Key::generate() before the fork.
  • In each child, immediately after forking, read and discard at least 256 bytes from rand::thread_rng() before adding any private cookie.
  • Add private cookies only on threads created after the fork.

Applications that ran in an affected configuration should rotate their Key.

Workarounds as given by the GitHub Advisory Database, CC BY 4.0.

Affected software

SoftwareAffected versions
cookiecrates.io · osv:crates.io:cookie
  • From 0.11.3 before 0.18.3
  • From 0.14.0 before 0.18.3

About cookie

Downloads in the last 90 days (crates.io)
79,987,169crates.io, 1 Dec 2026
Total downloads (crates.io)
302,375,446crates.io, 1 Dec 2026

This is the only vulnerability in cookie in our list.

References