Mini Project: A Detection Engineering Sprint
You are the detection engineer of the lab.test SOC for one sprint. The goal: five new detections, each written as a Sigma rule and as a tested pandas implementation, evaluated on a synthetic week of telemetry with a hidden intrusion, mapped to ATT&CK, tuned, and summarised in a one-page report for the SOC lead. Every step uses a lesson of the course and links to it. All data is generated by the program from a fixed seed: no real users, hosts or organisations.
The brief
Environment: 30 users (u01–u30), one workstation each (ws01–ws30), home country VN, VPN sign-ins with MFA as the norm. Sources (already normalised to one schema, see Normalisation and Schemas): auth (VPN sign-ins: user, source address, outcome, country|method), edr (process creation as parent>child plus command-line extras, and LSASS access with the granted-access mask), dns (resolver queries per host).
Threat profile from intelligence (Threat Intelligence): password spraying against the VPN, macro documents, credential theft from LSASS, C2 over DNS-resolved HTTPS with jitter.
Deliverables:
- Five detections as Sigma rules (or SIEM queries where Sigma can't express them), each with metadata (id, status, ATT&CK tags, level, owner).
- A pandas implementation of each, with at least one positive and one negative fixture, passing.
- Results on the week: alerts, true and false positives, precision.
- An ATT&CK coverage table with levels (data / rule / tested), as in Coverage Mapping.
- Tuning notes: every false positive explained and handled narrowly (Tuning, Suppression and Allow-Lists).
- A one-page SOC report.
Step 1 and 2: data, detections, tests and results
The program generates the week (with benign look-alikes on purpose: a forgotten password, a finance macro, Defender reading LSASS, an NTP client, a traveller with MFA), implements the five detections, runs each one's fixtures, and then runs it on the week, scoring against the hidden labels. Edit the thresholds, add a detection, or change the attack, and run it again.
import numpy as np, pandas as pd
# ---------- 1. a synthetic week of normalised telemetry (label = ground truth, hidden from the rules) ----------
rng = np.random.default_rng(2026)
USERS = [f"u{i:02d}" for i in range(1, 31)]
HOST = {u: f"ws{i:02d}" for i, u in enumerate(USERS, 1)}
T0 = pd.Timestamp("2026-01-12") # Monday
rows = [] # time, source, user, host, src, action, obj, extra, label
def add(t, *r, label="benign"):
rows.append((T0 + pd.Timedelta(hours=t), *r, label))
for d in range(5): # working week
for u in USERS:
s = d * 24 + 8 + rng.random()
if rng.random() < 0.15:
add(s - 0.01, "auth", u, "", "10.10.0.%d" % USERS.index(u), "fail", "vpn", "")
add(s, "auth", u, "", "10.10.0.%d" % USERS.index(u), "ok", "vpn", "VN|mfa")
for _ in range(3):
add(s + rng.random() * 8, "edr", u, HOST[u], "", "proc", "explorer.exe>" + rng.choice(["winword.exe", "excel.exe", "chrome.exe"]), "")
for _ in range(int(rng.integers(5, 15))):
add(s + rng.random() * 8, "dns", u, HOST[u], "", "query", rng.choice(["mail.lab.test", "docs.example", "news.example"]), "")
for h in range(0, 24, 4): # security tools touching LSASS (benign)
add(d * 24 + h + 0.5, "edr", "SYSTEM", "ws05", "", "lsass_access", "MsMpEng.exe", "0x1410")
for k in range(int(7 * 24 * 60 / 64)): # NTP client: perfectly periodic
add(k * 64 / 60, "dns", "SYSTEM", "ws02", "", "query", "time.lab.test", "")
for d in range(5): # finance macro (benign, Excel -> cmd)
add(d * 24 + 16, "edr", "u12", "ws12", "", "proc", "excel.exe>cmd.exe", "lab-finance-report.cmd")
for k in range(6): # u08 forgot her password (benign)
add(24 + 9 + k * 0.02, "auth", "u08", "", "10.10.0.7", "fail", "vpn", "")
add(24 + 9.2, "auth", "u08", "", "10.10.0.7", "ok", "vpn", "VN|mfa")
add(48 + 15, "auth", "u21", "", "198.51.100.30", "ok", "vpn", "SG|mfa") # u21 travels, with MFA (benign)
# The intrusion on Thursday: spray finds u17's password, then a macro, credential access and a beacon
for i, u in enumerate(USERS[:12]):
add(72 + 2 + i * 0.01, "auth", u, "", "203.0.113.50", "fail", "vpn", "", label="attack")
add(72 + 2.2, "auth", "u17", "", "203.0.113.50", "fail", "vpn", "", label="attack")
for k in range(5):
add(72 + 2.25 + k * 0.01, "auth", "u17", "", "203.0.113.50", "fail", "vpn", "", label="attack")
add(72 + 2.4, "auth", "u17", "", "203.0.113.50", "ok", "vpn", "DE|password", label="attack")
add(72 + 3.0, "edr", "u17", "ws17", "", "proc", "winword.exe>powershell.exe", "-nop -w hidden -enc ...", label="attack")
add(72 + 3.1, "edr", "u17", "ws17", "", "lsass_access", "C:\\Users\\Public\\lib.exe", "0x1010", label="attack")
t = 72 + 3.2
while t < 72 + 39: # beacon every ~5 min, 20 % jitter, 36 h
add(t, "dns", "u17", "ws17", "", "query", "upd.cdn-lab.example", "", label="attack")
t += 5 / 60 * (1 + 0.2 * rng.uniform(-1, 1))
ev = pd.DataFrame(rows, columns=["time", "source", "user", "host", "src", "action", "obj", "extra", "label"]).sort_values("time", ignore_index=True)
print(f"{len(ev)} events, {ev.source.nunique()} sources, {ev[ev.label == 'attack'].shape[0]} attack events\n")
# ---------- 2. five detections ----------
def d1_bruteforce_success(e, n=5, w="30min"):
a, out = e[e.source == "auth"], []
for r in a[a.action == "ok"].itertuples():
f = a[(a.src == r.src) & (a.user == r.user) & (a.action == "fail") & a.time.between(r.time - pd.Timedelta(w), r.time)]
if len(f) >= n:
out.append((r.Index, r.user, f"{len(f)} failures then success from {r.src}"))
return out
def d2_new_country_no_mfa(e, home="VN"):
a = e[(e.source == "auth") & (e.action == "ok")]
country, method = a.extra.str.split("|").str[0], a.extra.str.split("|").str[1]
hit = a[(country != home) & (method != "mfa")]
return [(i, r.user, f"sign-in from {r.extra.split('|')[0]} without MFA") for i, r in hit.iterrows()]
def d3_office_shell(e):
hit = e[(e.action == "proc") & e.obj.str.match(r"(winword|excel|outlook)\.exe>(cmd|powershell|wscript|mshta)\.exe")
& ~e.extra.str.contains("lab-finance-report.cmd", regex=False)]
return [(i, r.user, r.obj) for i, r in hit.iterrows()]
def d4_lsass_read(e, allowed={"MsMpEng.exe": 0x1410}):
hit = e[e.action == "lsass_access"]
out = []
for i, r in hit.iterrows():
mask = int(r.extra, 16)
if mask & 0x10 and not (r.obj in allowed and mask & ~allowed[r.obj] == 0):
out.append((i, r.user, f"{r.obj} {r.extra}"))
return out
def d5_beacon(e, allow={"time.lab.test"}):
q, out = e[e.action == "query"], []
for (host, dom), g in q.groupby(["host", "obj"]):
if dom in allow or len(g) < 50 or q[q.obj == dom].host.nunique() > 2:
continue
gaps = g.time.diff().dt.total_seconds().dropna()
if gaps.std() / gaps.mean() < 0.4:
out.append((g.index[0], g.user.iloc[0], f"{host} -> {dom}: {len(g)} lookups, CV {gaps.std() / gaps.mean():.2f}"))
return out
RULES = {"D1 brute force then success": d1_bruteforce_success, "D2 new country without MFA": d2_new_country_no_mfa,
"D3 office app spawns shell": d3_office_shell, "D4 LSASS memory read": d4_lsass_read, "D5 DNS beaconing": d5_beacon}
# ---------- 3. unit tests on fixtures, then the week ----------
def fx(rows):
return pd.DataFrame([(T0 + pd.Timedelta(minutes=m), *r) for m, *r in rows],
columns=["time", "source", "user", "host", "src", "action", "obj", "extra"]).assign(label="")
FIXTURES = {
"D1 brute force then success": (fx([(k, "auth", "x", "", "192.0.2.9", "fail", "vpn", "") for k in range(5)] + [(6, "auth", "x", "", "192.0.2.9", "ok", "vpn", "VN|mfa")]),
fx([(0, "auth", "x", "", "10.10.0.9", "fail", "vpn", ""), (1, "auth", "x", "", "10.10.0.9", "ok", "vpn", "VN|mfa")])),
"D2 new country without MFA": (fx([(0, "auth", "x", "", "192.0.2.9", "ok", "vpn", "DE|password")]),
fx([(0, "auth", "x", "", "192.0.2.9", "ok", "vpn", "SG|mfa")])),
"D3 office app spawns shell": (fx([(0, "edr", "x", "h", "", "proc", "outlook.exe>mshta.exe", "")]),
fx([(0, "edr", "x", "h", "", "proc", "excel.exe>cmd.exe", "lab-finance-report.cmd")])),
"D4 LSASS memory read": (fx([(0, "edr", "x", "h", "", "lsass_access", "rundll32.exe", "0x1FFFFF")]),
fx([(0, "edr", "x", "h", "", "lsass_access", "MsMpEng.exe", "0x1410"), (1, "edr", "x", "h", "", "lsass_access", "taskmgr.exe", "0x1000")])),
"D5 DNS beaconing": (fx([(k * 5, "dns", "x", "h", "", "query", "c2.example", "") for k in range(60)]),
fx([(k * 5, "dns", "x", "h", "", "query", "time.lab.test", "") for k in range(60)])),
}
print(f"{'detection':28} {'tests':>5} {'alerts':>6} {'TP':>3} {'FP':>3} {'precision':>9}")
caught = set()
for name, rule in RULES.items():
pos, neg = FIXTURES[name]
tests = "pass" if rule(pos) and not rule(neg) else "FAIL"
hits = rule(ev)
tp = sum(ev.label[i] == "attack" for i, *_ in hits)
caught |= {name for i, *_ in hits if ev.label[i] == "attack"}
print(f"{name:28} {tests:>5} {len(hits):6} {tp:3} {len(hits) - tp:3} {(tp / len(hits) if hits else 0):9.0%}")
for i, user, why in hits[:2]:
print(f" {ev.time[i]:%a %H:%M} {user:6} {why}")
print(f"\ndetections that fired on the intrusion: {len(caught)} of {len(RULES)}")2731 events, 3 sources, 453 attack events
detection tests alerts TP FP precision
D1 brute force then success pass 2 1 1 50%
Tue 09:12 u08 6 failures then success from 10.10.0.7
Thu 02:24 u17 6 failures then success from 203.0.113.50
D2 new country without MFA pass 1 1 0 100%
Thu 02:24 u17 sign-in from DE without MFA
D3 office app spawns shell pass 1 1 0 100%
Thu 03:00 u17 winword.exe>powershell.exe
D4 LSASS memory read pass 1 1 0 100%
Thu 03:06 u17 C:\Users\Public\lib.exe 0x1010
D5 DNS beaconing pass 1 1 0 100%
Thu 03:12 u17 ws17 -> upd.cdn-lab.example: 432 lookups, CV 0.11
detections that fired on the intrusion: 5 of 5
All five detections pass their fixtures and fire on the intrusion, in order: at 02:24 on Thursday u17 signs in from 203.0.113.50 after six failures (one from the spray, five aimed at the account), from Germany and without MFA (D1 and D2); at 03:00 Word starts hidden PowerShell on ws17 (D3); at 03:06 a program in C:\Users\Public reads LSASS memory (D4); from 03:12 the host resolves upd.cdn-lab.example 432 times with a CV of 0.11 (D5). Six alerts in total, five true positives. The one false positive is u08's forgotten password on Tuesday, the benign twin of D1's attack pattern. The look-alikes that were planted to trap careless rules (the finance macro, Defender's LSASS reads, the NTP client, the traveller with MFA) produced nothing, because each rule has a narrow filter for them and a negative fixture that proves it.
Step 3: the Sigma rules
The single-event detections translate directly into Sigma (Sigma Rules); the field names below are Sigma's generic ones and reach your SIEM through a field mapping. D1 and D5 need counting over time: Sigma correlation rules, or the SIEM's own language (SIEM Search and Correlation).
title: Office Application Spawns a Shell (D3)
id: 0d6f0d1c-3b8f-4a5e-9f21-1c2e3d4f5a61
status: test
tags: [attack.execution, attack.t1204.002, attack.t1059.001]
logsource: {category: process_creation, product: windows}
detection:
selection:
ParentImage|endswith: ['\winword.exe', '\excel.exe', '\outlook.exe']
Image|endswith: ['\cmd.exe', '\powershell.exe', '\wscript.exe', '\mshta.exe']
filter_finance_macro:
ParentImage|endswith: '\excel.exe'
CommandLine|contains: 'lab-finance-report.cmd'
condition: selection and not filter_finance_macro
level: high
---
title: LSASS Memory Read by Unexpected Process (D4)
id: 6a1e9b74-0c2d-4f3a-8e5b-7d9c0a1b2c33
status: test
tags: [attack.credential-access, attack.t1003.001]
logsource: {category: process_access, product: windows}
detection:
selection:
TargetImage|endswith: '\lsass.exe'
GrantedAccess: ['0x1010', '0x1410', '0x1438', '0x143a', '0x1fffff']
filter_defender:
SourceImage|endswith: '\MsMpEng.exe'
SourceImage|startswith: 'C:\ProgramData\Microsoft\Windows Defender\Platform\'
condition: selection and not filter_defender
level: critical
---
title: Sign-in From a New Country Without MFA (D2)
id: 9c4b2a10-5e6f-4d7a-8b9c-0d1e2f3a4b55
status: test
tags: [attack.initial-access, attack.t1078]
logsource: {category: authentication, product: lab_vpn}
detection:
selection:
outcome: success
filter_home:
country: VN
filter_mfa:
auth_method: mfa
condition: selection and not 1 of filter_*
level: high(Sigma has no generic authentication category with these fields; D2 uses a custom log source for the lab VPN, mapped by your own processing pipeline. D4 lists the masks seen in the lab; the pandas version checks the VM_READ bit instead, which is more robust, and that difference is a finding for the tuning notes.)
D1 and D5, written as Splunk SPL for the SIEM (query snippets, not run here):
D1 index=vpn earliest=-30m
| stats count(eval(action="failure")) AS fails, count(eval(action="success")) AS ok, max(_time) AS last BY user src_ip
| where fails >= 5 AND ok >= 1
D5 index=dns earliest=-24h NOT query IN ("time.lab.test")
| sort 0 host query _time | streamstats current=f last(_time) AS prev BY host query
| eval gap=_time-prev | stats count, avg(gap) AS mean, stdev(gap) AS sd, dc(host) AS hosts BY query host
| eventstats dc(host) AS hosts_per_query BY query
| where count >= 50 AND hosts_per_query <= 2 AND sd/mean < 0.4Step 4: ATT&CK coverage after the sprint
| Tactic | Technique | Detection | Data | Level |
|---|---|---|---|---|
| Credential Access | T1110.003 Password Spraying | none (gap: spray seen only through D1 on the account it cracked) | auth | 1 data |
| Credential Access / Initial Access | T1110.001 Password Guessing, T1078 Valid Accounts | D1, D2 | auth | 3 tested |
| Execution | T1204.002 Malicious File, T1059.001 PowerShell | D3 | EDR process | 3 tested |
| Credential Access | T1003.001 LSASS Memory | D4 | EDR process access | 3 tested |
| Command and Control | T1071.004 / T1071.001 | D5 | DNS | 3 tested |
| Persistence | T1053.005 Scheduled Task | none | EDR process | 1 data |
"Tested" here means fixtures pass and the rule fired on the week's intrusion; before production, each also needs an end-to-end validation in the lab (Testing Detections).
Step 5: tuning notes
Write one entry per false positive and per missed or weak case. For this week:
- D1, u08 on Tuesday (false positive): six failures then success from her office address, a forgotten password. Not tuned by raising the threshold (the attacker needed only six too). Fix: join the identity provider's password-reset events and suppress when a reset for the same user lies between the failures and the success; add the reset case to D1's negative fixtures. Owner: detection engineering; review in 90 days.
- D4 Sigma vs pandas: the Sigma rule lists specific masks; the pandas rule tests the VM_READ bit. Align the Sigma rule (a
|reon the mask or a backend that supports bitwise tests) and add a fixture with an unlisted mask such as0x1418. - D5 and jitter: with CV < 0.4 the rule covers jitter up to roughly ±70 %; heavier jitter needs the rarity and volume signals scored together. Add a variant fixture with ±80 % jitter and decide whether D5 becomes a risk input.
- Gap: the spray itself (12 accounts failing from
203.0.113.50in seven minutes) raised no alert of its own. Next sprint: D6 distinct accounts per source (Brute Force Followed by Success).
Step 6: the one-page SOC report
Use this template; the filled-in parts come from the program's output.
SOC DETECTION SPRINT REPORT lab.test SOC, sprint ending 2026-01-18
Author: detection engineering Audience: SOC lead, CISO (summary), analysts (details)
1. Summary
Five detections built, tested and evaluated on one week of telemetry from 30 workstations.
They detected every stage of Thursday's simulated intrusion (credential guessing, foreign
sign-in without MFA, macro execution, LSASS read, DNS beacon). 6 alerts, 5 true positives,
1 false positive (explained, fix planned).
2. Detections ATT&CK tests alerts TP FP status
D1 brute force then success T1110.001 pass 2 1 1 test -> prod after reset join
D2 new country, no MFA T1078 pass 1 1 0 test -> prod
D3 office app spawns shell T1204.002/T1059.001 pass 1 1 0 test -> prod
D4 LSASS memory read T1003.001 pass 1 1 0 test -> prod (align Sigma)
D5 DNS beaconing T1071.004 pass 1 1 0 test -> prod
3. Coverage change Before: 0 of 6 profile techniques tested. After: 4 of 6 (table attached).
4. Gaps and next sprint Password spraying (D6), scheduled-task persistence; end-to-end lab validation.
5. Risks D1 false positives until the reset join; D5 weak against heavy jitter.
6. Asks Password-reset events from the identity provider into the SIEM (needed by D1).Assessment checklist
| Criterion | Done when |
|---|---|
| Detections | Five rules with id, status, ATT&CK tags, level, owner |
| Tests | Each rule has at least one positive and one negative fixture, all passing; variant fixtures for at least two rules |
| Results | Alerts, TP, FP and precision on the week, with the hidden labels used only for scoring |
| Coverage | A table with levels, honest about what "tested" means and what is missing |
| Tuning | Every FP explained and handled narrowly (no host- or user-wide exclusions) |
| Report | One page, numbers matching the program's output, gaps and asks stated |
| Safety | Only synthetic data; any lab validation done on your own lab with written scope |
Extensions: add D6 (spray) and a scheduled-task detection from A Hunt End to End; move D1–D5 into your Wazuh lab as local rules (A Custom Wazuh Rule) and validate them end to end.
Test yourself
Why are the hidden labels in the dataset used only for scoring, never inside the rules?
- They are too large
- Real telemetry has no labels; a rule that reads them would be cheating and useless in production
- pandas cannot read them
- Sigma forbids labels
D1 fired on u08's forgotten password. What is the recommended fix?
- Raise the threshold to 10 failures
- Join password-reset events and suppress when a reset lies between the failures and the success
- Exclude u08 permanently
- Delete D1
Which part of the intrusion raised no alert of its own?
- The LSASS read
- The password spray across 12 accounts from one source
- The DNS beacon
- The macro