Skip to content

About

49 Sigma rules, unit-tested (215 cases), ATT&CK-checked and converted to Splunk, Sentinel and Elastic on every commit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Detection-as-Code: Sigma Rule Pipeline

Detection CI

One repository for all the Sigma rules from my detection engineering projects, run through a CI pipeline on every commit. Rules are treated like code: they are validated, converted to several SIEM languages, tested against sample logs, and mapped to MITRE ATT&CK automatically.

Pipeline

Stage What it does Status
1. Validate sigma check with every validator turned on (ATT&CK tags are checked in stage 4). Any error or issue fails the build ✅ done
2. Convert Every rule converted to Splunk SPL, Microsoft Sentinel KQL (ASIM) and Elastic Lucene (ECS). Report in the job summary, queries as a build artifact ✅ done
3. Unit test Each rule has sample logs that must trigger it and logs that must not. Rules are executed for real with the pySigma SQLite backend. A rule without tests fails the build ✅ 49 / 49 rules, 215 cases
4. ATT&CK coverage Every tag checked against ATT&CK v20.1 (Enterprise and ICS); Navigator layers and a coverage table per tactic generated on every commit ✅ done

Latest: RMM attacks on MSPs (November 2026)

In the same week, attackers went after N-able N-central (4EverAble2Shell, unauthenticated root, XMRig on 21 servers) and ConnectWise ScreenConnect (SCKit, rogue clients pushed through RMM+ extensions to about 400 partner environments). 12 new rules were added about two weeks after the first reports, each with unit tests from day one and converted to Splunk, Sentinel and Elastic by the same pipeline.

➡️ Case notes, rules and known limits

Rules

52 rules (49 files, 3 with correlation rules) from these sources:

Project Rules Platforms
armory-castle-vcenter-detections 13 Linux, vCenter, ESXi, proxy, Zeek
hospital-ransomware-nis2-playbook 9 Windows
sandworm-ukraine-grid-ics-attacks 9 Windows, Linux, Zeek (IEC-104)
php2shell-detection-engineering 6 Web server, WAF, PHP, Linux
RMM attacks on MSPs, Nov 2026 (written in this repository) 12 Linux, Windows, web server, WAF, firewall, DNS

Each rule keeps a link to its source project or reports in references.

Layout

rules/
  linux/            13 rules  (process_creation, file_event)
  windows/          20 rules  (process_creation, file_event, registry_set, Security log)
  vmware/            3 rules  (vCenter SSO, VAMI, ESXi shell)
  web/               7 rules  (webserver, WAF, Apache, PHP)
  network/zeek/      3 rules
  network/proxy/     1 rule
  network/firewall/  1 rule
  network/dns/       1 rule
docs/
  rmm-attacks-on-msps-2026-11.md   case notes for the November 2026 RMM rules
config/
  validation.yml             validator settings and documented exclusions
  conversion-expected.yml    which targets each rule must keep converting to
scripts/
  convert.py                 converts every rule and writes the report
  run_tests.py               runs every rule against its sample events
  coverage.py                checks ATT&CK tags, builds Navigator layers
tests/                       one test file per rule, same path as the rule
.github/workflows/
  ci.yml                     the pipeline

Run it locally

# Stage 1: validate
pip install -r requirements.txt
sigma check --validation-config config/validation.yml --fail-on-issues rules/

# Stage 3: unit tests (same environment as stage 1)
python scripts/run_tests.py --require-all

# Stage 4: ATT&CK coverage (needs the STIX data in build/attack-data/)
mkdir -p build/attack-data
for d in enterprise-attack ics-attack; do
  curl -sSfL https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master/$d/$d-20.1.json \
       -o build/attack-data/$d-20.1.json
done
python scripts/coverage.py

# Stage 2: convert (use a separate virtual environment, see below)
pip install -r requirements-convert.txt
python scripts/convert.py      # queries in build/queries/, report in build/conversion-report.md

Conversion results

