{"id":"CVE-2026-140014","aliases":["CVE-2026-140014","GHSA-8wcq-xq25-7fhm","RUSTSEC-2026-0594"],"related":[],"kind":"vulnerability","state":"published","title":"cookie: Private cookie nonces can repeat in processes that fork","summary":"cookie is an HTTP cookie parsing and cookie jar management library for Rust. From 0.11.3 until 0.12.0 and from 0.14.0 until 0.18.3, PrivateJar generates AES-256-GCM nonces with rand::thread_rng(), whose buffered state can be duplicated when a Unix-like process calls fork() without exec(). The forking thread must have used the thread-local generator before the fork, and two resulting processes must add private cookies on that same thread with a shared Key; applications that do not fork, create cookies only on post-fork threads, use SignedJar, or run on Windows are not affected. At most the first 21 private cookies added on that thread in each resulting process can reuse nonces before the generator reseeds and the processes diverge. An attacker must obtain two cookies from different resulting processes that share a nonce to recover plaintext relationships and forge private cookies accepted by the application. This issue is fixed in version 0.18.3.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"cookie is an HTTP cookie parsing and cookie jar management library for Rust. From 0.11.3 until 0.12.0 and from 0.14.0 until 0.18.3, PrivateJar generates AES-256-GCM nonces with rand::thread_rng(), whose buffered state can be duplicated when a Unix-like process calls fork() without exec(). The forking thread must have used the thread-local generator before the fork, and two resulting processes must add private cookies on that same thread with a shared Key; applications that do not fork, create cookies only on post-fork threads, use SignedJar, or run on Windows are not affected. At most the first 21 private cookies added on that thread in each resulting process can reuse nonces before the generator reseeds and the processes diverge. An attacker must obtain two cookies from different resulting processes that share a nonce to recover plaintext relationships and forge private cookies accepted by the application. This issue is fixed in version 0.18.3.","source":"cvelist"},{"lang":"en","text":"## Who is affected\n\nOnly 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:\n\n * **Rocket is not affected.**\n * **axum is not affected as normally run.** It is affected only when an application forks worker processes itself and runs each on a current-thread runtime. See \"Rocket and axum\" below.\n * Applications that never fork are not affected. This includes all applications on Windows.\n * Signed cookies (`SignedJar`) are not affected.\n\nThe exact conditions are listed under \"Conditions\" below.\n\n## Description\n\nPrivate 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.\n\n## Impact\n\nReusing a nonce under the same key breaks AES-GCM. From two private cookies that share a nonce, an attacker can:\n\n * recover the XOR of the two plaintexts, and thus either plaintext if the other is known, and\n * recover the GHASH authentication key and forge private cookies, with a name and value of their choosing, that the application accepts as authentic.\n\nThe 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.\n\nExploitation 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.\n\n## Conditions\n\nAll of the following must hold:\n\n 1. The target is a Unix-like system and the process calls `fork()` without a subsequent `exec()`.\n 2. The thread that calls `fork()` used `rand::thread_rng()` at any point before the fork. Any use counts, including `Key::generate()`, adding a private cookie, or a call made by an unrelated crate.\n 3. After the fork, private cookies are added on that same thread in two or more of the resulting processes: the parent and a child, or several children.\n 4. Those processes use the same `Key`.\n\nWhen they hold, at most the first 21 private cookies added on that thread in each process share nonces. After that the generator reseeds and the processes diverge.\n\nThe following are **not** affected:\n\n * Applications that never fork, including all applications on Windows.\n * Processes in which the forking thread did not use `rand::thread_rng()` before the fork.\n * Private cookies added on threads that were created after the fork. This includes servers that fork and then start a multi-threaded async runtime in each child.\n * Signed cookies (`SignedJar`), which do not use a nonce.\n * Versions `0.12.0` through `0.13.3`, and `0.11.2` and earlier, which obtained nonces from the operating system via `ring`.\n\n## Rocket and axum\n\nRocket and axum were tested with `cookie` `0.18.2` by collecting the private cookies sent by each server process and comparing their nonces.\n\n**Rocket** (`0.5.4`, `CookieJar::add_private()`) is not affected. Rocket does not fork, and it handles requests on worker threads of a runtime it creates when launched. No nonce was reused:\n\n * when launched normally, in a single process, or\n * when a parent process used a private cookie and then forked two worker processes that each launched Rocket.\n\n**axum** (`0.8.9`, with `PrivateCookieJar` from `axum-extra` `0.12.6`) is not affected as normally run. No nonce was reused:\n\n * when run in a single process on a multi-threaded runtime, or\n * when a parent process used a private cookie and then forked two worker processes that each started a multi-threaded runtime.\n\nAn axum application is affected only if it does all of the following:\n\n 1. forks worker processes itself,\n 2. runs each worker on a current-thread runtime on the thread that forked, so that requests are handled on that thread, and\n 3. used `rand::thread_rng()` on that thread before forking.\n\nIn that configuration, the first private cookies sent by two workers reused nonces: 19 when the parent had added one private cookie before forking, and 15 when the parent had only called `Key::generate()`. No nonce was reused when the parent did neither.\n\nOther frameworks and libraries that use this crate's `PrivateJar` were not tested. The conditions above apply to them as well.\n\n## Fix\n\nVersion `0.18.3` obtains nonces directly from the operating system's random number generator, which is not affected by `fork`.\n\n## Workarounds\n\nIf upgrading is not possible, any one of the following prevents the reuse:\n\n * 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.\n * In each child, immediately after forking, read and discard at least 256 bytes from `rand::thread_rng()` before adding any private cookie.\n * Add private cookies only on threads created after the fork.\n\nApplications that ran in an affected configuration should rotate their `Key`.","format":"markdown","source":"ghsa"}],"published":"2026-11-23T12:00:00.000Z","modified":"2026-12-01T19:15:03.091Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N","score":6.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N","score":6.5,"rating":"MEDIUM"}],"cwes":["CWE-323"],"affected":[{"ranges":[{"version":">= 0.14.0, < 0.18.3","status":"affected"},{"version":">= 0.11.3, < 0.12.0","status":"affected"}],"vendor":"rwf2","product":"cookie-rs","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0.14.0","status":"affected","fixed":"0.18.3"}],"ecosystem":"crates.io","package":"cookie","purl":"pkg:cargo/cookie","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.11.3","status":"affected","fixed":"0.18.3"}],"ecosystem":"crates.io","package":"cookie","purl":"pkg:cargo/cookie","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.11.3","status":"affected","fixed":"0.12.0"},{"type":"semver","introduced":"0.14.0","status":"affected","fixed":"0.18.3"}],"ecosystem":"crates.io","package":"cookie","purl":"pkg:cargo/cookie","source":"rustsec"}],"references":[{"url":"https://github.com/rwf2/cookie-rs/security/advisories/GHSA-8wcq-xq25-7fhm","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/rwf2/cookie-rs/commit/4a5e0f31fa18731cb8270090f1d173679bca913c","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/rwf2/cookie-rs/commit/98de6032defb10ad5e49d83fa1a9bbed1873cbe4","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://github.com/rwf2/cookie-rs/releases/tag/0.18.3","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140014","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/rwf2/cookie-rs","tags":["package"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2026-0594.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/cookie","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-12-01T13:30:27.401Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-140014","url":"https://www.cve.org/CVERecord?id=CVE-2026-140014","licence":"CVE Terms of Use","modified":"2026-12-01T13:54:35.268Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-8wcq-xq25-7fhm","url":"https://github.com/advisories/GHSA-8wcq-xq25-7fhm","licence":"CC-BY-4.0","modified":"2026-12-01T19:15:03.091Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2026-0594","url":"https://rustsec.org/advisories/RUSTSEC-2026-0594.html","licence":"CC0-1.0","modified":"2026-12-01T00:10:43.697Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-140014","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140014","licence":"Public domain","modified":"2026-12-01T14:18:19.443Z"}],"updatedAt":"2026-12-01T19:57:26.355Z","epss":{"score":0.00435,"percentile":0.39542,"date":"2026-12-01T12:00:22.000Z"}}