HistoryEditJSON (OSV)

RUSTSEC-2022-0004

Stack overflow in rustc_serialize when parsing deeply nested JSON

Reported
Issued
Package
rustc-serialize (crates.io)
Type
Vulnerability
Categories
Keywords
#stack-overflow
Aliases
Patched
no patched versions
Affected Functions
Version
rustc_serialize::json::Json::from_str
  • *

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

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

serde is recommended as a replacement to rustc_serialize.

Advisory available under CC0-1.0 license.