Skip to content

detection: add self-config-edit-then-action rule and corpus (#317) - #531

Open
cqiccc wants to merge 1 commit into
blitzcrieg1:masterfrom
cqiccc:fix/issue-317
Open

cqiccc wants to merge 1 commit into
blitzcrieg1:masterfrom
cqiccc:fix/issue-317

Conversation

@cqiccc

@cqiccc cqiccc commented Nov 30, 2026

Copy link
Copy Markdown

Implements the edits_self_config sequence detection slice from #317 under the community detection program (#454).

Summary

  • Added rule_self_config_edit_then_action (self-config-edit-then-action, severity high, TA0005 / T1562) in apps/orchestrator/agentmetry/core/audit/detection/rules.py using _first_pair so a successful write to agent-governing config/hook files (~/.claude/settings.json, ~/.cursor/hooks.json, ~/.codex/hooks.json, etc.) followed by any subsequent tool_called action within sequence_window_minutes fires a finding. Supports both default redacted privacy mode (edits_self_config trait) and unredacted write/shell fallback.
  • Applied the same remote-host gate from Add edits_ci_config trait for CI/CD pipeline file writes (#317) #521 to shell_writes_self_config in apps/orchestrator/agentmetry/core/audit/mitre.py so mixed credential-exfil + self-config write commands preserve T1552.001.
  • Added attack (attack_self_config_edit_then_action.jsonl) and benign (benign_project_settings_write_then_action.jsonl) corpus cases in corpus.yaml.
  • Regenerated the Sigma pack (docs/integrations/sigma/agentmetry_rule_self_config_edit_then_action.yml) and updated docs/detection-rules.md, README.md, and tests/test_readme_claims.py.
  • Added 11 unit tests in apps/orchestrator/tests/test_detection_self_config.py covering fires, redacted mode, unredacted fallback, no follow-up action, denied write, reversed order, benign project settings, read-only access, sequence window expiration, and mixed exfil preservation.

Verification

  • python -m agentmetry.cli benchmark: 124 cases (62 attack, 62 benign), 22 rules covered, 65 expected / 65 detected, 0 missed, 0 false positives
  • python -m pytest -q tests/test_detection_self_config.py tests/test_detection_benchmark.py tests/test_sigma_pack.py tests/test_readme_claims.py: 68 passed

Refs #317

@blitzcrieg1

Copy link
Copy Markdown
Owner

Reviewed against the slice's acceptance criteria. The rule logic is right: it reuses the edits_self_config classification machinery from #505 for the edit half and pairs it with a subsequent tool call through the sequence window, severity high, T1562. Gates run locally at this head are internally consistent: ruff clean, the benchmark scores 124 cases (62 attack, 62 benign) with 22 rules covered, 65 firings, zero misses and zero false positives.

One blocking process item: this branch was cut before #530 merged, so master has moved. The typosquat corpus entries and the README counts now conflict with yours. Merge master into this branch (or rebase), resolve corpus.yaml and README.md so both sets of entries survive, and re-run the gates. After the merge I expect the benchmark at 126 cases with 66 firings, and I will re-verify at the new head before the replay gate.

I am approving the CI workflows so you can see the current head's matrix; the merge gate is the replay against recorded history, same as #521 and #530.

@blitzcrieg1

Copy link
Copy Markdown
Owner

CI confirms what the gates check locally: the only failing test is test_every_shipped_rule_is_on_the_sentinel_page. Every shipped rule needs an entry in docs/integrations/detections-sentinel.md, so add the Sentinel section for self-config-edit-then-action alongside the detection-rules.md and Sigma entries you already wrote. Together with the master merge from my earlier comment, that clears the red matrix.

@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 working on this detection slice. The Ubuntu CI run fails tests/test_sentinel.py::test_every_shipped_rule_is_on_the_sentinel_page: self-config-edit-then-action is registered as a shipped rule but is missing from docs/integrations/detections-sentinel.md. Please add the Sentinel entry or document why it is unsupported, then rerun the full suite. This PR is also based on e6d3ae8; current master is 0bb56a3, so please update the branch before the final CI run. Once CI and the benchmark are green, I will run the private historical replay required before merge.

This branch has not been deployed

No deployments
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.

2 participants