CVE-2021-29935: Rocket Use After Free Vulnerability
HIGHCVE-2021-29935 is a HIGH (CVSS 7.3) use after free vulnerability (CWE-416: Use After Free) affecting Rocket libraries in the crates.io ecosystem. The issue involves use after free in rocket. Remediation is available by upgrading affected packages to version 0.4.7.
CVE-2021-29935 at a Glance
Security Impact
CVSS: 7.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L).
How to Fix CVE-2021-29935
To remediate this vulnerability, upgrade all affected Rocket dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade rocket to 0.4.7
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for rocket
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-29935, inspect your project dependencies for Rocket:
inspect dependencies for rocket
Analyze the terminal output to locate any version of Rocket in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.4.7), 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 CWE-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. In Rocket, 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
CVE-2021-29935 Affected Rocket Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
rocket
|
crates.io |
< 0.4.7
|
0.4.7
|
References
Frequently Asked Questions
What is CVE-2021-29935?
Which Rocket versions are affected?
What version fixes CVE-2021-29935?
Is rocket affected?
What is the CVSS score of CVE-2021-29935?
What CWE is associated with CVE-2021-29935?
How can I check crates.io dependencies for CVE-2021-29935?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-vcw4-8ph6-7vw8",
"modified" : "2023-06-13T20:47:54Z",
"published" : "2021-08-25T20:54:20Z",
"aliases" : [ "CVE-2021-29935" ],
"summary" : "Use after free in Rocket",
"details" : "Affected versions of this crate transmuted a &str to a &'static str before pushing it into a StackVec, this value was then popped later in the same function.\n\nThis was assumed to be safe because the reference would be valid while the method's stack was active. In between the push and the pop, however, a function f was called that could invoke a user provided function.\n\nIf the user provided panicked, then the assumption used by the function was no longer true and the transmute to &'static would create an illegal static reference to the string. This could result in a freed string being used during (such as in a Drop implementation) or after (e.g through catch_unwind) the panic unwinding.\n\nThis flaw was corrected in commit `e325e2f` by using a guard object to ensure that the &'static str was dropped inside the function.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "rocket"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.4.7"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-29935"
}, {
"type" : "WEB",
"url" : "https://github.com/SergioBenitez/Rocket/issues/1534"
}, {
"type" : "WEB",
"url" : "https://github.com/SergioBenitez/Rocket/commit/b53a906a8e170fe9b151381c66a76a872c419f9e"
}, {
"type" : "WEB",
"url" : "https://github.com/SergioBenitez/Rocket/commit/e325e2fce4d9f9f392761e9fb58b418a48cef8bb"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/SergioBenitez/Rocket"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2021-0044.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-416" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-08-19T17:09:45Z",
"nvd_published_at" : null
}
}