GHSA-2226-4v3c-cff8: Rustc serialize Stack Overflow Vulnerability

MODERATE
Published
Advisory Summary

GHSA-2226-4v3c-cff8 is a MODERATE stack overflow vulnerability (General Security Weakness) affecting Rustc serialize libraries in the crates.io ecosystem. The issue involves stack overflow in rustc_serialize when parsing deeply nested json. Remediation is available in the latest vendor maintenance releases.

GHSA-2226-4v3c-cff8 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-2226-4v3c-cff8
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Rustc serialize
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-2226-4v3c-cff8

To remediate this vulnerability, upgrade all affected Rustc serialize dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

rustc-serialize fixed: Latest secure release
Upgrade rustc-serialize to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for rustc-serialize

How to Check if You Are Affected

To determine whether your application is affected by GHSA-2226-4v3c-cff8, inspect your project dependencies for Rustc serialize:

inspect dependencies for rustc-serialize

Analyze the terminal output to locate any version of Rustc serialize in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In Rustc serialize, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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.

GHSA-2226-4v3c-cff8 Affected Rustc serialize Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
rustc-serialize
crates.io
≤ 0.3.24

References

Frequently Asked Questions

What is GHSA-2226-4v3c-cff8?
GHSA-2226-4v3c-cff8 is a security vulnerability in Rustc serialize involving Stack overflow in rustc_serialize when parsing deeply nested JSON under General Security Weakness.
Which Rustc serialize versions are affected?
Affected versions include releases prior to current release patches across affected packages: rustc-serialize.
What version fixes GHSA-2226-4v3c-cff8?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is rustc-serialize affected?
Yes, rustc-serialize is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What CWE is associated with GHSA-2226-4v3c-cff8?
GHSA-2226-4v3c-cff8 is classified under General Security Weakness.
How can I check crates.io dependencies for GHSA-2226-4v3c-cff8?
Run the dependency tree command: 'inspect dependencies for rustc-serialize'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-2226-4v3c-cff8",
  "modified" : "2022-06-17T00:18:24Z",
  "published" : "2022-06-17T00:18:24Z",
  "aliases" : [ ],
  "summary" : "Stack overflow in rustc_serialize when parsing deeply nested JSON",
  "details" : "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.\n\nExample code that triggers the vulnerability is\n\n```rust\nfn main() {\n    let _ = rustc_serialize::json::Json::from_str(&\"[0,[\".repeat(10000));\n}\n```\n\n[serde](https://crates.io/crates/serde) is recommended as a replacement to rustc_serialize.\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rustc-serialize"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.3.24"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang-deprecated/rustc-serialize"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rust-lang/rustc-serialize"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2022-0004.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-17T00:18:24Z",
    "nvd_published_at" : null
  }
}