Advisory

RUSTSEC-2020-0009

Also known as: CVE-2020-35864, GHSA-c9h5-hf8r-m97x

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>()]));
}

Severity

High Basis: CVSS v3 score 7.5, vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Dates

Published
2020-04-11 12:00 UTC
Modified
2023-11-08 04:03 UTC

Affected packages and fixes

flatbuffers

crates.io · All systems

Affected

  • introduced 0.4.0, fixed 2.0.0 (semver)

Fixed versions

2.0.0

Fix

  • Fixed version 2.0.0
    cargo update -p flatbuffers --precise 2.0.0

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: RustSec Advisory Database · CC0-1.0

Sources & licences