{"answers":{"affected":"2 open source packages ship an affected version, including yara-x.","exploited":"There is no known exploitation of GHSA-2jx3-ff3v-j7jj in the wild and no public exploit code.","fix":"Upgrade yara-x to 1.19.0 or later.","what":"GHSA-2jx3-ff3v-j7jj is an unsafe deserialization vulnerability in yara-x, published on 24 Sep 2026. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-2jx3-ff3v-j7jj and fix it if it is affected.\n\nWhat it is: GHSA-2jx3-ff3v-j7jj is an unsafe deserialization vulnerability in yara-x, published on 24 Sep 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-2jx3-ff3v-j7jj in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- yara-x (crates.io): affected all versions; fixed in 1.19.0\n- yara-x (crates.io): affected all versions; fixed in 1.19.0\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-2jx3-ff3v-j7jj/ (Markdown: https://insights.sbomify.com/GHSA-2jx3-ff3v-j7jj/index.md)","id":"GHSA-2jx3-ff3v-j7jj","markdown":"https://insights.sbomify.com/GHSA-2jx3-ff3v-j7jj/index.md","name":"GHSA-2jx3-ff3v-j7jj","record":{"aliases":[],"analysis":{"component_type":"library","fix_type":"patch","impacts":["code_execution","denial_of_service"],"network_reachable":"yes","non_default_config":false,"product_category":"Rust YARA library","requires_auth":"none","summary":"Unvalidated deserialization in yara-x allows attackers to trigger memory corruption and undefined behavior via crafted serialized rule data.","user_interaction":"not_required","vuln_class":"deserialization"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"\u003e [!NOTE]\n\u003e This finding was identified during an agentic unsafe Rust code review performed by Gemini AI, followed by human review and verification.\n\n## The Issue\n\nThe crate exports a public safe API [`Rules::deserialize`](https://github.com/VirusTotal/yara-x/blob/5bd1f35db783679c90a3ea1a66bd15fe4e55bef1/lib/src/compiler/rules.rs#L187-L254)  accepting any generic byte sequence `B: AsRef\u003c[u8]\u003e`. It restores compiled rule structures directly from raw bytes using `bincode::serde::decode_from_slice`.\n\nThis decoded `Rules` struct contains internal lookup tables, including `sub_patterns: Vec\u003c(PatternId, SubPattern)\u003e`, `atoms: Vec\u003cSubPatternAtom\u003e`, and `lit_pool: BStringPool`. Subsequent safe operations assume these internal tables satisfy strict structural invariants:\n\n- `Rules::get_sub_pattern` executes `unsafe { self.sub_patterns.get_unchecked(sub_pattern_id.0 as usize) }`. If untrusted serialized bytes contain an atom referencing an out-of-bounds `SubPatternId`, calling `get_sub_pattern` during scanning triggers an out-of-bounds memory read (Undefined Behavior).\n\nhttps://github.com/VirusTotal/yara-x/blob/5bd1f35db783679c90a3ea1a66bd15fe4e55bef1/lib/src/compiler/rules.rs#L355-L360\n\n- `Metadata::next()` extracts string metadata via `unsafe { s.to_str_unchecked() }`. If serialized bytes corrupt `lit_pool` indices or structural data, `to_str_unchecked` constructs a `\u0026str` pointing to invalid UTF-8 bytes (Undefined Behavior).\n\nhttps://github.com/VirusTotal/yara-x/blob/5bd1f35db783679c90a3ea1a66bd15fe4e55bef1/lib/src/models.rs#L204-L210\n\nBecause passing malformed or untrusted data to `Rules::deserialize` induces Undefined Behavior in subsequent safe calls (`Scanner::new`, `Scanner::scan`) without any `unsafe` blocks in caller code, this API is unsound.\n\n\u003cdetails\u003e\u003csummary\u003eMinimal Reproduction (Miri / Native Crash)\u003c/summary\u003e\n\nZip file with crashing_payload: \n[crashing_payload.zip](https://github.com/user-attachments/files/29173221/crashing_payload.zip)\n\nWe have a payload crashing_payload.bin where only a single byte in the structural metadata tail is mutated (changing a `SubPatternId` from `1` to `248` while keeping the WebAssembly bytecode completely untouched and valid).\n\nBelow is the self-contained verification script which compiles and runs against the official **unmodified** `yara-x v1.17.0` crate:\n\n```rust\nuse yara_x::{Rules, Scanner};\n\nfn main() {\n    // Embed the crashing payload generated by the fuzzer at compile time.\n    let serialized = include_bytes!(\"crashing_payload.bin\");\n    println!(\"Loaded embedded crashing payload, length: {}\", serialized.len());\n\n    // Deserialize. On unmodified library, this succeeds because the WASM and headers\n    // are pristine and structural corruption isn't validated.\n    if let Ok(deserialized) = Rules::deserialize(serialized) {\n        println!(\"Deserialization succeeded! Running scanner...\");\n        let mut scanner = Scanner::new(\u0026deserialized);\n        \n        // Run the standard scan, which will execute the WASM and trigger the out-of-bounds read!\n        let _ = scanner.scan(b\"lorem ipsum dolor sit amet\");\n        println!(\"Scanner finished.\");\n    } else {\n        println!(\"Deserialization failed!\");\n    }\n}\n```\n\n### 1. Miri Trace\n\nNOTE: This needs to be run with 1.17.0. I haven't tested this against other versions.\n\nUnfortunately I was able to get a miri trace, but I'm not able to reproduce it right now because of lockfile changes. If you're trying this out be sure to use `MIRIFLAGS=\"-Zmiri-disable-stacked-borrows\"`\n\n### 2. Segfault / panics\n\nWhen run natively (without Miri or any sanitizers) on a standard Linux platform, the process immediately segfaults:\n\n```bash\n$ cargo run --bin verify\nLoaded embedded crashing payload, length: 11777\nDeserialization succeeded! Running scanner...\nSegmentation fault (core dumped)\n```\n\nAnd with a newer compiler (which appears to have debug assertions in `get_unchecked)`\n\n```bash\nDeserialization succeeded! Running scanner...\n\nthread 'main' (997442) panicked at lib/src/compiler/rules.rs:404:36:\nunsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice\n\nThis indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eSuggested Fix\u003c/summary\u003e\n\nTo uphold Rust soundness guarantees, either mark `Rules::deserialize` as `pub unsafe fn deserialize` with a formal `/// # Safety` contract documenting that callers are responsible for verifying the authenticity and structural integrity of the input bytes (e.g. via cryptographic signatures), or replace all internal `get_unchecked` and `to_str_unchecked` calls on deserialized data structures with safe bounds checks (`.get()`) and UTF-8 validation (`std::str::from_utf8`).\n\n\u003c/details\u003e\n\n---","ecosystems":["crates.io"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"yara-x: Unvalidated deserialization in safe `Rules::deserialize` allows memory corruption and UB","id":"GHSA-2jx3-ff3v-j7jj","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"crates.io","product":null,"products":[],"type":"deserialization","year":"2026"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"crates.io","fixed":["1.19.0"],"introduced":["0"],"last_affected":[],"package":"yara-x","purl":null,"source":"GHSA-2jx3-ff3v-j7jj"},{"ecosystem":"crates.io","fixed":["1.19.0"],"introduced":["0"],"last_affected":[],"package":"yara-x","purl":"pkg:cargo/yara-x","source":"GHSA-2jx3-ff3v-j7jj"}],"products":null,"published":"2026-09-24","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Unvalidated deserialization in yara-x allows attackers to trigger memory corruption and undefined behavior via crafted serialized rule data.","url":"https://insights.sbomify.com/GHSA-2jx3-ff3v-j7jj/"}