YARA rule naming and style conventions
Conventions used in public YARA rule sets: rule name prefixes, meta fields, string naming ($x, $s, $fp), formatting with yr fmt, comments and versioning.
Style does not change what a rule matches, but it decides whether the next analyst can understand, trust and maintain it. The conventions below are the ones you will see in large public rule sets such as Signature Base or the YARA Forge packages; adopting them makes your rules familiar to everyone.
Rule names
A common pattern is PREFIX_Family_Detail_Date:
| Prefix | Meaning | Example |
|---|---|---|
MAL_ | Malware | MAL_Emotet_Loader_Mar24 |
APT_ | Threat-actor tooling | APT_UNC0000_Backdoor_Config |
HKTL_ | Hack tool / offensive framework | HKTL_CobaltStrike_Beacon_Strings |
SUSP_ | Suspicious trait, not malicious by itself | SUSP_PE_Overlay_Base64_Script |
EXPL_ | Exploit or exploit document | EXPL_CVE_2023_23397_Outlook |
WEBSHELL_ | Web shell | WEBSHELL_PHP_Generic_Eval |
PUA_ | Potentially unwanted application | PUA_Miner_XMRig_Config |
Some sets add a platform (MAL_Win_, MAL_Linux_) or a technique. YARA Forge additionally prefixes every rule with its source (SIGNATURE_BASE_…), which is why rule pages in this library show both names.
Meta fields
| Field | Purpose |
|---|---|
description | One sentence: what the rule detects |
author | Who wrote it (kept visible when matches are reported under DRL 1.1) |
reference | Report, blog post or case that motivated the rule |
date / modified | Creation and last change, YYYY-MM-DD |
id | Stable UUID, survives renames |
hash | Sample hashes used to build or test the rule (repeat the key) |
score | 0–100 confidence that a match is malicious |
license | Licence of the rule, when it differs from the repository's |
rule MAL_Example_Conventions_Sep26
{
meta:
= "Example loader showing the usual meta fields"
= "yararules.org"
= "https://yararules.org/en/learn/style-conventions"
= "2026-09-29"
= "2026-09-29"
= "5b0f7a58-1f35-4c1c-9d3e-6b2f4b1b8a10"
= "0000000000000000000000000000000000000000000000000000000000000000"
= 75
= "DRL-1.1"
strings:
$x1 = "ExampleLoader_v3_config" ascii
$s1 = "Stage2Url" wide
$s2 = "InjectInto" ascii
$fp1 = "Copyright (c) Example Software GmbH" wide
condition:
uint16(0) == 0x5A4D and filesize < 2MB and
not 1 of ($fp*) and
(1 of ($x*) or all of ($s*))
}
String naming
$x*— highly specific strings, each enough on its own.$s*— supporting strings that only count in combination.$a*,$op*— groups by topic, e.g.$op*for opcode sequences.$fp*— false-positive exclusions, used withnot.
Sets then read naturally: 1 of ($x*) or 3 of ($s*).
Formatting
Consistent layout makes diffs readable. YARA-X's yr fmt rewrites rules in a canonical format. The linter on this site has a conservative formatter that only changes whitespace: it re-indents sections, aligns = signs and leaves rules with comments untouched.
- Four spaces (or one tab) for section keywords, eight for their content.
- One pattern per line; long hex strings may wrap.
- A blank line between rules.
Comments
Use comments for reasoning that doesn't belong in meta — why a byte is wildcarded, which build a pattern came from — and keep them short. Anything a consumer should see in scan results goes in meta instead.
Versioning and change control
- Never reuse a rule name for different logic; create a new rule and retire the old one.
- Keep
idstable across renames and updatemodifiedon every logic change. - Record false positives and their fixes (see testing and CI).
- State a licence: without one, others cannot legally reuse your rule (see public rule sets).
Browse rules from different sources in the library to see these conventions in practice, and check your own with the linter.
FAQ
- What do prefixes like MAL_ or HKTL_ mean in YARA rule names?
- They classify the rule: MAL_ for malware, HKTL_ for hack tools, SUSP_ for suspicious traits, APT_ for threat-actor tooling, EXPL_ for exploits, WEBSHELL_ for web shells and PUA_ for potentially unwanted applications.
- Which meta fields should every YARA rule have?
- At least description, author, date and reference. Many rule sets add id, modified, score, hash and license.
- Is there an official YARA formatter?
- YARA-X ships yr fmt, which rewrites rules in a canonical layout. The linter on this site also has a conservative formatter that only changes whitespace.