Unit 1: Detection lifecycle and ATT&CK coverage · Lesson 5 of 7 · 18 min

Map rules to ATT&CK and find the gaps

Build a coverage layer from rule tags with sigma-cli, then compare it with the threat profile to list techniques nobody detects.

mission

You are
You are preparing the quarterly coverage review.
Situation
Threat intel wrote coverage/threat-profile.csv: sixteen techniques used by the two groups most likely to target Kestrel. Management wants to know which of them have no rule.
Goal
Turn the rules' ATT&CK tags into a layer and compare it with the profile.
Hand in
A list of uncovered techniques, with the high priority ones first.

Coverage as a heat map with holes

01

Build a coverage layer from the rules

sigma analyze attack reads every rule's tags and writes an ATT&CK Navigator layer. count scores each technique by the number of rules that tag it.

analyst@soc-de01
sigma analyze attack count coverage/rules-layer.json rules/sigma
Parsing Sigma rules

you should see The layer is written to coverage/rules-layer.json.

sigma
sigma-cli. Checks Sigma detection rules and converts them into queries for a SIEM. Install with pipx install sigma-cli.
02

Read the layer

@tsv prints the fields separated by tabs. A technique under two tactics appears twice.

analyst@soc-de01
jq -r '.techniques[] | [.techniqueID, .tactic, .score] | @tsv' coverage/rules-layer.json
T1105	command-and-control	1
T1059.001	execution	1
T1136.001	persistence	1
T1543.003	persistence	1
T1543.003	privilege-escalation	1
T1047	execution	1
T1218.011	stealth	1
T1003.001	credential-access	1

you should see Seven techniques, each covered by one rule.

jq
Picks fields out of JSON and reshapes it. Install with sudo apt install jq, or brew install jq on a Mac.
03

Compare with the tags in the rules

grep -o prints only the matching part, so you get every technique tag.

analyst@soc-de01
grep -rhoE 'attack\.t[0-9.]+' rules/sigma | sort -u
attack.t1003.001
attack.t1047
attack.t1059.001
attack.t1070.001
attack.t1105
attack.t1136.001
attack.t1218.011
attack.t1543.003

you should see Eight technique tags. T1070.001 is tagged in a rule but missing from the layer.

grep
Prints the lines of text that match a pattern. Built into Linux and macOS.
sort
Sorts lines of text. Built into Linux and macOS.
04

List the gaps

comm -23 a b prints lines only in file a. Both files must be sorted.

analyst@soc-de01
tail -n +2 coverage/threat-profile.csv | cut -d, -f1 | sort > /tmp/profile.txt
jq -r '.techniques[].techniqueID' coverage/rules-layer.json | sort -u > /tmp/covered.txt
comm -23 /tmp/profile.txt /tmp/covered.txt
T1021.002
T1053.005
T1070.001
T1071.001
T1110.003
T1204.002
T1218.005
T1546.008
T1566.001
T1567.002
comm -23 /tmp/profile.txt /tmp/covered.txt | wc -l
10

you should see Ten of the sixteen profile techniques have no rule in the layer.

tail
Prints the last lines of a file, or follows it as it grows with -f. Built into Linux and macOS.
cut
Keeps only chosen columns or characters from each line. Built into Linux and macOS.
comm
Compares two sorted files and shows the lines unique to each, or shared. Built into Linux and macOS.
wc
Counts lines, words and bytes. Built into Linux and macOS.
05

Pick out the high priority gaps

grep -f - reads the patterns from standard input, here the gap list.

analyst@soc-de01
comm -23 /tmp/profile.txt /tmp/covered.txt | grep -f - coverage/threat-profile.csv | grep ',high,'
T1566.001,high,phishing campaign against freight forwarders
T1204.002,high,phishing campaign against freight forwarders
T1218.005,high,phishing campaign against freight forwarders
T1053.005,high,phishing campaign against freight forwarders
T1021.002,high,ransomware affiliate playbook
T1070.001,high,ransomware affiliate playbook

you should see Six high priority gaps, four from the phishing campaign. T1070.001 is one, even though a rule exists.

What a defender takes away

  1. 1Tags are what turn rules into coverage. Tag every rule.
  2. 2Compare coverage with a threat profile, not with all of ATT&CK.
  3. 3A technique missing from the layer despite a tagged rule means the tag is wrong.

Questions

0 of 2 solved

Answer each one from what you find on your lab machine.

  1. Show hint

    `comm -23 /tmp/profile.txt /tmp/covered.txt | wc -l`

  2. Show hint

    Compare `grep -rhoE 'attack\.t[0-9.]+' rules/sigma` with the layer.