← All posts

YARA memory scanning in the browser: physical sweep, VADs and attribution

7 min read

YARA is how most teams encode what they already know about a threat. Pointing it at a memory image is the fastest way to answer "is this family here?", but memory is not a file. It has no single start offset, it is split between physical frames and per-process virtual views, and a string can straddle two pages that are nowhere near each other physically. This post covers how ramparser handles that, and what it deliberately does not do.

The engine: YARA-X in a Web Worker

ramparser ships the official YARA-X WebAssembly build (1.20.0), served from the site's own origin, never from a CDN. It runs in a dedicated Web Worker that holds the compiled rules, so scanning never blocks the page and nothing goes over the network.

If the engine traps mid-scan (a known issue of the 1.20 browser build in Chrome), the client starts a fresh worker, recompiles the rules and rescans that chunk once.

Bringing your own rules

The YARA view takes rules three ways: .yar / .yara files added from disk or dropped onto the page, a paste box, and a small built-in starter set. The starter set is CC0 and written for these tools: two generic hunting rules (an rclone remote configuration section and PowerShell download cradles) and two synthetic rules for the fictional demo case. No third-party rules are bundled and nothing is downloaded at runtime. For real work, load your own packs, such as YARA Forge or signature-base exports.

Every file is compiled into its own namespace (its file name), so two packs can reuse a rule name. A file with errors is left out and the others still compile. Each diagnostic shows the file, the YARA-X error code, and the line and column, with the full report one click away. After a compile, a rule table lists each rule with its tags, meta and strings, so you can check what is actually loaded before you scan.

One engine quirk is worked around. YARA-X 1.18 to 1.21 deduplicates identical patterns across rules, and a header guard on one rule (uint16(0) == 0x5A4D and $a, filesize > N and $a) can leak onto another rule sharing $a and make it silently miss. ramparser splits such rules into separate rule sets, scans them one after the other and merges the hits. When nothing conflicts, you get one set and one pass.

Target 1: the physical sweep

The first target is the whole physical address space. ramparser asks the dump for its physical ranges, merges ranges separated by gaps of 1 MiB or less, and streams them through the engine in 32 MiB chunks. Each chunk re-reads the first 64 KiB of the next one:

  • A match that starts before the overlap belongs to the current chunk.
  • A match that starts inside the overlap is left to the next chunk.

So a string that straddles a chunk boundary is found once, not twice and not zero times. The limit: a match longer than 64 KiB that crosses a boundary can be missed. YARA-X caps match lengths well below that.

The physical sweep sees freed pages, the file cache and kernel memory, which a per-process scan cannot. Its weakness is context: a physical offset does not say which process owns the bytes.

Attributing physical hits to processes

On Windows images with kernel symbols, ramparser closes that gap with a reverse page-table map. It walks the user half of every process's page tables and records, for each physical frame, the (pid, virtual address) pairs that map it. For each hit, the frame is looked up and the in-page offset is added, so a physical match resolves to a process name, a PID and a user-space virtual address. A shared DLL frame lists several owners.

Limits of this mapping:

  • The kernel half is excluded on purpose (every process maps it identically), so a hit in kernel memory stays unattributed.
  • A hit in a freed or cache page has no owner and is shown as "not attributed".
  • At most 24 owners are kept per frame, and the first 2,000 hit frames are attributed.

Target 2: per-process VAD regions

The second target is the Volatility vadyarascan approach. For each Windows process, ramparser takes the regions from the kernel's _MMVAD tree and reads each one through the process's own page tables, then scans it as one stream. Hits carry the PID, the VAD range and its protection, and the virtual address of each match.

Several controls keep this practical:

  • Process filter: all processes, or one PID.
  • File-backed regions (mapped images and files) are skipped by default. Injected code and unpacked payloads live in private memory, and skipping images avoids rescanning the same system DLLs in every process.
  • Region size cap: 16, 64 (default), 256 or 1024 MiB.
  • Paged-out regions: pages not in RAM read as zeros, and a region with no resident page is skipped instead of scanned.

The run summary counts what was skipped and why.

TargetWhat it readsHit context
Physical sweepevery physical range, 32 MiB chunks + 64 KiB overlapphysical offset, owner via reverse page-table map
VAD scaneach process's _MMVAD regionsPID, VAD range, protection, VA
yarascan (built-in)cached physical string sweepphysical offset, family, context
vadyarascan (built-in)first 4 MiB of each VAD, per pagePID, VAD start, family

The built-in family signatures

The Windows plugin set also has two on-demand scanners that need no rules, yarascan and vadyarascan. Despite the names, they are not YARA: they match a fixed catalog of literal strings from commodity tooling: Cobalt Strike (beacon.x64.dll, the %COMSPEC% /C %s spawn string), Metasploit, Mimikatz command names (sekurlsa::logonPasswords, lsadump::sam), Empire, Quasar, AsyncRAT, Remcos, and Conti and LockBit ransom-note fragments.

yarascan runs over physical memory through the shared string sweep. Its hits go into the findings list as "strings in memory", with a warning that they may come from antivirus signature data and should be confirmed with vadyarascan. Low-signal families (generic credential formats, the PsExec service name) are left out of the findings.

vadyarascan walks each process's VADs page by page, capped at the first 4 MiB of each region and 2,048 regions per process. Each physical frame is scanned only once. A shared frame's hits are cached and credited to every process that maps it, and the last bytes of each page are joined with the next one so a string that crosses a page boundary is still caught. A hit becomes a high-severity finding ("Mimikatz signature in lsass.exe (pid 612)"), except a lone family name match, which is rated low because it also matches API names (GdipBitmapLockBits contains "LockBit").

How hits surface

YARA-X results are grouped by rule, with the rule's tags and description meta. Each match row shows where it was found (physical, or the VAD range and protection), the offset, the owning processes as links that open the process view, and the matched bytes as ASCII and hex. The global time range applies too: a match whose owning processes all fall outside it is hidden and counted.

Caps keep the view usable: 1,000 matches per pattern in the engine, 1,000 per rule per scanned region, 10,000 per rule across physical memory, and the first 300 rows shown per rule. CSV and JSON exports contain every kept match, with rule meta, physical offset, PID, process and VA on each row.

Limits to keep in mind

  • Conditions see a chunk or a region, not a file. filesize and uint16(0) apply to the chunk or region. PE-header rules work in the VAD scan when the image starts the region, and only by chance in the physical sweep.
  • VAD scanning and attribution are Windows-only and need the kernel PDB. On Linux and macOS, the physical sweep still works.
  • Throughput is bounded by the browser. The summary reports MB/s; large rule packs cost more per byte than a few targeted rules.

Further reading