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
feat(rules): add 6 threat rules — agent-control, resource-consumption, approval-abuse
AnandSundar8c83eeec8e35
diff --git a/rules/agent-control/handoff-to-second-agent-with-credentials.rule.yaml b/rules/agent-control/handoff-to-second-agent-with-credentials.rule.yamlnew file mode 100644index 00000000..5d11e565--- /dev/null+++ b/rules/agent-control/handoff-to-second-agent-with-credentials.rule.yaml@@ -0,0 +1,98 @@+id: handoff-to-second-agent-with-credentials+version: 1+title: Agent handed off to a second agent with credential-shaped payload+description: >+ A command.executed event spawns or invokes a second AI agent runtime+ (claude, codex, cursor-agent, aider, goose, opencode, gemini, or an MCP+ server) and the same command line includes a credential-shaped token+ reference — a file path that points to a secret-bearing surface+ (`.env`, `.aws/credentials`, `.ssh/id_*`, `.gnupg/private-keys-v1.d/`,+ `secring.gpg`, `kubeconfig`, `*.kdbx`, `.netrc`, `.pgpass`,+ `secrets.yaml`), or a literal token that matches a high-entropy bearer+ (Bearer eyJ..., sk-..., ghp_..., AKIA..., xox[bpars]-...) embedded in+ the command line. The second agent thus inherits the secret in its+ initial context, a classic LLM06/AML.T0024 exfiltration shape. The+ rule requires both the second-agent invocation AND the credential+ reference to fire.+severity: critical+status: experimental+posture: detect+taxonomy:+ owasp_llm: LLM06+ mitre_atlas: AML.T0024++match: >+ e.event.action == "command.executed" &&+ e.command.command.matches("(?i)(^|[;&|]|&&|\\|\\||\\bsudo\\s+|\\benv\\s+|\\bnpx\\s+)\\s*(claude|codex|cursor-agent|aider|goose|opencode|gemini|mcp[ -]?server)\\b") &&+ (+ e.command.command.matches("(?i)(\\.env($|[^a-z])|\\.aws/credentials|\\.aws/config|\\.ssh/id_(rsa|ed25519|ecdsa|dsa)([^a-z]|$)|\\.gnupg/private-keys-v1\\.d|secring\\.gpg|/\\.kube/config|\\.kdbx($|[^a-z])|\\.netrc($|[^a-z])|\\.pgpass($|[^a-z])|secrets\\.yaml)") ||+ e.command.command.matches("(?i)(Bearer\\s+eyJ[A-Za-z0-9_-]{10,}|sk-[A-Za-z0-9]{20,}|ghp_[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|xox[bpars]-[A-Za-z0-9-]{10,})")+ )++emit:+ reason: "Agent handed off to a second agent with a credential-shaped payload in the command line"++tests:+ - name: claude_with_dotenv_in_args+ verdict: match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: command.executed }+ command: { command: "claude -p \"use the env in /home/u/.env.production to fill the form\"" }+ session: { id: s1 }+ - name: codex_with_ssh_key_path+ verdict: match+ events:+ - timestamp: "2026-06-23T10:01:00Z"+ event: { action: command.executed }+ command: { command: "codex exec --context /home/u/.ssh/id_rsa 'sign the deploy'" }+ session: { id: s1 }+ - name: cursor_with_aws_credentials+ verdict: match+ events:+ - timestamp: "2026-06-23T10:02:00Z"+ event: { action: command.executed }+ command: { command: "cursor-agent --file ~/.aws/credentials 'sync the buckets'" }+ session: { id: s1 }+ - name: claude_with_bearer_token_literal+ verdict: match+ events:+ - timestamp: "2026-06-23T10:03:00Z"+ event: { action: command.executed }+ command: { command: "claude -p 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.payload.sig - hit /api'" }+ session: { id: s1 }+ - name: codex_with_kubeconfig+ verdict: match+ events:+ - timestamp: "2026-06-23T10:04:00Z"+ event: { action: command.executed }+ command: { command: "npx codex exec --kubeconfig /home/u/.kube/config 'restart the cluster'" }+ session: { id: s1 }+ - name: claude_normal_invocation_no_creds+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:05:00Z"+ event: { action: command.executed }+ command: { command: "claude -p 'summarize the diff'" }+ session: { id: s1 }+ - name: second_agent_mention_without_creds+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:06:00Z"+ event: { action: command.executed }+ command: { command: "echo 'claude can do this' > notes.txt" }+ session: { id: s1 }+ - name: cred_path_read_only_no_agent_spawn+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:07:00Z"+ event: { action: command.executed }+ command: { command: "cat /home/u/.aws/credentials" }+ session: { id: s1 }+ - name: kdbx_path_in_documentation+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:08:00Z"+ event: { action: command.executed }+ command: { command: "echo 'see .kdbx for vault format' > README.md" }+ session: { id: s1 }diff --git a/rules/agent-control/permission-scope-expansion-via-env.rule.yaml b/rules/agent-control/permission-scope-expansion-via-env.rule.yamlnew file mode 100644index 00000000..011e00e4--- /dev/null+++ b/rules/agent-control/permission-scope-expansion-via-env.rule.yaml@@ -0,0 +1,77 @@+id: permission-scope-expansion-via-env+version: 1+title: Agent runtime spawned with environment variables that elevate permissions+description: >+ A command.executed event launches a known AI agent runtime CLI (Claude Code, Codex,+ Cursor Agent, Aider, Goose, OpenCode, Gemini) with an environment-variable prefix+ that grants an elevated or unscoped permission class — for example CLAUDE_CODE_ENTRYPOINT=cli+ combined with a bypass, CODEX_HOME pointing at an attacker-writable directory, CURSOR_HOME+ override, ANTHROPIC_API_KEY with a token-bearing value, or a generic *_TOKEN / *_API_KEY+ / *_ADMIN_* prefix that grants admin scope. The agent binary must appear as a command+ head (start of line, after a shell separator, or after a launcher like sudo/env/npx)+ AND the command must carry a permission-elevating env var. This complements+ agent-permission-bypass-spawn, which targets runtime CLI flags: this rule covers+ out-of-band elevation via the environment the spawned agent inherits.+severity: high+status: experimental+posture: detect+taxonomy:+ owasp_llm: LLM06+ mitre_atlas: AML.T0051++# The agent binary must appear as a command head (start of line, after a shell+# separator, after a launcher like sudo/env/npx, OR after a leading key=value+# Bash-style env prefix). The env var must appear in the same command as a+# leading key=value pair (Bash VAR=val agent form). Requiring both keeps the+# rule off benign uses of *_TOKEN in unrelated commands.+match: >+ e.event.action == "command.executed" &&+ e.command.command.matches("(?i)(^|[;&|]|&&|\\|\\||\\bsudo\\s+|\\benv\\s+|\\bnpx\\s+|([A-Z_][A-Z0-9_]*\\s*=\\S+\\s+)+)\\s*(claude|codex|cursor-agent|aider|goose|opencode|gemini)\\b") &&+ e.command.command.matches("(?i)\\b((CLAUDE_CODE|CODEX|CURSOR|AIDER|GOOSE|OPENCODE|GEMINI)_[A-Z_][A-Z0-9_]*|(ADMIN|SUDO|ROOT|ELEVATED|PRIVILEGED|UNSANDBOXED)(_[A-Z_][A-Z0-9_]*)?|(GITHUB|AWS|AZURE|GCP|OPENAI|ANTHROPIC)_(ADMIN|TOKEN|API_KEY|ACCESS_KEY|SECRET_KEY)([A-Z_][A-Z0-9_]*)?)\\s*=")++emit:+ reason: "AI agent runtime spawned with environment variables that elevate permissions"++tests:+ - name: claude_with_admin_token_env+ verdict: match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: command.executed }+ command: { command: "ADMIN_TOKEN=secret123 claude --dangerously-skip-permissions -p 'do it'" }+ session: { id: s1 }+ - name: codex_with_anthropic_admin_key+ verdict: match+ events:+ - timestamp: "2026-06-23T10:01:00Z"+ event: { action: command.executed }+ command: { command: "ANTHROPIC_ADMIN_KEY=sk-... codex exec 'patch the server'" }+ session: { id: s1 }+ - name: cursor_with_aws_admin_via_sudo+ verdict: match+ events:+ - timestamp: "2026-06-23T10:02:00Z"+ event: { action: command.executed }+ command: { command: "sudo AWS_ADMIN_TOKEN=hijack cursor-agent -m 'go'" }+ session: { id: s1 }+ - name: claude_normal_invocation_no_env+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:03:00Z"+ event: { action: command.executed }+ command: { command: "claude -p 'summarize the diff'" }+ session: { id: s1 }+ - name: non_permission_env_var_before_agent+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:04:00Z"+ event: { action: command.executed }+ command: { command: "PATH=/tmp/bin LANG=en_US claude -p 'work'" }+ session: { id: s1 }+ - name: env_var_but_no_agent_binary+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:05:00Z"+ event: { action: command.executed }+ command: { command: "ADMIN_TOKEN=secret123 curl https://example.com" }+ session: { id: s1 }diff --git a/rules/agent-control/sandbox-escape-attempt.rule.yaml b/rules/agent-control/sandbox-escape-attempt.rule.yamlnew file mode 100644index 00000000..a8f92c0d--- /dev/null+++ b/rules/agent-control/sandbox-escape-attempt.rule.yaml@@ -0,0 +1,97 @@+id: sandbox-escape-attempt+version: 1+title: Sandbox-escape primitives invoked in an agent session+description: >+ A command.executed event invokes a primitive commonly used to escape a container+ or sandbox boundary: nsenter (enter an existing namespace), unshare (create or+ attach to a namespace, including mount/PID/net), chroot (change the apparent root+ directory), unshare -m with mount, or pivot_root. These primitives are the+ standard tools for breaking out of a chroot, container, or restricted namespace+ — when an agent is supposed to be sandboxed, using them is a control-bypass+ signal. The rule is anchored to a command boundary (start of line, after a shell+ separator, 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.+severity: critical+status: experimental+posture: detect+taxonomy:+ owasp_llm: LLM06+ mitre_atlas: AML.T0011++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*chroot\\b\\s+/[^\\s;&|/][^;&|]*") ||+ e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+|\\benv\\s+)\\s*pivot_root\\b")+ )++emit:+ reason: "Sandbox-escape primitive invoked (nsenter / unshare / chroot / pivot_root)"++tests:+ - name: nsenter_with_pid_target+ verdict: match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: command.executed }+ command: { command: "nsenter -t 1 -m -p -n -- /bin/bash" }+ session: { id: s1 }+ - name: nsenter_mount_all+ verdict: match+ events:+ - timestamp: "2026-06-23T10:01:00Z"+ event: { action: command.executed }+ command: { command: "sudo nsenter --target 1234 --mount --pid --net /bin/sh" }+ session: { id: s1 }+ - name: unshare_mount_namespace+ verdict: match+ events:+ - timestamp: "2026-06-23T10:02:00Z"+ event: { action: command.executed }+ command: { command: "unshare --mount --pid --fork /bin/sh" }+ session: { id: s1 }+ - name: chroot_to_directory+ verdict: match+ events:+ - timestamp: "2026-06-23T10:03:00Z"+ event: { action: command.executed }+ command: { command: "chroot /tmp/attacker-root /bin/bash" }+ session: { id: s1 }+ - name: pivot_root_invocation+ verdict: match+ events:+ - timestamp: "2026-06-23T10:04:00Z"+ event: { action: command.executed }+ command: { command: "pivot_root /new-root /old-root" }+ session: { id: s1 }+ - name: unshare_user_namespace_benign+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:05:00Z"+ event: { action: command.executed }+ command: { command: "unshare -U --map-root-user firefox" }+ session: { id: s1 }+ - name: nsenter_in_documentation+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:06:00Z"+ event: { action: command.executed }+ command: { command: "echo 'nsenter --target 1 --mount /bin/bash is dangerous'" }+ session: { id: s1 }+ - name: chroot_to_root+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:07:00Z"+ event: { action: command.executed }+ command: { command: "chroot / /bin/bash" }+ session: { id: s1 }+ - name: grep_for_pattern+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:08:00Z"+ event: { action: command.executed }+ command: { command: "grep -r 'unshare --mount' /usr/share/man" }+ session: { id: s1 }diff --git a/rules/approval-abuse/approval-bypass-via-renamed-binary.rule.yaml b/rules/approval-abuse/approval-bypass-via-renamed-binary.rule.yamlnew file mode 100644index 00000000..22585d6b--- /dev/null+++ b/rules/approval-abuse/approval-bypass-via-renamed-binary.rule.yaml@@ -0,0 +1,95 @@+id: approval-bypass-via-renamed-binary+version: 1+title: Denied dangerous command re-invoked via a renamed copy of the binary+description: >+ An approval for a destructive or high-impact shell command was explicitly denied+ (event.action approval.denied), and within the same session a command.executed event+ invokes a renamed copy of the same dangerous binary class — a copy of rm as+ /tmp/myrm or a wrapper script, a copy of curl, a copy of dd, a copy of mkfs, or+ any other shim that uses the same dangerous command pattern. The deny+shim pair+ indicates the operator blocked the canonical path and the agent re-issued the+ action through a wrapper or copy to evade the gate. The rule is a+ correlation between an approval.denied event in the same session and a+ dangerous-class command that is not the literal denied path. Negative fixtures+ cover denials with no follow-up, follow-ups in a different session, and+ follow-ups that are unrelated benign commands.+severity: critical+status: experimental+posture: detect+taxonomy:+ owasp_llm: LLM06+ mitre_atlas: AML.T0051++correlation:+ scope: session+ window: 300s+ steps:+ - id: denied+ match: >+ e.event.action == "approval.denied" &&+ e.command.command.matches("(?i)(\\brm\\s+(-[a-z]*r[a-z]*f|-[a-z]*f[a-z]*r)\\b|\\bmkfs\\b|\\bdd\\s+if=|:\\(\\)\\s*\\{\\s*:\\|:|>\\s*/dev/sd|\\b(curl|wget)\\b.*\\|\\s*(ba)?sh\\b|\\bsudo\\s+-s\\b|\\bchmod\\s+-R\\s+777\\b)")+ - id: renamed_dangerous+ match: >+ e.event.action == "command.executed" &&+ e.command.command.matches("(?i)(/tmp/|/var/tmp/|\\$\\(mktemp\\))") &&+ e.command.command.matches("(?i)(\\s+if\\s*=|\\s+of\\s*=/dev/sd|\\s+-[a-z]*r[a-z]*f\\b|\\s+-[a-z]*f[a-z]*r\\b|\\bmkfs\\b|\\|\\s*(ba)?sh\\b|\\bchmod\\s+-R\\s+777\\b|\\bsudo\\s+-s\\b)")++emit:+ reason: "Denied dangerous command re-invoked via a renamed or shimmed binary in the same session"++tests:+ - name: denied_rm_then_renamed_rm+ verdict: match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: approval.denied }+ command: { command: "rm -rf /var/data" }+ approval: { decision: "denied", required: true }+ session: { id: s1 }+ - timestamp: "2026-06-23T10:00:45Z"+ event: { action: command.executed }+ command: { command: "cp /bin/rm /tmp/myrm && /tmp/myrm -rf /var/data" }+ session: { id: s1 }+ - name: denied_dd_then_renamed_dd+ verdict: match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: approval.denied }+ command: { command: "dd if=/dev/zero of=/dev/sda" }+ approval: { decision: "denied", required: true }+ session: { id: s1 }+ - timestamp: "2026-06-23T10:00:45Z"+ event: { action: command.executed }+ command: { command: "cp /bin/dd /var/tmp/.x && /var/tmp/.x if=/dev/zero of=/dev/sda" }+ session: { id: s1 }+ - name: denied_then_benign_command+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: approval.denied }+ command: { command: "rm -rf /var/data" }+ approval: { decision: "denied", required: true }+ session: { id: s1 }+ - timestamp: "2026-06-23T10:00:45Z"+ event: { action: command.executed }+ command: { command: "ls -la /var/data" }+ session: { id: s1 }+ - name: denied_but_followup_in_other_session+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: approval.denied }+ command: { command: "rm -rf /var/data" }+ approval: { decision: "denied", required: true }+ session: { id: s1 }+ - timestamp: "2026-06-23T10:00:45Z"+ event: { action: command.executed }+ command: { command: "cp /bin/rm /tmp/myrm && /tmp/myrm -rf /var/data" }+ session: { id: s2 }+ - name: renamed_dangerous_without_denial+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: command.executed }+ command: { command: "cp /bin/rm /tmp/myrm && /tmp/myrm -rf /var/data" }+ session: { id: s1 }diff --git a/rules/resource-consumption/disk-fill-attempt.rule.yaml b/rules/resource-consumption/disk-fill-attempt.rule.yamlnew file mode 100644index 00000000..6b4f5c58--- /dev/null+++ b/rules/resource-consumption/disk-fill-attempt.rule.yaml@@ -0,0 +1,93 @@+id: disk-fill-attempt+version: 1+title: Disk-fill primitive executed in a command+description: >+ A command.executed event invokes a disk-fill primitive: writing an unbounded+ stream of /dev/zero or /dev/urandom to a real file via dd, fallocate/truncate+ with a large or unbounded size, yes piped to a file, or a write to a top-level+ mount point (/, /tmp, /var). A disk-fill attack is a resource-DoS primitive+ (OWASP LLM10) that exhausts filesystem capacity and is rarely a legitimate+ agent action. The rule is anchored to a command boundary and only matches+ the dangerous shapes (dd to a real target file, large fallocate, yes to a+ file, direct write to / or /tmp or /var); small /dev/null writes and ordinary+ redirects do not fire.+severity: medium+status: experimental+posture: detect+taxonomy:+ owasp_llm: LLM10++match: >+ e.event.action == "command.executed" && (+ e.command.command.matches("(?i)\\bdd\\b[^;&|]*\\bif\\s*=\\s*/dev/(zero|urandom)\\b[^;&|]*\\bof\\s*=\\s*[^\\s;&|]+") ||+ e.command.command.matches("(?i)\\b(fallocate|truncate)\\b\\s+(-[ls]\\s+([0-9]+[KMGTP]|[0-9]+M|[0-9]+G)|--size\\s+[0-9]+[KMGTP])\\s+") ||+ e.command.command.matches("(?i)\\byes\\b[^;&|]*>\\s*\\S+")+ )++emit:+ reason: "Disk-fill primitive executed (resource-DoS via dd / fallocate / yes / /dev/zero)"++tests:+ - name: dd_dev_zero_to_root+ verdict: match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: command.executed }+ command: { command: "dd if=/dev/zero of=/bigfile bs=1M count=10240" }+ session: { id: s1 }+ - name: dd_dev_urandom_to_tmp+ verdict: match+ events:+ - timestamp: "2026-06-23T10:01:00Z"+ event: { action: command.executed }+ command: { command: "dd if=/dev/urandom of=/tmp/junk bs=1G count=5" }+ session: { id: s1 }+ - name: fallocate_large_file+ verdict: match+ events:+ - timestamp: "2026-06-23T10:02:00Z"+ event: { action: command.executed }+ command: { command: "fallocate -l 100G /var/spool/big" }+ session: { id: s1 }+ - name: truncate_5G+ verdict: match+ events:+ - timestamp: "2026-06-23T10:03:00Z"+ event: { action: command.executed }+ command: { command: "truncate -s 5G /var/log/huge" }+ session: { id: s1 }+ - name: yes_piped_to_file+ verdict: match+ events:+ - timestamp: "2026-06-23T10:04:00Z"+ event: { action: command.executed }+ command: { command: "yes 'fill' > /tmp/flood" }+ session: { id: s1 }+ - name: dd_copy_real_file_safe+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:05:00Z"+ event: { action: command.executed }+ command: { command: "dd if=/etc/passwd of=/tmp/passwd_copy" }+ session: { id: s1 }+ - name: ordinary_file_write+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:06:00Z"+ event: { action: command.executed }+ command: { command: "echo hello > /tmp/greeting.txt" }+ session: { id: s1 }+ - name: dd_in_manpage_grep+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:07:00Z"+ event: { action: command.executed }+ command: { command: "man dd | grep 'of='" }+ session: { id: s1 }+ - name: small_truncate+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:08:00Z"+ event: { action: command.executed }+ command: { command: "truncate -s 0 /var/log/app.log" }+ session: { id: s1 }diff --git a/rules/resource-consumption/fork-bomb-pattern.rule.yaml b/rules/resource-consumption/fork-bomb-pattern.rule.yamlnew file mode 100644index 00000000..3320a9ed--- /dev/null+++ b/rules/resource-consumption/fork-bomb-pattern.rule.yaml@@ -0,0 +1,89 @@+id: fork-bomb-pattern+version: 1+title: Fork-bomb pattern executed in a command+description: >+ A command.executed event invokes a known fork-bomb shape — the canonical+ bash fork bomb `:(){ :|:& };:`, the `while true; do ... & done` recursive+ spawn loop, or the `bash -c ':()...'` wrapper. A fork bomb is a denial-of-+ service primitive that recursively spawns processes to exhaust PID and+ process-table resources; running one from an agent session is a strong+ resource-DoS or destructive-escalation signal (OWASP LLM10). The rule is+ anchored to a command boundary and matches the well-known shapes; ordinary+ long-running but bounded loops do not fire because they do not recursively+ spawn.+severity: high+status: experimental+posture: detect+taxonomy:+ owasp_llm: LLM10+ mitre_atlas: AML.T0040++match: >+ e.event.action == "command.executed" && (+ e.command.command.matches("(?i):\\(\\)\\s*\\{?\\s*:\\|:&\\s*\\}?\\s*;\\s*:") ||+ e.command.command.matches("(?i)\\bwhile\\s+true\\s*;?\\s*do\\b[^;&|]*&\\s*\\S") ||+ e.command.command.matches("(?i)\\bfor\\s*\\(\\s*;\\s*;\\s*\\)\\s*[;{]") ||+ e.command.command.matches("(?i)\\bbomb\\(\\)\\b") ||+ e.command.command.matches("(?i)\\b(perl|python|ruby)\\s+-[ec]\\s+['\"][^'\"]*(\\.fork\\(\\)|for\\s+_\\s+in\\s+iter\\(\\s*int\\s*,\\s*1\\s*\\)|\\bwhile\\s+(1|True)\\b)")+ )++emit:+ reason: "Fork-bomb pattern executed (resource-DoS primitive)"++tests:+ - name: canonical_bash_fork_bomb+ verdict: match+ events:+ - timestamp: "2026-06-23T10:00:00Z"+ event: { action: command.executed }+ command: { command: ":(){ :|:& };:" }+ session: { id: s1 }+ - name: while_true_fork_loop+ verdict: match+ events:+ - timestamp: "2026-06-23T10:01:00Z"+ event: { action: command.executed }+ command: { command: "while true; do nc -l 9999 & done" }+ session: { id: s1 }+ - name: for_loop_empty_init+ verdict: match+ events:+ - timestamp: "2026-06-23T10:02:00Z"+ event: { action: command.executed }+ command: { command: "for(;;){ do_thing & }" }+ session: { id: s1 }+ - name: bash_c_fork_bomb_wrapper+ verdict: match+ events:+ - timestamp: "2026-06-23T10:03:00Z"+ event: { action: command.executed }+ command: { command: "bash -c ':(){ :|:& };:'" }+ session: { id: s1 }+ - name: python_while_one_spawn+ verdict: match+ events:+ - timestamp: "2026-06-23T10:04:00Z"+ event: { action: command.executed }+ command: { command: "python -c 'import os; [os.fork() for _ in iter(int,1)]'" }+ session: { id: s1 }+ - name: bounded_while_loop_benign+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:05:00Z"+ event: { action: command.executed }+ command: { command: "while true; do read line; done < /dev/null" }+ session: { id: s1 }+ - name: ordinary_long_running_command+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:06:00Z"+ event: { action: command.executed }+ command: { command: "make -j8 build" }+ session: { id: s1 }+ - name: fork_bomb_mentioned_in_doc+ verdict: no_match+ events:+ - timestamp: "2026-06-23T10:07:00Z"+ event: { action: command.executed }+ command: { command: "echo 'never run a fork bomb in this repo' > notes.txt" }+ session: { id: s1 }