Medium, CVSS 4.8crates.ioAmendedPublished
yara-x: Unvalidated deserialization in safe Rules::deserialize allows memory corruption and UB
GHSA-2jx3-ff3v-j7jj
- Affected
- crates.io yara-x <= 1.18.0
- Fixed in
- 1.19.0· Vendor fix available
- Issue
- [!NOTE] This finding was identified during an agentic unsafe Rust code review performed by Gemini AI, followed by human review and verification. The Issue The crate exports a public safe API Rules::deserialize accepting any generic byte sequence B: AsRef<[u8]. It restores compiled rule structures directly from raw bytes using bincode::serde::decodefromslice. This decoded Rules struct contains internal lookup tables, including subpatterns: Vec<(PatternId, SubPattern), atoms: Vec<SubPatternAtom, and litpool: BStringPool. Subsequent safe operations assume these internal tables satisfy strict structural invariants: - Rules::getsubpattern executes unsafe { self.subpatterns.getunchecked(subpatternid.0 as usize) }. If untrusted serialized bytes contain an atom referencing an out-of-bounds SubPatternId, calling getsubpattern during scanning triggers an out-of-bounds memory read (Undefined Behavior).…
Recommended action: Upgrade to 1.19.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.