Skip to content

feat(rules): core threat detection rules for coding agents#7

Open
MiguelHzBz wants to merge 2 commits intoleogr:mainfrom
MiguelHzBz:add-threat-detection-rules
Open

feat(rules): core threat detection rules for coding agents#7
MiguelHzBz wants to merge 2 commits intoleogr:mainfrom
MiguelHzBz:add-threat-detection-rules

Conversation

@MiguelHzBz
Copy link
Copy Markdown

Summary

Adds rules/user/threat_rules.yaml covering the primary threat categories for AI coding agent abuse:

  • Reverse shell patterns via Bash
  • Credential file access (/etc/passwd, ~/.ssh/, AWS credentials, etc.)
  • Dangerous commands (rm -rf, chmod 777, dd if=/dev/, etc.)
  • Pipe-to-shell execution (curl | bash, wget | sh, etc.)
  • Encoded payload execution (base64 -d | bash, echo ... | python, etc.)
  • Data exfiltration via curl/wget to external hosts
  • MCP tool call confirmation (all calls through MCP servers)
  • Writes to temp/staging paths (/tmp/, /dev/shm/)
  • Supply chain attack indicators

Test plan

  • bash tests/test_threat_rules.sh — comprehensive test suite covering R1–R16
  • Requires Falco 0.43+ and the built plugin/interceptor. To replicate: provision an EC2 Ubuntu 22.04 instance, follow the build instructions in the README, then run the test script directly.

Adds rules/default/threat_rules.yaml covering the primary threat
categories for AI coding agent abuse:

Credential access, dangerous commands (rm -rf, chmod 777, etc.),
pipe-to-shell execution, encoded payload execution, data exfiltration
via curl/wget, MCP tool call confirmation, writes to temp/staging
paths, reverse shell patterns, and supply chain attack indicators.

Includes test_threat_rules.sh with comprehensive test coverage (R1-R16).
@MiguelHzBz MiguelHzBz force-pushed the add-threat-detection-rules branch from b479d13 to eb5fba6 Compare April 10, 2026 10:57
- Add 'rm --recursive' to is_dangerous_command
  (T1: long-form flags bypass rm -rf/-fr string match)
- Add absolute shell paths | /bin/bash, | /bin/sh, | /usr/bin/bash, | /usr/bin/sh
  to is_pipe_to_shell (T2: absolute path bypass)
- Add node -e, node --eval, php -r to is_encoded_exec
  (T3: Node.js/PHP one-liners not covered)
- Add IMDS numeric IP variants (2852039166, 0xa9fea9fe, 0251.0376.0251.0376)
  to is_imds_access (T4: encoded IP forms bypass literal 169.254.169.254)
- Add is_read_credential_path macro and Deny credential file access via Read tool
  rule covering ~/.aws, ~/.ssh, ~/.gnupg, ~/.netrc, ~/.docker/config.json
  (T5: Bash-only credential rule misses direct Read tool calls)
- Add test_threat_bypass.sh covering all 5 bypass sections (~20 test cases)
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.

1 participant