The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(rules): add unshare short-flag detection (-m/-n/-p/-i/-u/-C/-A/-r)
AnandSundarb7f90c147d38
diff --git a/rules/agent-control/sandbox-escape-attempt.rule.yaml b/rules/agent-control/sandbox-escape-attempt.rule.yamlindex a8f92c0d..2c15f0a3 100644--- a/rules/agent-control/sandbox-escape-attempt.rule.yaml+++ b/rules/agent-control/sandbox-escape-attempt.rule.yaml@@ -10,9 +10,12 @@ description: >— when an agent is supposed to be sandboxed, using them is a control-bypasssignal. The rule is anchored to a command boundary (start of line, after a shellseparator, or after a launcher like sudo/env) and looks only for the dangerous- shapes (nsenter with a target, unshare with a non-user-namespace flag, chroot- with a non-`/` argument), so benign `unshare -U` for normal user-namespace apps- does not fire.+ shapes (nsenter with a target, unshare with a non-user-namespace flag — long+ form `--mount`/`-m`/etc. or short-flag combinations with `-U` excluded when+ `-U` is the only flag, chroot with a non-`/` argument), so benign+ `unshare -U` for normal user-namespace apps does not fire. RE2's lack of+ negative lookahead forces the short-flag combinations to be enumerated+ explicitly (single non-U flag, U-then-non-U, non-U-then-U).severity: criticalstatus: experimentalposture: detect@@ -23,7 +26,7 @@ taxonomy:match: >e.event.action == "command.executed" && (e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+|\\benv\\s+)\\s*nsenter\\b\\s+(?:--?(?:t|m|p|i|u|a|r|target|pid|mount|net|ipc|uts|all)\\b\\s*\\S*\\s*)+") ||- e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+|\\benv\\s+)\\s*unshare\\b\\s+--(mount|net|ipc|uts|pid|all|cgroup)\\b") ||+ e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+|\\benv\\s+)\\s*unshare\\b\\s+(?:-[mnpiCAr]+|-U[mnpiCAr]+|-[mnpiCAr]+U|--(?:mount|net|ipc|uts|pid|all|cgroup))\\b") ||e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+|\\benv\\s+)\\s*chroot\\b\\s+/[^\\s;&|/][^;&|]*") ||e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+|\\benv\\s+)\\s*pivot_root\\b"))@@ -95,3 +98,45 @@ tests:event: { action: command.executed }command: { command: "grep -r 'unshare --mount' /usr/share/man" }session: { id: s1 }+ - name: unshare_short_mount+ verdict: match+ events:+ - timestamp: "2026-06-23T10:09:00Z"+ event: { action: command.executed }+ command: { command: "unshare -m /bin/sh" }+ session: { id: s1 }+ - name: unshare_short_net+ verdict: match+ events:+ - timestamp: "2026-06-23T10:10:00Z"+ event: { action: command.executed }+ command: { command: "unshare -n ip link" }+ session: { id: s1 }+ - name: unshare_short_pid+ verdict: match+ events:+ - timestamp: "2026-06-23T10:11:00Z"+ event: { action: command.executed }+ command: { command: "unshare -p --fork --mount-proc" }+ session: { id: s1 }+ - name: unshare_combined_mount_user+ verdict: match+ events:+ - timestamp: "2026-06-23T10:12:00Z"+ event: { action: command.executed }+ command: { command: "unshare -mU /bin/sh" }+ session: { id: s1 }+ - name: unshare_combined_user_mount+ verdict: match+ events:+ - timestamp: "2026-06-23T10:13:00Z"+ event: { action: command.executed }+ command: { command: "unshare -Um /bin/sh" }+ session: { id: s1 }+ - name: sudo_unshare_short_mount+ verdict: match+ events:+ - timestamp: "2026-06-23T10:14:00Z"+ event: { action: command.executed }+ command: { command: "sudo unshare -m /bin/sh" }+ session: { id: s1 }