SigmaSeal · an illustrated walkthrough

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. ☕

scroll down, your brain will thank you ↓

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:

🔕 It stays silent
The attack happens, the rule doesn't fire, and you find out in the incident review.
🔔 It never shuts up
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:

THINK ABOUT IT🧠

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

🛡️guardrails.pyquarantines prompt injection, redacts secretstrusts the LLM? nope
🤖agent.pythe LLM: drafts a Sigma rule, tests it, revisesit IS the LLM
🔁Replay sandboxruns the rule on dev eventstrusts it? nope
⚖️gate.pygrades on held-out events it never sawtrusts it? nope
🧑‍💻A humansigns off on a gate-signed (HMAC) bundletrusts it? nope

watch the orange dot: advisory → guardrails → agent ⟲ replay → gate → human

Notice anything? Only one box in the system trusts the LLM… and it's the LLM.

Chapter 1The rule that looked perfect

A real early run. The advisory (AWS iam:PassRole + Lambda backdoor) said:

"…over-privileged execution roles such as 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.

WATCH IT!⚠️

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.

GRAB A PENCIL✏️

Which of these catches the attack nobody has shown you yet?

  1. roleArn|re: '.*(admin|poweruser).*'
  2. roleArn|contains: 'admin'
  3. Alert on every PassRole-to-Lambda except from the CI/CD role the advisory calls legitimate.
tap for the answer (no peeking!)
3. "Such as" introduces examples, not a complete list. What the advisory really defines is the legitimacy boundary, so alert on everything outside it. Options 1 and 2 only catch roles someone already wrote down.

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.

NO SILLY QUESTIONS
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

WATCH IT!⚠️

"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

📝 Single-ShotI'm one API call. Give me the schema, existing rules and some benign samples, and with gpt-4.1 I passed 14 of 25.
🤖 The AgentAnd I passed 17.
📝 Single-ShotWith 25 runs each, 17 vs 14 is a coin flip with extra steps. p ≈ 0.56. And I did it in one call, no loop.
🤖 The AgentFine. Put us both on the small model. You got 10 of 75, even with a compile-fix retry. I got 40 of 75.
📝 Single-Shot…
🤖 The AgentThat's p < 0.001. On a small model, checking your own work isn't a luxury. It's the whole game.
📝 Single-ShotShell command lines, though.
🤖 The Agent…we don't talk about shell command lines. (1 in 15)

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

Naive prompt
0/75
+ context
7/75
+ compile-fix retry
10/75
Agent loop
40/75

p < 0.001. a real gap ✓

gpt-4.1 · held-out v4 · 25 runs per arm

Naive prompt
2/25
+ context
14/25
+ compile-fix retry
12/25
Agent loop
17/25

17 vs 14? could easily be noise (p ≈ 0.56)

What this says
• 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.
What it doesn't say
• 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

📌

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.