Lucene search

K
rustsecRustsecRUSTSEC-2020-0009
HistoryApr 11, 2020 - 12:00 p.m.

`read_scalar` and `read_scalar_at` allow transmuting values without `unsafe` blocks

2020-04-1112:00:00
rustsec.org
15

0.001 Low

EPSS

Percentile

39.2%

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>()]));
}
CPENameOperatorVersion
flatbuffersge0.4.0
flatbufferslt2.0.0

0.001 Low

EPSS

Percentile

39.2%