Skip to content

Response, New York. Noah Park: Check Point Patches Actively Exploited Management Server Path Traversal. Detection, Dallas. Ava Okello: Report Finds Nearly Half of Deployed Detections Need Attention Before SOCs Can Trust Them.

SOCtember

Always First. Fast SOC News.

A screenshot of the GitHub release page for VirusTotal yara-x v1.25.0, marked Latest, listing changes including replacing bincode with postcard for compiled rule serialization so previously serialized rules must be recompiled, following symbolic links to regular files when scanning directories, and fixing memory corruption when a Scanner or Compiler is used sequentially across different OS threads such as Go goroutines or C thread pools.
Image: VirusTotal yara-x project on GitHub (fair use), the v1.25.0 release notes.

Tools

YARA-X Fixed a Bug That Made "0 of them" Always True, Then Shipped a Speedup That Could Corrupt Memory in Go and C Scanners, and Version 1.25 Makes Every Saved Ruleset Recompile

Two YARA-X releases in six days fix rule logic that silently disagreed with classic YARA, a directory scan that skipped symlinked samples without a word, and a heap corruption bug that the first of the two releases introduced. Teams running YARA-X in pipelines should go straight to 1.25.0 and rebuild their compiled rules.

James Whitford, ToolsAustin5 min read

AUSTIN - YARA-X, VirusTotal's Rust rewrite of the YARA pattern-matching engine, has shipped two releases in less than a week, and the fine print matters for any team that runs YARA rules in a detection pipeline, a malware triage service or an incident response kit.

Version 1.24.0, published November 20, brings 8 improvements and 15 bug fixes, and version 1.25.0, published November 26, adds 4 improvements and 14 bug fixes, as SANS Internet Storm Center handler Didier Stevens tallied on Sunday. Several of those fixes change what a scan returns.

A condition that always said yes

The most consequential fix in 1.24.0 is to a single expression. In YARA, "0 of them" means none of the rule's strings matched, the same as "none of them," and classic YARA has behaved that way since version 4.3.0. YARA-X did not.

A screenshot of yara-x GitHub issue 847, titled 0 of them is true even when some of the patterns match, showing a rule named zero using the condition 0 of them matching a file containing the string foo, a note that YARA 4.5.8 reports no matches for the same file, and a table comparing YARA 4.5.8 and YARA-X results for several forms of the condition.
Image: VirusTotal yara-x project on GitHub (fair use), issue 847.

In issue 847, filed November 7, a user showed a rule with the condition "0 of them" matching a file that contained one of its strings, while YARA 4.5.8 correctly reported no match. The fix explains the cause: a shortcut used when the strings in a set are numbered contiguously, which is always the case for "0 of them," returned true whenever the number of matches was at least the number required. With zero required, that test always passed.

The bug affected "0 of them," other "0 of" sets whose strings were declared one after another, and quantifiers computed at run time that came out to zero, such as "uint8(0) of them." Other spellings, including "none of them," were already correct. In practice, a rule author who wrote "0 of them" to exclude files containing known benign strings got an exclusion that did nothing, and a rule that YARA evaluated correctly could fire in YARA-X on files it was meant to skip.

A speedup with a cost

Version 1.24.0 also included a batch of performance work. One of those changes, commit 0258378, added per-thread caches of reference-counted values. According to pull request 907, merged November 25, that design broke when a single scanner or compiler object was used from more than one operating system thread in sequence, as happens in Go programs using goroutines and in C thread pools. Reference counts from one thread could be decremented on another, "causing UAF/double-free heap corruption," the pull request says.

A screenshot of yara-x pull request 907, fix(types): avoid cross-thread Rc races when scanners migrate OS threads, merged by plusvic, explaining that commit 0258378 introduced thread-local caches of Rc values and that using a scanner or compiler across multiple OS threads sequentially, such as in Go goroutines or C thread pools, can cause use-after-free or double-free heap corruption, and listing the fix.
Image: VirusTotal yara-x project on GitHub (fair use), pull request 907.

Use-after-free and double-free bugs can crash a process or, in the worst case, be exploitable. The pull request does not describe an attack, and SOCtember found no report of one. The practical exposure is narrower: services that embed YARA-X through its C API or Go bindings and ran 1.24.0. The fix shipped in 1.25.0, so any team that upgraded to 1.24.0 to pick up the "0 of them" fix should move again.

Scans that quietly skipped files

Version 1.25.0 fixes a quieter failure. In issue 894, opened November 23, a user reported that running the yr command-line tool against a directory whose samples were symbolic links to files stored elsewhere produced no matches at all, because the directory walk skipped the links. The exit code was 0 and nothing was printed. The same happened with rule directories: if the rule files were symlinks, yr compiled zero rules and still reported success. Classic YARA follows such links by default, the reporter noted.

A screenshot of yara-x GitHub issue 894, titled yr scan: symlinks to files inside a scanned directory are silently skipped, describing a directory of symlinked samples producing no matches with exit code 0, rule directories made of symlinks compiling zero rules, and a reproduction on yr 1.24.0 compared with YARA 4.5.8.
Image: VirusTotal yara-x project on GitHub (fair use), issue 894.

Symlinked sample stores are common in sandboxes, evidence collections and deduplicated malware libraries, so a clean result from yr on such a tree before 1.25.0 should not be read as proof that nothing matched.

1.25.0 also changes how compiled rules are saved, replacing one serialization library with another, and the release notes say plainly that "previously serialized rules must be recompiled." Pipelines that compile rules once and distribute the binary file to scanners will need to rebuild those files when they upgrade. Version 1.24.0, for its part, restricted include directives to regular files inside configured include directories to prevent path traversal, which may break rule sets that pull in files from elsewhere on disk.

What a tools team should do

  • Upgrade straight to 1.25.0. It contains the "0 of them" fix from 1.24.0 and the fix for the memory corruption 1.24.0 introduced.
  • Search your rule sets for "0 of" conditions and quantifiers that can evaluate to zero, and re-run any retro hunts or triage verdicts that depended on them. Files may have been flagged that should not have been.
  • Recompile and redistribute saved rules after upgrading, and add a check that the scanner loaded the expected number of rules, so a silent zero-rule load fails loudly.
  • Re-scan symlinked sample stores and evidence trees that were scanned with yr before 1.25.0, or point yr at the link targets.
  • If you embed YARA-X in Go or C services, confirm which version each build links against, and treat crashes in scanner workers running 1.24.0 as a known bug rather than bad samples.
  • Test includes. Rule sets that include files from outside the configured include directories will need to be restructured.

About the Author

James Whitford

James Whitford covers SOC tooling, SIEM, SOAR, and detection platforms for SOCtember from Austin.

Related stories

Tools desk