RUSTSEC-2021-0044

Source
https://rustsec.org/advisories/RUSTSEC-2021-0044
Import Source
https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2021-0044.json
JSON Data
https://api.osv.dev/v1/vulns/RUSTSEC-2021-0044
Aliases
Published
2021-02-09T12:00:00Z
Modified
2023-11-08T04:05:43.819286Z
Severity
  • 7.3 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L CVSS Calculator
Summary
Use after free possible in `uri::Formatter` on panic
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.

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.

Database specific
{
    "license": "CC0-1.0"
}
References

Affected packages

crates.io / rocket

Package

Affected ranges

Type
SEMVER
Events
Introduced
0.0.0-0
Fixed
0.4.7

Ecosystem specific

{
    "affected_functions": null,
    "affects": {
        "os": [],
        "functions": [],
        "arch": []
    }
}

Database specific

{
    "cvss": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L",
    "informational": "unsound",
    "categories": [
        "memory-corruption"
    ]
}