Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- Required
- Attack complexity
- Low
- Impact type
- Cross-site scripting
- Confidentiality · integrity · availability
- Low · Low · None
- Fix status
- Fixed
Attack profile from CVSS 3.1 · CNA. Fix status from CNA and GitHub. Impact type from CWE-79.
Summary
Cargo downloads a Rust project’s dependencies and compiles the project. Starting in Rust 1.60.0 and prior to 1.72, Cargo did not escape Cargo feature names when including them in the report generated by `cargo build --timings`. A malicious package included as a dependency may inject nearly arbitrary HTML here, potentially leading to cross-site scripting if the report is subsequently uploaded somewhere. The vulnerability affects users relying on dependencies from git, local paths, or alternative registries. Users who solely depend on crates.io are unaffected. Rust 1.60.0 introduced `cargo build --timings`, which produces a report of how long the different steps of the build process took. It includes lists of Cargo features for each crate. Prior to Rust 1.72, Cargo feature names were allowed to contain almost any characters (with some exceptions as used by the feature syntax), but it would produce a future incompatibility warning about them since Rust 1.49. crates.io is far more stringent about what it considers a valid feature name and has not allowed such feature names. As the feature names were included unescaped in the timings report, they could be used to inject Javascript into the page, for example with a feature name like `features = ["<img src='' onerror=alert(0)"]`. If this report were subsequently uploaded to a domain that uses credentials, the injected Javascript could access resources from the website visitor. This issue was fixed in Rust 1.72 by turning the future incompatibility warning into an error. Users should still exercise care in which package they download, by only including trusted dependencies in their projects. Please note that even with these vulnerabilities fixed, by design Cargo allows arbitrary code execution at build time thanks to build scripts and procedural macros: a malicious dependency will be able to cause damage regardless of these vulnerabilities. crates.io has server-side checks preventing this attack, and there are no packages on crates.io exploiting these vulnerabilities. crates.io users still need to excercise care in choosing their dependencies though, as remote code execution is allowed by design there as well.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| rust-lang | cargo | 1.60.0 to before 1.72 | 1.72 | Patch available | CNA |
| — | cargo (crates.io) | 1.60.0 to before 1.72 | 1.72 | Patch available | GHSA-wrrj-h57r-vx9p |
- cargo Vendorrust-lang Affected 1.60.0 to before 1.72 Fixed in 1.72 Patch available CNA
- cargo (crates.io) Vendor— Affected 1.60.0 to before 1.72 Fixed in 1.72 Patch available GHSA-wrrj-h57r-vx9p
Remediation
- Fix · CNA cargo (rust-lang) Fixed in 1.72
- Fix · GHSA-wrrj-h57r-vx9p cargo (crates.io) Fixed in 1.72 Advisory →
Vendor assessments
Timeline
- 2026-10-02 Threatist record created from CVE-2023-40030
- 2026-10-03 Alias added: GHSA-wrrj-h57r-vx9p
References
Patch 3
More rust-lang Rust vulnerabilities
- TI-2024-16197 Rusts's `std::process::Command` did not properly escape arguments of batch files on Windows CVSS 3.1CRITICAL 10.0
- TI-2024-03325 Command injection vulnerability in programing languages on Microsoft Windows operating system. CVSS 3.1CRITICAL 9.8
- TI-2022-06036 Race condition in std::fs::remove_dir_all in rustlang CVSS 3.1HIGH 7.3
- TI-2018-16034 The Rust Programming Language Standard Library version 1.29.0, 1.28.0, 1.27.2, 1.27.1… CVSS 3.0CRITICAL 9.8
- TI-2021-11383 In the standard library in Rust before 1.52.0, a double free can occur in the… CVSS 3.1CRITICAL 9.8
- TI-2021-09849 In the standard library in Rust before 1.52.0, the Zip implementation can report an… CVSS 3.1CRITICAL 9.8
Sources
- CVE-2023-40030 · CVE Program
- CVE-2023-40030 · NVD
- FIRST EPSS
- GHSA-wrrj-h57r-vx9p · GitHub Advisory Database · CC BY 4.0
- CVE-2023-40030 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences