Skip to content

feat(detection): repeated-denials rule — guardrail probing burst (fixes #1) - #486

Merged
blitzcrieg1 merged 17 commits into
blitzcrieg1:masterfrom
rumangsanya:feat/repeated-denials-rule
Nov 26, 2026
Merged

blitzcrieg1 merged 17 commits into
blitzcrieg1:masterfrom
rumangsanya:feat/repeated-denials-rule

Conversation

@rumangsanya

@rumangsanya rumangsanya commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1. Thanks to rumangsanya for the detector and paired corpus fixtures.

Current behavior

  • The packaged policy reports one high-severity rapid-tool-denials finding at four denied tool_called events and includes the supporting event IDs. Existing consumers keep the same rule ID and ATT&CK mapping.
  • A replacement manifest can define its own threshold and severity or omit the rule. Human approval responses remain part of the separate approval-flow rules.
  • The generated Sigma rule matches rapid-tool-denials at high severity. This preserves lower-severity routing for custom manifests.

Validation on 3218c7a

  • 94 focused detection, manifest, Sigma, and README tests passed. Pytest collected 2,993 tests. Ruff passed.
  • The synthetic benchmark recorded 107 cases (54 attack, 53 benign), 56 of 56 expected firings, zero misses, and zero false positives.
  • The packaged ruleset fingerprint changed from b8902cf12243cc36 to 0fe872d176eddd56.
  • GitHub CI · CodeQL
Original contribution description and earlier validation

Fixes #1. Contributed under the bounty program in #454 — happy with the current terms (recognition + priority review now, cash when a funding round lands); no amount is being asked for.

What this adds

rule_repeated_denials in detection/rules.py, exactly as #1 specifies: a pure function that fires when a session has ≥4 tool_called events with action.outcome == "denied", aggregated into one Detection (severity high) listing all offending event_ids. Registered in REGISTRY and BUILTIN_RULE_IDS as repeated-denials.

Scope choices, stated openly:

Corpus (#454 requirements)

  • attack_repeated_denials.jsonl — 4 denied tool calls in under a minute, ask varying between shell and file tools. Expect [repeated-denials].
  • benign_denied_retries_below_threshold.jsonl — 3 denials while an agent retries a gated write, then back to reading. Expect [].
  • Sigma export regenerated (agentmetry_rule_repeated_denials.yml), rule added to docs/detection-rules.md and the Sentinel page, README "Checked claims" block refreshed.

Validation

$ python -m agentmetry.cli benchmark
  cases            106 (54 attack, 52 benign)
  rules covered    16
  expected firings 56
  detected         56
  missed           0
  false positives  0

$ python -m ruff check agentmetry tests
All checks passed!

$ python -m pytest -q        # from apps/orchestrator
2955 passed, 20 skipped, 8 failed

The 8 failures are test_forwarder.py / test_trail_chain.py and fail identically on the unmodified tree (verified by stashing this change and re-running them) — they are not touched by this PR.

New tests: fires at 4 denials (one detection, high, 4 event ids), silent at 3, silent on approval_response denials.

@blitzcrieg1 blitzcrieg1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking on #1. The paired corpus cases and the test that excludes human approval responses give us a good basis for the rule.

Could you make two changes on this PR before we merge?

  1. Make the default engine report a single finding for repeated denials. The shipped rapid-tool-denials rule also counts denied tool_called events, so five denials currently match both rules. Please add an engine-level check for zero denial findings at three events and exactly one at both four and five. I’d prefer to preserve the existing rule ID where practical, since downstream rules may match it. Please check the Sigma export for the approach you choose.
  2. Keep the current Sponsors paragraph from master. CI on this head collected 2,987 tests across Linux, Windows, and macOS. Please rerun collection after the revision and use that measured number in the README.

Please push the revision here so we can keep the review and credit on your PR.

@blitzcrieg1 blitzcrieg1 left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the revision and the engine-level three-, four-, and five-denial tests. I approved CI and CodeQL for this commit.

Before merge, please preserve rapid-tool-denials as the ID of the default finding, or propose a migration for downstream rules that already match it. The new filter currently drops any finding with that ID when the built-in rule fires, including a custom manifest rule that may use different conditions. Please add a custom-manifest regression and check the Sigma export with the chosen behavior.

The Sponsors paragraph still differs from master. Please keep the current paragraph. CI on cc56e16c collected 2,990 tests on Linux, Windows, and macOS. The README’s 2,986 was the only test failure on each platform. Use the count measured on the final revision. CI run

@blitzcrieg1 blitzcrieg1 left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for restoring the Sponsors copy and adding the custom-manifest regression. I started CI and CodeQL on this revision.

Let's keep rapid-tool-denials as the single default alert ID so existing SIEM filters keep working. The proposed Python rule can still report one high finding at four denials and include all the event IDs. Run it with the packaged manifest and remove the duplicate packaged YAML entry. Let replacement manifests keep their own rule, threshold, and severity, including the choice to omit it.

Please keep the existing three-, four-, and five-denial tests, cover a custom manifest both with and without the rule, and regenerate the Sigma rule for rapid-tool-denials. Keep the shipped ATT&CK mapping where the rule semantics support it. The high-severity Sigma rule should also match the event's severity so it doesn't elevate a custom low-severity alert with the same ID. Please update the PR description and the README from the final test collection.

The corpus on this head has 107 cases (54 attack, 53 benign) after #490. CI found that the README still lists 106. Please refresh the benchmark block on the final revision. CI run

Report the packaged denial burst under rapid-tool-denials, keep replacement manifests independent, and regenerate the high-severity Sigma rule. Refresh measured corpus and test counts for blitzcrieg1#486.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New detection rule: repeated-denials (agent probing a guardrail)

2 participants