Rust advisories / rustc-serialize
Vulnerability MediumRUSTSEC-2022-0004 · rustc-serialize
RUSTSEC-2022-0004: Stack overflow in rustc_serialize when parsing deeply nested JSON
Short answerA security vulnerability in the rustc-serialize crate: Stack overflow in rustc_serialize when parsing deeply nested JSON. GitHub rates it Medium. No fixed version: replace the crate or remove the affected code path.
| Crate | rustc-serialize |
|---|---|
| Type | Vulnerability (denial-of-service) |
| Affected versions | Every version. |
| Fixed in | none |
| Severity | Medium (GitHub rating) |
| Published | 2022-01-01 |
| Last changed | 2023-11-08 |
| Also known as | GHSA-2226-4v3c-cff8 |
| Affected functions | rustc_serialize::json::Json::from_str |
What to do
- Find who pulls it in:
cargo tree -i rustc-serialize. - Avoid the affected API (
rustc_serialize::json::Json::from_str), or replace the crate.
Details from the advisory
When parsing JSON using json::Json::from_str, there is no limit to the depth of the stack, therefore deeply nested objects can cause a stack overflow, which aborts the process.
Example code that triggers the vulnerability is
fn main() {
let _ = rustc_serialize::json::Json::from_str(&"[0,[".repeat(10000));
}
serde is recommended as a replacement to rustc_serialize.
References
From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.
Other advisories for rustc-serialize
Up next
Same craterustc-serialize: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →Did this answer your question?