Advisory Database
  • Advisories
  • Dependency Scanning
  1. cargo
  2. ›
  3. rocket
  4. ›
  5. CVE-2021-29935

CVE-2021-29935: Use after free in Rocket

August 25, 2021 (updated June 13, 2023)

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.

This 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.

If 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.

This flaw was corrected in commit e325e2f by using a guard object to ensure that the &‘static str was dropped inside the function.

References

  • github.com/SergioBenitez/Rocket
  • github.com/SergioBenitez/Rocket/commit/b53a906a8e170fe9b151381c66a76a872c419f9e
  • github.com/SergioBenitez/Rocket/commit/e325e2fce4d9f9f392761e9fb58b418a48cef8bb
  • github.com/SergioBenitez/Rocket/issues/1534
  • github.com/advisories/GHSA-vcw4-8ph6-7vw8
  • nvd.nist.gov/vuln/detail/CVE-2021-29935
  • rustsec.org/advisories/RUSTSEC-2021-0044.html

Code Behaviors & Features

Detect and mitigate CVE-2021-29935 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 0.4.7

Fixed versions

  • 0.4.7

Solution

Upgrade to version 0.4.7 or above.

Impact 7.3 HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L

Learn more about CVSS

Weakness

  • CWE-416: Use After Free

Source file

cargo/rocket/CVE-2021-29935.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:19 +0000.