CVE-2023-40030 json
Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
published 2023-08-24 3 y ago modified 2026-09-10 1 mo ago also GHSA-wrrj-h57r-vx9p , EUVD-2023-2375
- cvss
- 6.1
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 0.9%
- EPSS 0.9% chance of exploitation in 30 days, percentile 59%
- public exploits
- 0
- none known
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.
Patch / fix
- crates.io cargo 1.72
- rust-lang rust 1.72.0
- rust-cargo Debian 14, Debian 13 0.76.0-1
debian advisories DEBIAN-CVE-2023-40030
- rustc Ubuntu 24.04 LTS 1.73.0+dfsg0ubuntu1-0ubuntu1
ubuntu advisories UBUNTU-CVE-2023-40030
Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- rust1.72 SLE Module for Development Tools 15 SP5, SLE Module for Development Tools 15 SP4, openSUSE Leap 15.5 +1 more 1.72.0-150400.9.3.1
- rust SLE Module for Development Tools 15 SP5, SLE Module for Development Tools 15 SP4, openSUSE Leap 15.5 +1 more 1.72.0-150400.24.24.1
suse advisories SUSE-SU-2023:3722-1
- rust1.72 openSUSE Tumbleweed 1.72.1-1.1
opensuse advisories openSUSE-SU-2024:13262-1
- github.com/rust-lang/cargo@9835622 commit
- github.com/rust-lang/cargo@f975722 commit
- github.com/rust-lang/cargo#12291 pull request
Vendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2023-40030 updated cvss 6.1
rust-cargo: XSS via dependency HTML injection
-
Red Hat All currently supported Red Hat productsnot affected: vulnerable code not present
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
CISA SSVC
- Exploitation
- none
- Automatable
- no
- Technical impact
- partial
- Assessed
- 2 y ago
Exploit prediction
0.90% chance of exploitation in the next 30 days, higher than 59% of all scored CVEs (FIRST EPSS, 2026-11-08).
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 6.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| NVD | 3.1 | 6.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| crates.io | cargo | >=1.60.0, <1.72 |
1.72 |
Affected products
- rust-lang cargo
Classification
- Weakness
-
- CWE-79 Improper Neutralization of Input During Web Page Generation
References
-
github.com
/rust-lang/cargo/pull/12291
issue-tracking, patch
-
github.com
/rust-lang/cargo/commit/9835622853f08be9a4b58ebe29dcec8f43b64b33
web, patch
-
github.com
/rust-lang/cargo/commit/f975722a0eac934c0722f111f107c4ea2f5c4365
web, patch
-
github.com
/rust-lang/cargo/security/advisories/GHSA-wrrj-h57r-vx9p
web, vendor-advisory
-
github.com
/rust-lang/cargo
package
Sources
- CVE List CVE-2023-40030
- GitHub Advisory GHSA-wrrj-h57r-vx9p
- NVD CVE-2023-40030
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.