# GHSA-2226-4v3c-cff8: Stack overflow in rustc_serialize when parsing deeply nested JSON

- Severity: Medium (rating, scored by GitHub)
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2022-01-01T12:00:00.000Z
- Modified: 2023-11-08T04:13:48.926Z
- Also known as: RUSTSEC-2022-0004

## Description

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

```rust
fn main() {
    let _ = rustc_serialize::json::Json::from_str(&"[0,[".repeat(10000));
}
```

[serde](https://crates.io/crates/serde) is recommended as a replacement to rustc_serialize.

(As written by GitHub Advisory Database.)

## Affected

- rustc-serialize (crates.io): up to 0.3.24; from 0.0.0-0

## References

- <https://github.com/rust-lang-deprecated/rustc-serialize> (web)
- <https://github.com/rust-lang/rustc-serialize> (package)
- <https://rustsec.org/advisories/RUSTSEC-2022-0004.html> (advisory, web)
- <https://crates.io/crates/rustc-serialize> (package)

## Sources

- GitHub Advisory Database: [GHSA-2226-4v3c-cff8](https://github.com/advisories/GHSA-2226-4v3c-cff8), CC-BY-4.0, modified 2023-11-08
- RustSec Advisory Database: [RUSTSEC-2022-0004](https://rustsec.org/advisories/RUSTSEC-2022-0004.html), CC0-1.0, modified 2023-11-08

---

Page: https://cve.day/GHSA-2226-4v3c-cff8 · Whole record: https://cve.day/GHSA-2226-4v3c-cff8.json · Rebuilt by cve.day 2026-11-25T22:56:43.089Z