Target Converted Notes
Splunk SPL 49 / 49 Includes the 3 correlation rules
Elastic Lucene (ECS) 46 / 49 The Lucene backend does not support correlation rules
Sentinel KQL (ASIM) 30 / 49 ASIM has no table for Zeek, vCenter/ESXi, Apache, PHP, WAF bodies, Sigma firewall/DNS fields or Security 4698, and the backend does not support correlation rules

Download the queries from the latest run: Actions → latest run → Artifacts → converted-queries. The per-rule matrix is in the run's job summary.

How the build treats conversion failures. A backend that cannot handle a log source is expected, so it is reported and does not fail the build. The build fails if a rule converts to no target at all, or if a rule stops converting to a target listed in config/conversion-expected.yml. That file is the regression baseline.

Two toolchains. Validation uses sigma-cli 4 / pySigma 2 for the newest validators. The Elastic and Kusto backends still require pySigma 1.x, so conversion runs in its own job with requirements-convert.txt. Both are pinned.

Known limits of the converted queries

  • Linux, proxy, web and VMware rules have no field-mapping pipeline for Elastic, so their Lucene queries keep the generic Sigma field names (CommandLine, Image). Map them to ECS (process.command_line, process.executable) for your index.
  • Windows and Zeek rules use the ECS pipelines (ecs_windows, ecs_zeek_beats).
  • To bring the Sentinel coverage up, the custom log sources need their own table mappings (e.g. a custom table for ESXi shell.log). This is on the roadmap.

Unit tests

Every rule gets a test file at the same path under tests/. Each case is a small set of log events:

match:                    # must trigger the rule
  - name: SSH turned on
    event: {cs-method: PUT, cs-uri-stem: /rest/appliance/access/ssh}
no_match:                 # look-alike benign activity, must NOT trigger
  - name: SSH state only read
    event: {cs-method: GET, cs-uri-stem: /rest/appliance/access/ssh}
known_false_positive:     # triggers today but should not: a documented limit
  - name: host suffix match is too loose
    reason: "endswith 'slack.com' also matches notslack.com"
    event: {cs-host: notslack.com, c-uri: "https://notslack.com/api/conversations.history"}
known_false_negative:     # an attack the rule misses today: a documented gap
  - name: procdump by PID
    reason: "needs the word 'lsass' in the command line"
    event: {Image: 'C:\Tools\procdump64.exe', CommandLine: 'procdump64.exe -ma 624 out.dmp'}

Correlation rules are tested with several timed events, for example four AD discovery commands by one user within 15 minutes (must match) against three commands, four commands over two hours, or four commands by four users (must not match).

The runner converts each rule to SQL with the pySigma SQLite backend, loads the case's events into an in-memory SQLite table and executes the query. So the test exercises the real rule logic, including correlation rules and regular expressions. Fieldless keyword rules (ESXi shell.log, vCenter SSO) match against the event's message field. A field the rule checks but the event does not have is treated as absent, as in a real SIEM.

known_false_positive and known_false_negative cases keep rule limits visible. If someone fixes the rule, the case flips and the test fails with a note to move it to no_match or match, so the documentation cannot go stale.

Found by the tests, and what happened next

The tests found six limits in rules that had already passed validation. Four were fixed. When a rule was fixed, its known_* case failed with a note to move it, exactly as designed, and the case now guards the fix as a normal match / no_match test. Two were accepted, with the reason recorded in the test file.

Rule Limit found Outcome
proxy_slack_api_from_server endswith: 'slack.com' also matched look-alike domains (notslack.com). The obvious fix, '.slack.com', would have missed the bare slack.com host that LAZYBONES calls, which the tests also caught. ✅ Fixed: exact slack.com or *.slack.com
linux_nmap_vmware_management_ports 2012 matched as a plain substring, so paths and other numbers fired. ✅ Fixed: ports must appear in the -p list (regex)
hosp_ransom_stop_backup_av_db_services config + sql matched routine service changes (sc config MSSQLSERVER start= auto). ✅ Fixed: only start= disabled
linux_disk_wipe_or_sysrq_reboot Missed attack: dd from /dev/zero or /dev/urandom over a disk. ✅ Fixed: any random or zero source onto a disk device (not /dev/null)
hosp_ransom_lsass_dump Missed attack: procdump by PID (procdump -ma 624). ⚖️ Accepted: the command line cannot show the PID is lsass. Needs a process-access rule (Sysmon event 10) on a different log source.
esxi_shell_ssh_key_or_vmfs_staging '/.a' matches any dot-folder starting with a on a datastore. ⚖️ Accepted: tightening to '/.a/' would miss the mkdir that creates the staging folder. Low noise on VMFS.

