Adverserial use of `make_bitflags!` macro can cause undefined behavior
Key facts
- Attack vector
- —
- Privileges required
- —
- User interaction
- —
- Attack complexity
- —
- Impact type
- —
- Confidentiality · integrity · availability
- —
- Fix status
- Fixed
No CVSS vector from any source. Fix status from GitHub.
Summary
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 } ```
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | enumflags2 (crates.io) | 0.7.0 to before 0.7.7 | 0.7.7 | Patch available | GHSA-qvc4-78gw-pv8p |
- enumflags2 (crates.io) Vendor— Affected 0.7.0 to before 0.7.7 Fixed in 0.7.7 Patch available GHSA-qvc4-78gw-pv8p
Remediation
- Fix · GHSA-qvc4-78gw-pv8p enumflags2 (crates.io) Fixed in 0.7.7 Advisory →
Timeline
- 2026-10-03 Threatist record created from GHSA-qvc4-78gw-pv8p
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences