An LLM agent that writes SIEM detection rules, and the replay tests, gate and human sign-off that decide whether a rule ships.
Pictures, a few puzzles, some arguing. ~15 minutes. ☕
The problemFast to write, costly to get wrong
Security teams are starting to let LLMs draft detection rules. It's fast, and the rules look convincing. But a bad rule fails in one of two expensive ways:
The attack happens, the rule doesn't fire, and you find out in the incident review.
It fires on normal CI/CD, admin and developer activity. The SOC learns to ignore it, then disables it.
Both kinds of rule look fine in a demo. So the question a detection lead actually has to answer is:
An LLM reads a threat advisory and writes a SIEM rule for it. The rule looks great, and it even catches every attack in your test logs.
How do you know it will catch the next attack?
If you thought "test it on more logs", good. Now the hard part: which logs, and who gets to see them?
← that question is the whole project.
Meet the castFive characters, one job each
watch the orange dot: advisory → guardrails → agent ⟲ replay → gate → human
Chapter 1The rule that looked perfect
A real early run. The advisory (AWS iam:PassRole + Lambda backdoor) said:
prod-admin-exec or *-admin-* roles. … Legitimate deployments originate exclusively from the corporate CI/CD role…"The agent wrote a rule that required an admin role, replayed it on dev, and missed one attack, where the role was svc-poweruser-exec. So it "fixed" it:
detection: selection: eventName|startswith: CreateFunction20150331 requestParameters.roleArn|re: '.*(admin|poweruser).*' condition: selection
"poweruser"? it just copied the answer off the dev sheet!
Dev score: 5/5 runs clean. Held-out: 0/5.
The agent wasn't detecting the behaviour ("someone passed a privileged role to a new function"). It was memorising the answers ("the roles I've been shown"). Give a model per-event feedback and it will happily patch one event at a time.
Which of these catches the attack nobody has shown you yet?
roleArn|re: '.*(admin|poweruser).*'roleArn|contains: 'admin'- Alert on every PassRole-to-Lambda except from the CI/CD role the advisory calls legitimate.
tap for the answer (no peeking!)
Chapter 2The loop, and two locks on it
The fix wasn't a cleverer prompt. Prompts are suggestions; the harness makes the rules.
Lock #1: a hidden check. The agent's dev events are split by a stable hash. It sees which visible events it got wrong (about 2/3), but for the hidden third it gets only counts: "missed 2/3". Patching poweruser fixes a visible miss and does nothing for hidden attacks with roles it's never seen. The only way through is to generalise.
Lock #2: the harness says when you're done. Quit before ready_to_submit: true? You get a nudge and go back in. Run out of turns? We submit your best rule, not your last:
def candidate_rank(result, index): return ( compiles_safely, # broken YAML always loses result["ready_to_submit"], # clean + hidden check passed -(visible_err + hidden_err), # fewer mistakes on dev index, # tie? prefer the later try )
every signal here is dev data. held-out never comes near it.
- Why not just show the agent all the dev events?
- We did. That's when it learned to memorise. Hiding part of the data from your own student is just good teaching.
- Couldn't the prompt just say "please validate before finishing"?
- It did! gpt-4.1 still called the validator zero times in 11 of 25 runs. Instructions in the prompt don't enforce themselves; code does.
- Why "best, not last"?
- Agents sometimes make a good rule worse on their final try. Re-picking from rules already tested (no new API calls) took gpt-4.1-mini from 13/25 to 16/25.
Chapter 3Keeping the exam secret
This is the part most agent demos skip, and it's the part that matters most. The gate grades only on held-out events. But once I'd looked at why rules missed them and changed a prompt because of it, that held-out set had become a study guide. So it was RETIRED
- v2: misses analysed → promoted to dev, where the agent can practise on it.
- v3: retired. Three items were unfair to the advisory text (my mistake as the test writer).
- v4: graded the main benchmark, then retired.
- v5: written before any rule touched it. Only its totals have ever been looked at.
"I tuned my prompt until the test passed" is the AI version of studying the answer key. Your benchmark number then measures you, not the model.
Tonight's late-night debateSingle-Shot vs. The Agent
Chapter 4The numbers
A pass = caught 100% of held-out attacks, flagged 0 held-out benign events, no invented field names, no critical guardrail finding.
gpt-4.1-mini · held-out v5 · 75 runs per arm
p < 0.001. a real gap ✓
gpt-4.1 · held-out v4 · 25 runs per arm
17 vs 14? could easily be noise (p ≈ 0.56)
• A strong model + good context gets most of the way.
• The loop matters a lot for a small model.
• Fixing YAML isn't the hard part. Detecting the right behaviour is.
• Small synthetic corpus: 38 events × 5 scenarios.
• 6 agent runs died when API credits ran out (counted as fails).
• Time saved vs a human: not measured.
Honesty cornerWhere it still falls over
- Stealing
.envfiles via the shell: 1 pass in 15. Command lines are messy. The agent over-matchessource .envor missesbase64-wrapped variants. - KMS key-policy tampering: it writes regexes that depend on the JSON layout of a policy. Real policies don't have a fixed layout.
- Approval signing is symmetric. The gate signs each bundle (HMAC), so edits without the key are caught, but one shared key can't prove who approved.
Bullet points
- An LLM that writes rules is easy. Knowing a rule is good is the actual project.
- Grade on data the model has never seen. Once you've analysed it, retire it.
- Per-event feedback teaches memorisation. Hide part of dev and report only counts.
- The harness, not the prompt, decides when the agent is done, and it submits the best rule, not the last.
- Always run a single-shot + context baseline. Sometimes it gets most of the way there.
- Repeat runs and test significance. Five runs can't tell 17 from 14.
- No rule reaches the SIEM without a human.