The fixed rules carry modified: 2026-11-28 and a comment that explains the change.

Regex semantics differ between SIEMs. The test runner, Splunk (regex) and KQL (matches regex) search for the pattern anywhere in the field. Elasticsearch regexp queries on keyword fields must match the whole value, so the Lucene version of the nmap rule needs .* at both ends for such fields. The tests cannot see this difference, so check regex rules in Elastic before deployment.

zeek_iec104_from_unexpected_host uses placeholder SCADA server addresses (10.0.0.10, 10.0.0.11). Replace them with your own before deployment.

The tests were checked by breaking rules on purpose: removing a filter, changing an HTTP method, tightening a domain, lowering a correlation threshold, widening a time window, counting the wrong field and widening a regular expression. Every change made the expected test fail, and a rule with a broken condition is reported as a failure instead of crashing the run.

ATT&CK coverage

The coverage job downloads the official ATT&CK STIX data for v20.1 (pinned, cached between runs) and:

  1. Checks every attack.* tag. Unknown IDs, revoked or deprecated techniques (with the replacement, e.g. t1086 → t1059.001) and tactics that no longer exist (e.g. defense-evasion, split into stealth and defense-impairment in recent versions) fail the build. It knows both Enterprise and ICS, so ICS tags such as attack.t0881 are checked too.
  2. Builds two ATT&CK Navigator layers (layer-enterprise.json, layer-ics.json). The score of a technique is the number of rules that cover it, and the comment lists them.
  3. Writes a coverage table per tactic to the job summary.
Domain Covered Rules
Enterprise 51 techniques and sub-techniques (45 distinct techniques) in all 13 tactics from Initial Access to Impact 48
ICS 6 techniques across Execution, Evasion, Command and Control, Inhibit Response Function and Impair Process Control 4

Download the layers: Actions → latest run → Artifacts → attack-coverage, then ATT&CK Navigator → Open Existing Layer → Upload from local.

The coverage numbers say which techniques have a rule, not that the technique is fully detected. Most rules target one campaign's specific behaviour.

Validation policy

All validators run, and the build fails on any issue, not just on errors. An exception must be added to config/validation.yml for one rule ID at a time, with a comment that explains why. Current exceptions:

  • An escaped \? in the PHP2Shell upload rule, which is meant to match a literal <?php.
  • pySigma's attacktag validator is turned off. It only knows Enterprise ATT&CK and rejected the valid ICS tags of the four Sandworm rules. ATT&CK tags are checked by the coverage job instead, against both Enterprise and ICS. (Before stage 4 this was four hand-checked per-rule exceptions.)

Roadmap

  • Collect rules and validate them in CI
  • Convert to SPL, KQL and Elastic, and publish the output as build artifacts
  • Map the custom log sources (Zeek, vCenter, ESXi, web) for Sentinel KQL
  • Unit tests for all 37 rules, mandatory for new rules (--require-all)
  • Fix the rule limits the tests found: 4 fixed, 2 accepted with reasons
  • Process-access rule for LSASS (Sysmon event 10) to close the accepted procdump-by-PID gap
  • ATT&CK tag check (Enterprise + ICS) and Navigator layers generated in CI
  • Port the KQL detections from connectwise-m365-kql-detections to Sigma

License

© 2026 Stelios Partsinevelos. Released under the MIT License (see LICENSE). Rules are provided as-is for defensive use. Test before production.

About

49 Sigma rules, unit-tested (215 cases), ATT&CK-checked and converted to Splunk, Sentinel and Elastic on every commit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages