RUSTSEC-2020-0009

Source
https://rustsec.org/advisories/RUSTSEC-2020-0009
Import Source
https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2020-0009.json
JSON Data
https://api.osv.dev/v1/vulns/RUSTSEC-2020-0009
Aliases
Published
2020-04-11T12:00:00Z
Modified
2023-11-08T04:03:36.276800Z
Severity
  • 7.5 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H CVSS Calculator
Summary
`read_scalar` and `read_scalar_at` allow transmuting values without `unsafe` blocks
Details

The read_scalar and read_scalar_at functions are unsound because they allow transmuting values without unsafe blocks.

The following example shows how to create a dangling reference:

fn main() {
    #[derive(Copy, Clone, PartialEq, Debug)]
    struct S(&'static str);
    impl flatbuffers::EndianScalar for S {
        fn to_little_endian(self) -> Self { self }
        fn from_little_endian(self) -> Self { self }
    }
    println!("{:?}", flatbuffers::read_scalar::<S>(&[1; std::mem::size_of::<S>()]));
}
Database specific
{
    "license": "CC0-1.0"
}
References

Affected packages

crates.io / flatbuffers

Package

Affected ranges

Type
SEMVER
Events
Introduced
0.4.0
Fixed
2.0.0

Ecosystem specific

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

Database specific

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