Skip to content
Heist/ feed
UnratedFix available

yara-x: Unvalidated deserialization in safe `Rules::deserialize` allows memory corruption and UB

Type: advisorySource: OSV1 source record

> [!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`](https://github.com/VirusTotal/yara-x/blob/5bd1f35db783679c90a3ea1a66bd15fe4e55bef1/lib/src/compiler/rules.rs#L187-L254) accepting any generic byte sequence `B: AsRef<[u8]>`. It restores compiled rule structures directly from raw bytes using `bincode::serde::decode_from_slice`. This decoded `Rules` struct contains internal lookup tables, including `sub_patterns: Vec<(PatternId, SubPattern)>`, `atoms: Vec`, and `lit_pool: BStringPool`. Subsequent safe operations assume these internal tables satisfy strict structural invariants: - `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). https://github.com/VirusTotal/yara-x/blob/5bd1f35db783679c90a3ea1a66bd15fe4e55bef1/lib/src/compiler/rules.rs#L355-L360 - `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 `&str` pointing to invalid UTF-8 bytes (Undefined Behavior). https://github.com/VirusTotal/yara-x/blob/5bd1f35db783679c90a3ea1a66bd15fe4e55bef

Announced Group revision 1
Original source ↗

GHSA-2jx3-ff3v-j7jj

Primary source · Revision 1

Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.

Security context

Source reference: osv:GHSA-2jx3-ff3v-j7jj

yara-x

Source reference: /affected/0/package/name

Affected versions
Not stated in this record
Fixed versions
1.19.0

Source reference: /affected/0/ranges

Prerequisites
Not stated in this record

Structured affected-version data

Original package identities and version rules from this source.

[
  {
    "ranges": [
      {
        "type": "SEMVER",
        "events": [
          {
            "introduced": "0"
          },
          {
            "fixed": "1.19.0"
          }
        ]
      }
    ],
    "package": {
      "name": "yara-x",
      "purl": "pkg:cargo/yara-x",
      "ecosystem": "crates.io"
    },
    "database_specific": {
      "source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-2jx3-ff3v-j7jj/GHSA-2jx3-ff3v-j7jj.json",
      "last_known_affected_version_range": "<= 1.18.0"
    }
  }
]

Publisher severity

No explicit severity was provided.

Event
#14221 · Revision 1
Added to Heist Feed
Publisher date
Read the original announcement