RUSTSEC-2023-0035

    Dashboard / Vulnerabilities / RUSTSEC-2023-0035

    RUSTSEC-2023-0035

    Published: 17 Apr 2023Last Modified: 8 Nov 2023

    Summary: Adverserial use of `make_bitflags!` macro can cause undefined behavior

    Details: The macro relied on an expression of the form `Enum::Variant` always being a variant of the enum. However, it may also be an associated integer constant, in which case there's no guarantee that the value of said constant consists only of bits valid for this bitflag type. Thus, code like this could create an invalid `BitFlags<Test>`, which would cause iterating over it to trigger undefined behavior. As the debug formatter internally iterates over the value, it is also affected. ```rust use enumflags2::{bitflags, make_bitflags}; #[bitflags] #[repr(u8)] #[derive(Copy, Clone, Debug)] enum Test { A = 1, B = 2, } impl Test { const C: u8 = 69; } fn main() { let x = make_bitflags!(Test::{C}); // printing or iterating over x is UB } ```

    Affected packages

    Package

    Name: enumflags2

    Purl: pkg:cargo/enumflags2

    Affected ranges

    Type: SEMVER

    Events:

    Introduced- 0.7.0
    Fixed -0.7.7

    Affected versions

    Common Vulnerability Scoring System

    Attack Vector
    Network
    Adjacent
    Local
    Physical
    Privileges Required
    None
    Low
    High
    User Interaction
    None
    Required
    Scope
    Unchanged
    Changed
    Confidentiality
    None
    Low
    High
    Integrity
    None
    Low
    High
    Availability
    None
    Low
    High
    RUSTSEC-2023-0035 | CVE-DB