Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
YARA gives analysts a way to describe a malware family rather than a single file, in a syntax that runs against disks, memory, and email gateways alike.

What Are YARA Rules?
YARA is a pattern matching language built for malware researchers. A rule describes what a family looks like — distinctive strings, byte sequences, file structure, and the logic that combines them — and the engine applies that description to files, processes, or raw memory. Where a hash identifies one build, a well-written rule identifies everything compiled from the same source, which is the difference between an indicator and a detection.
Every rule has an identifier and up to three sections: metadata for human context, strings to search for, and a condition that decides what constitutes a match.
rule Privia_Example_Loader
{
meta:
author = "Privia Security"
description = "Config marker and hard-coded user agent"
strings:
$cfg = { 8B 45 ?? 33 C9 89 48 04 83 C0 10 }
$ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Updater/1.0" ascii
$mtx = "svc_update_7f2" ascii wide nocase
condition:
uint16(0) == 0x5A4D and filesize < 2MB
and $cfg and 1 of ($ua, $mtx)
}
Several things in that condition are doing real work. The uint16(0) test anchors the rule to Windows executables, so it never inspects the rest of the disk. The filesize limit keeps it away from large archives and installers. The wildcards in the hex string cover register and offset bytes that change between builds, while the surrounding instructions stay fixed. The ascii wide modifiers matter more than they look: Windows APIs use UTF-16 extensively, and a rule that searches only for ASCII will miss the same string in its wide form.
This breadth is why YARA has outlasted the formats it competed with. The same rule written during an incident feeds threat hunting, gateway filtering, and forensic triage without being rewritten.
Select strings an attacker cannot change without changing the malware. Mutex names, internal debug paths, bespoke user agents, configuration markers, and unusual format strings are good. Library functions, compiler boilerplate, and copied open source are not, because thousands of unrelated programs contain them.
Anchor every rule to a file type and a size limit. Without them the engine examines every byte of every file it is pointed at, which makes a sweep across a file server take hours instead of minutes. Prefer two or three independent conditions over one long string: a rule requiring a structural test plus any two of four markers survives small changes between builds, while a single hundred-byte pattern breaks on the next compile.
Then test against goodware. Run every new rule over a large collection of legitimate software before it reaches production, because a rule that matches a common runtime library will fire on half your estate at three in the morning.
Maintained properly, a rule set is one of the few security assets that appreciates. Each incident adds coverage, and the indicators that expire within days are replaced by descriptions that stay valid for years. At Privia Security, our SOC maturation services cover detection engineering of exactly this kind, including the review process that stops a rule set decaying into noise.
A YARA rule is written in an open language you control, can be shared freely, and can be run wherever you choose, including against process memory. A vendor signature is internal to a product, opaque, and applied on the vendor’s schedule. YARA is a signature in the broad sense, with the distinction being ownership and flexibility rather than the underlying technique.
It can detect unknown samples of known families, which is most of what matters. A rule keyed to distinctive code or configuration markers matches new builds that no hash has ever seen. Rules can also target techniques rather than families, such as a specific packer or injection routine, which catches unrelated samples sharing that component. Genuinely novel code needs behavioural detection.
Both, for different reasons. File scanning catches samples at rest, in email, and in storage before execution. Memory scanning is more powerful against packed and obfuscated malware, because the code has to be reconstructed in memory to run, and one rule then matches every variant that the packing produced. Most mature teams run file rules continuously and memory rules on demand.
Treat rules as code. Require an author, a date, and a reference on every rule, test each one against a large corpus of legitimate software before deployment, and review anything generating repeated false positives rather than leaving analysts to ignore it. Retire rules for threats that no longer exist, and measure performance so slow rules are found before a sweep stalls.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.