CVE-2023-40030
published 2023-08-24CVE-2023-40030: 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…
PriorityP429medium6.1CVSS 3.1
AVNACLPRNUIRSCCLILAN
EPSS
0.85%
53.9th percentile
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
Affected
8 ranges
| Vendor | Product | Version range | Fixed in |
|---|---|---|---|
| debian | cargo | < rust-cargo 0.76.0-1 (forky) | rust-cargo 0.76.0-1 (forky) |
| debian | rust-cargo | < rust-cargo 0.76.0-1 (forky) | rust-cargo 0.76.0-1 (forky) |
| msrc | azl3_rust_1.75.0-14_on_azure_linux_3.0 | — | — |
| msrc | azl3_rust_1.86.0-1_on_azure_linux_3.0 | — | — |
| msrc | cbl2_rust_1.72.0-2_on_cbl_mariner_2.0 | — | — |
| rust-lang | cargo | — | — |
| rust-lang | cargo | >= 1.60.0 < 1.72 | 1.72 |
| rust-lang | rust | >= 1.60.0 < 1.72.0 | 1.72.0 |
CVSS provenance
nvdv3.16.1MEDIUMCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
osv6.1MEDIUM
vendor_debian6.1MEDIUM
vendor_msrc6.1MEDIUM
Stop checking back — get the weekly exploitation signal.
Every Monday: what got weaponized or added to CISA KEV in the last seven days — each CVE cross-linked to its PoC, Nuclei template, and detection rule. Free, one email a week, unsubscribe in one click.
OSV
CVE-2023-40030: Cargo downloads a Rust project’s dependencies and compiles the project
osv·2023-08-24·CVSS 6.1
CVE-2023-40030 [MEDIUM] CVE-2023-40030: Cargo downloads a Rust project’s dependencies and compiles the project
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
GHSA
Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
ghsa·2023-08-24
CVE-2023-40030 [LOW] CWE-79 Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
The Rust Security Response WG was notified that 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 XSS if the report is subsequently uploaded somewhere.
The severity of this vulnerability is "low" for users relying on dependencies from git, local paths, or alternative registries. Users who solely depend on crates.io are unaffected.
Note that **by design** Cargo allows code execution at build time, due to build scripts and procedural macros. The vulnerability in this advisory allows performing a subset of the possible damage in a h
OSV
Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
osv·2023-08-24
CVE-2023-40030 [LOW] Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
The Rust Security Response WG was notified that 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 XSS if the report is subsequently uploaded somewhere.
The severity of this vulnerability is "low" for users relying on dependencies from git, local paths, or alternative registries. Users who solely depend on crates.io are unaffected.
Note that **by design** Cargo allows code execution at build time, due to build scripts and procedural macros. The vulnerability in this advisory allows performing a subset of the possible damage in a h
Microsoft
Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
vendor_msrc·2023-08-08·CVSS 6.1
CVE-2023-40030 [MEDIUM] CWE-79 Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports
FAQ: Is Azure Linux the only Microsoft product that includes this open-source library and is therefore potentially affected by this vulnerability?
One of the main benefits to our customers who choose to use the Azure Linux distro is the commitment to keep it up to date with the most recent and most secure versions of the open source libraries with which the distro is composed. Microsoft is committed to transparency in this work which is why we began publishing CSAF/VEX in October 2025. See this blog post for more information. If impact to additional products is identified, we will update the CVE to reflect this.
Mariner: Mariner
GitHub_M: GitHub_M
Customer Action Required: Yes
Remediation: CBL-M
Debian
CVE-2023-40030: cargo - Cargo downloads a Rust project’s dependencies and compiles the project. Starting...
vendor_debian·2023·CVSS 6.1
CVE-2023-40030 [MEDIUM] CVE-2023-40030: cargo - Cargo downloads a Rust project’s dependencies and compiles the project. Starting...
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
No detection rules found.
No public exploits indexed.
No writeups or analysis indexed.
https://github.com/rust-lang/cargo/commit/9835622853f08be9a4b58ebe29dcec8f43b64b33https://github.com/rust-lang/cargo/commit/f975722a0eac934c0722f111f107c4ea2f5c4365https://github.com/rust-lang/cargo/pull/12291https://github.com/rust-lang/cargo/security/advisories/GHSA-wrrj-h57r-vx9phttps://github.com/rust-lang/cargo/commit/9835622853f08be9a4b58ebe29dcec8f43b64b33https://github.com/rust-lang/cargo/commit/f975722a0eac934c0722f111f107c4ea2f5c4365https://github.com/rust-lang/cargo/pull/12291https://github.com/rust-lang/cargo/security/advisories/GHSA-wrrj-h57r-vx9p
2023-08-24
Published