Skip to content
Tamandua
← All posts
EDR

Sigma and YARA together: practices for detections that hold up when attackers change things

Practices for writing Sigma and YARA rules that are harder to evade by renaming a tool, encoding a command or repacking a payload, with illustrative rule examples.

Tamandua Team · · 7 min read

Most detection rules break the first time an attacker renames a binary. A rule that matches mimikatz.exe stops matching when the file is called svc_update.exe. A rule that matches one hash stops matching after a single byte changes. Those rules are easy to write and easy to evade, and plenty of rule packs are full of them.

Tamandua EDR's approved evaluation scope is Windows by invitation only; this post discusses Sigma and YARA practices, not general product availability. These open formats are readable and extendable. The rules below are illustrative, not measured results, and we have not published a benchmark corpus for them.

Two formats, two jobs

Sigma and YARA answer different questions. Treating them as alternatives misses the point.

  • Sigma describes behavior in logs. A process started with these arguments, a registry key was written, a parent spawned an unusual child. It matches events, so it sees what a file does.
  • YARA describes content. Strings, byte patterns and structure inside a file or a buffer. It sees what a file is, even before it runs.

Each side is cheap for an attacker to change on its own. Repacking a payload changes its bytes but not the fact that it dumps LSASS. Renaming a tool changes its command line but not the code inside it. Covering both sides means the attacker has to change the behavior and the content at once, and that costs far more.

Habit 1: match the technique, not the tool name

Here is a fragile Sigma rule:

title: Mimikatz Execution
logsource:
  category: process_creation
  product: windows
detection:
  selection:
    Image|endswith: '\mimikatz.exe'
  condition: selection
level: high

It fires on a lab copy and misses every renamed one. A sturdier rule targets something the technique cannot avoid. Dumping LSASS with the built-in comsvcs.dll, for example, always needs the DLL and its MiniDump export on the command line:

title: LSASS Memory Dump via Comsvcs MiniDump
logsource:
  category: process_creation
  product: windows
detection:
  selection_dll:
    CommandLine|contains|all:
      - 'comsvcs'
      - 'MiniDump'
  selection_rundll:
    Image|endswith: '\rundll32.exe'
  condition: selection_dll and selection_rundll
fields:
  - CommandLine
  - ParentImage
tags:
  - attack.credential_access
  - attack.t1003.001
level: high

The rule is tied to a technique (T1003.001), not to a filename. If you expect attackers to copy and rename rundll32.exe as well, add a second selection on the original file name from the PE header, which survives a rename.

Habit 2: use modifiers instead of exact strings

Attackers vary case, add padding and encode arguments. Value modifiers keep a rule focused on meaning instead of one spelling. Tamandua's Sigma engine supports AND/OR/NOT logic, 1 of and all of selections, count aggregations and more than fifteen value modifiers, including contains, startswith, endswith, re, base64, wide and cidr.

Encoded PowerShell is the classic case. The payload is base64-encoded, so a string match on the clear text misses it. Encoding modifiers let you match the encoded form of a keyword:

title: Encoded PowerShell Downloading Content
logsource:
  category: process_creation
  product: windows
detection:
  selection_img:
    Image|endswith:
      - '\powershell.exe'
      - '\pwsh.exe'
  selection_enc:
    CommandLine|contains:
      - ' -enc '
      - ' -EncodedCommand '
  selection_payload:
    CommandLine|wide|base64offset|contains:
      - 'DownloadString'
      - 'DownloadFile'
  condition: all of selection_*
level: high

PowerShell encodes its command as UTF-16, which is why wide comes before the base64 step. Spelling the switch differently, or changing the URL, does not get the payload past the rule.

Habit 3: count over time when one event is not enough

Some techniques look harmless one event at a time. One failed logon is noise. Forty in two minutes from one source, each against a different account, is password spraying. Sigma's aggregation syntax expresses that, and Tamandua evaluates count-over-timeframe conditions on the server, not only single-event matches:

title: Failed Logons Across Many Accounts From One Source
logsource:
  product: windows
  service: security
detection:
  selection:
    EventID: 4625
  timeframe: 2m
  condition: selection | count(TargetUserName) by IpAddress > 20
level: medium

Counting distinct target users per source catches spraying even when the attacker tries each account only once, which is exactly how spraying avoids lockouts.

Habit 4: write YARA against structure, not one string

A YARA rule that matches one unique string is the content version of the filename rule: change the string and it is gone. Durable rules combine several independent indicators and require a subset of them.

rule Credential_Dumper_Generic
{
    meta:
        description = "References LSASS together with minidump and debug-privilege APIs"
        mitre = "T1003.001"
        severity = "high"

    strings:
        $api1 = "MiniDumpWriteDump" ascii wide
        $api2 = "OpenProcess" ascii
        $api3 = "SeDebugPrivilege" ascii wide
        $tgt1 = "lsass" ascii wide nocase

    condition:
        uint16(0) == 0x5A4D and
        filesize < 5MB and
        $tgt1 and
        2 of ($api*)
}

The uint16(0) == 0x5A4D check limits the rule to PE files and the size bound keeps scans cheap. The condition needs a reference to the target plus two of the three API references. A tool that hides one string still matches on the others, and renaming the tool changes nothing. Expect to tune a rule like this: legitimate crash reporters and diagnostics tools reference some of the same APIs, which is where habit 6 comes in.

In Tamandua, YARA scanning runs on files and byte buffers, and the rule's metadata is carried into the alert. The analyst sees which rule fired, its technique and its severity, not just a match.

Habit 5: let the two formats confirm each other

The strongest signal comes when behavior and content agree. Say the comsvcs rule fires. On its own, that is a high-severity alert worth investigating. If a file written by the same process also matches a YARA rule, the picture gets much clearer.

Tamandua's server correlates related events across processes and time into attack chains before raising an alert, so related signals arrive together instead of as separate tickets. The agent scores process behavior with deterministic, explainable rules, and every alert carries the evidence behind it: process, file, network and timeline context. When a rule is wrong, you can see exactly which condition matched and fix it.

Habit 6: test against benign activity before you ship

A rule that is harder to evade is no use if it also fires on every build server. Before a rule goes live, run it against normal activity from your own environment: installers, admin scripts, backup jobs, crash reporting. After it is live, keep tuning. In Tamandua, analysts mark verdicts on alerts, and the platform can generate suppression rules with a time limit, so a noisy rule gets narrowed and reviewed again later instead of being muted forever.

A short checklist

  • Does the rule match the technique, or only a tool name or hash?
  • Would a change of case, padding or encoding break it? Use modifiers.
  • Is one event enough evidence, or does it need a count over time?
  • Does the YARA rule need several independent indicators before it fires?
  • Is it tagged with an ATT&CK technique, so your coverage stays visible?
  • Has it run against benign activity from your own environment?

Because these are plain Sigma and YARA, none of this is tied to Tamandua. The same habits make rules better in any engine that reads the two formats. Windows is the only platform with approved invitation evaluations; Linux is source-lab only, and no hosted EDR beta is offered.

Next step

Take the ten rules that fire most often in your environment and run each through the checklist above. The ones that only match a tool name or a hash are the first to rewrite.

Updated 2026-10-02: the title and introduction now frame these as practices rather than proven results.

Bring Tamandua EDR to your fleet

Detection you can read and response you control across Windows, Linux and macOS.