yara-rule-authoring
What it does
This skill guides writing detection rules for malware in the YARA-X format. It is for security analysts and threat hunters who write or check malware signatures.
When to use it
- βWhen you are writing a new YARA rule to spot a specific malware family.
- βWhen an existing YARA rule fires on normal files and you want to reduce false positives.
- βWhen you are moving older YARA rules over to YARA-X.
Skill link
https://github.com/trailofbits/skills/blob/main/plugins/yara-authoring/skills/yara-rule-authoring/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βWrite a YARA-X rule that detects this malware family without matching normal Windows files.β
5 new skills a week. 1 minute to read.
How it works
It guides choices about naming, string selection, and performance. It also includes scripts that lint rules and check them before they are deployed.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
YARA-X Rule Authoring
Write detection rules that catch malware without drowning in false positives.
Resolve the linter, atom analyzer,
and review helper from this installed SKILL.md's directory.
In commands below, replace each <resolved-...-path> with that script's absolute
path and keep the quotes. The rule file or directory is still relative to your
working directory unless you pass an absolute input path.
This skill targets YARA-X, the Rust-based successor to legacy YARA β 5-10x faster regex, better errors, built-in formatter, stricter validation, new modules (crx, dex), 99% rule compatibility. It powers VirusTotal's production systems. Install with brew install yara-x or cargo install yara-x; the CLI is yr. See Migrating from Legacy YARA for existing rules.
Core Principles
Strings must generate good atoms β YARA extracts 4-byte subsequences for fast matching. Strings with repeated bytes, common sequences, or under 4 bytes force slow bytecode verification on too many files.
Target specific families, not categories β "Detects ransomware" catches everything and nothing. "Detects LockBit 3.0 configuration extraction routine" catches what you want.
Test against goodware before deployment β A rule that fires on Windows system files is useless. Validate against VirusTotal's goodware corpus or your own clean file set.
Short-circuit with cheap checks first β
filesize(instant), then magic bytes (nearly instant), then strings (cheap), then modules (expensive).Metadata is documentation β Future you (and your team) need to know what this catches, why, and where the sample came from.
When to Use
- Writing new YARA-X rules for malware detection
- Reviewing existing rules for quality or performance issues
- Optimizing slow-running rulesets
- Converting IOCs or threat intel into detection signatures
- Debugging false positive issues
- Preparing rules for production deployment
- Migrating legacy YARA rules to YARA-X
- Analyzing Chrome extensions (crx module) or Android apps (dex module)
When NOT to Use
- Static analysis requiring disassembly β use Ghidra/IDA skills
- Dynamic malware analysis β use sandbox analysis skills
- Network-based detection β use Suricata/Snort skills
- Memory forensics with Volatility β use memory forensics skills
- Simple hash-based detection β just use hash lists
Platform Considerations
YARA works on any file type. Adapt patterns to your target:
| Platform | Magic Bytes | Bad Strings | Good Strings |
|---|---|---|---|
| Windows PE | uint16(0) == 0x5A4D |
API names, Windows paths | Mutex names, PDB paths |
| macOS Mach-O | uint32(0) == 0xFEEDFACE (32-bit), 0xFEEDFACF (64-bit), uint32be(0) == 0xCAFEBABE (universal) |
Common Obj-C methods | Keylogger strings, persistence paths |
| JavaScript/Node | (none needed) | require, fetch, axios |
Obfuscator signatures, eval+decode chains |
| npm/pip packages | (none needed) | postinstall, dependencies |
Suspicious package names, exfil URLs |
| Office docs | uint32(0) == 0x04034B50 |
VBA keywords | Macro auto-exec, encoded payloads |
| VS Code extensions | (none needed) | vscode.workspace |
Uncommon activationEvents, hidden file access |
| Chrome extensions | Use crx module |
Common Chrome APIs | Permission abuse, manifest anomalies |
| Android apps | Use dex module |
Standard DEX structure | Obfuscated classes, suspicious permissions |
uintNN()reads little-endian. Write the constant as the bytes reversed, or useuintNNbe()and write them in file order. A ZIP/OOXML file starts with bytes50 4B 03 04, so it isuint32(0) == 0x04034B50βuint32(0) == 0x504B0304compiles cleanly and never matches anything. The same trap catches Mach-O universal binaries: on disk they areCA FE BA BE, souint32(0) == 0xCAFEBABEis a dead branch; writeuint32be(0) == 0xCAFEBABEoruint32(0) == 0xBEBAFECA. Verify withyr scanagainst one known-good sample before trusting any magic-byte check.
macOS Malware Detection
No dedicated Mach-O module exists yet β use magic bytes plus string patterns. Good indicators:
- Keylogger artifacts:
CGEventTapCreate,kCGEventKeyDown - SSH tunnel strings:
ssh -D,tunnel,socks - Persistence paths:
~/Library/LaunchAgents, `/Library/Lau
FAQ
Why does the choice of strings matter?
Short or repeated strings slow down scanning across many files, so the skill steers you toward more distinctive strings.
Should I test rules before using them?
Yes. The skill says to test rules against normal software before deployment.
How do I install YARA-X?
The skill mentions installing it with Homebrew or Cargo. The command-line tool is called yr.
Details
Original description by the author
Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.
repo: trailofbits/skills
Popularity
- GitHub stars
- 8.0k
- Ranking position
- #12742
- License
- CC-BY-SA-4.0
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
audit-context-building
8.0kHelps your agent learn an unfamiliar codebase before a security review, mapping what each function assumes, guarantees and depends on.
algorand-vulnerability-scanner
8.0kHelps your agent scan Algorand smart contracts, written in TEAL or PyTeal, for 11 common security problems such as rekeying attacks and unchecked fees.
audit-prep-assistant
8.0kHelps your agent get a codebase ready for an outside security review, with static analysis, test coverage, dead-code cleanup and clear documentation.
cairo-vulnerability-scanner
8.0kHelps your agent scan Cairo smart contracts on StarkNet for 6 serious problems, including arithmetic overflow, risky cross-layer messages and signature replay.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.