{"id":"RUSTSEC-2020-0009","summary":"`read_scalar` and `read_scalar_at` allow transmuting values without `unsafe` blocks","details":"The `read_scalar` and `read_scalar_at` functions are unsound\nbecause they allow transmuting values without `unsafe` blocks.\n\nThe following example shows how to create a dangling reference:\n\n```\nfn main() {\n    #[derive(Copy, Clone, PartialEq, Debug)]\n    struct S(&'static str);\n    impl flatbuffers::EndianScalar for S {\n        fn to_little_endian(self) -\u003e Self { self }\n        fn from_little_endian(self) -\u003e Self { self }\n    }\n    println!(\"{:?}\", flatbuffers::read_scalar::\u003cS\u003e(&[1; std::mem::size_of::\u003cS\u003e()]));\n}\n```","aliases":["CVE-2020-35864","GHSA-c9h5-hf8r-m97x"],"modified":"2023-11-08T04:03:36.276800Z","published":"2020-04-11T12:00:00Z","database_specific":{"license":"CC0-1.0"},"references":[{"type":"PACKAGE","url":"https://crates.io/crates/flatbuffers"},{"type":"ADVISORY","url":"https://rustsec.org/advisories/RUSTSEC-2020-0009.html"},{"type":"REPORT","url":"https://github.com/google/flatbuffers/issues/5825"}],"affected":[{"package":{"name":"flatbuffers","ecosystem":"crates.io","purl":"pkg:cargo/flatbuffers"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0.4.0"},{"fixed":"2.0.0"}]}],"ecosystem_specific":{"affects":{"arch":[],"functions":["flatbuffers::read_scalar","flatbuffers::read_scalar_at"],"os":[]},"affected_functions":null},"database_specific":{"source":"https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2020-0009.json","categories":[],"cvss":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","informational":null}}],"schema_version":"1.7.3","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"}]}