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
rules: catch cp/mv into agent surfaces on later lines and in if/for bodies
Claude4f73f7d2152f
diff --git a/rules/sensitive-edit/agent-control-surface-modified.rule.yaml b/rules/sensitive-edit/agent-control-surface-modified.rule.yamlindex 4885892d..eb4159f9 100644--- a/rules/sensitive-edit/agent-control-surface-modified.rule.yaml+++ b/rules/sensitive-edit/agent-control-surface-modified.rule.yaml@@ -30,7 +30,7 @@ match: >) || (e.event.action == "command.executed" && (e.command.command.matches("(?i)(>{1,2}\\s*|\\btee(\\s+-[^\\s;&|<>]+)*\\s+|\\bsed\\s+([^;&|\\n]*\\s)?-i\\S*\\s+([^;&|\\n]*\\s)?|\\bgit\\s+clone\\b[^;&|\\n]*\\s|\\b(curl|wget)\\b[^;&|\\n]*\\s(-o|-O|--output|--output-document)(\\s+|=)|\\b(set-content|add-content|out-file)\\s+(-(literal|file)?path\\s+)?)['\"]?([^\\s;&|'\"<>]*[/\\\\])?((\\.claude/settings(\\.local)?\\.json|\\.claude\\.json|\\.mcp\\.json|managed-settings\\.json|\\.cursor/(mcp|hooks|cli|cli-config)\\.json|\\.codex/(config\\.toml|hooks\\.json)|\\.gemini/settings\\.json|\\.copilot/(config|mcp-config)\\.json|\\.vscode/mcp\\.json|\\.kiro/settings/mcp\\.json|opencode\\.jsonc?|\\.codeium/windsurf/mcp_config\\.json|\\.windsurf/hooks\\.json|cline_mcp_settings\\.json)|(\\.claude/plugins|\\.github/hooks|\\.kiro/(hooks|agents)|\\.gemini/extensions|\\.opencode/plugins?|\\.config/opencode/plugins?|\\.cline/plugins)(/[^\\s;&|'\"<>]*)?)['\"]?($|[\\s;&|)<>])") ||- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cp|mv|install|ln|rsync)\\s[^;&|<>\\n]*\\s['\"]?([^\\s;&|'\"<>]*[/\\\\])?((\\.claude/settings(\\.local)?\\.json|\\.claude\\.json|\\.mcp\\.json|managed-settings\\.json|\\.cursor/(mcp|hooks|cli|cli-config)\\.json|\\.codex/(config\\.toml|hooks\\.json)|\\.gemini/settings\\.json|\\.copilot/(config|mcp-config)\\.json|\\.vscode/mcp\\.json|\\.kiro/settings/mcp\\.json|opencode\\.jsonc?|\\.codeium/windsurf/mcp_config\\.json|\\.windsurf/hooks\\.json|cline_mcp_settings\\.json)|(\\.claude/plugins|\\.github/hooks|\\.kiro/(hooks|agents)|\\.gemini/extensions|\\.opencode/plugins?|\\.config/opencode/plugins?|\\.cline/plugins)(/[^\\s;&|'\"<>]*)?)['\"]?\\s*($|[;&|)])")+ e.command.command.matches("(?i)(^|[;&|(`\\n]|\\$\\(|\\b(then|do|else)\\s)\\s*(sudo\\s+)?(cp|mv|install|ln|rsync)\\s[^;&|<>\\n]*\\s['\"]?([^\\s;&|'\"<>]*[/\\\\])?((\\.claude/settings(\\.local)?\\.json|\\.claude\\.json|\\.mcp\\.json|managed-settings\\.json|\\.cursor/(mcp|hooks|cli|cli-config)\\.json|\\.codex/(config\\.toml|hooks\\.json)|\\.gemini/settings\\.json|\\.copilot/(config|mcp-config)\\.json|\\.vscode/mcp\\.json|\\.kiro/settings/mcp\\.json|opencode\\.jsonc?|\\.codeium/windsurf/mcp_config\\.json|\\.windsurf/hooks\\.json|cline_mcp_settings\\.json)|(\\.claude/plugins|\\.github/hooks|\\.kiro/(hooks|agents)|\\.gemini/extensions|\\.opencode/plugins?|\\.config/opencode/plugins?|\\.cline/plugins)(/[^\\s;&|'\"<>]*)?)['\"]?\\s*($|[;&|)\\n])")))@@ -260,6 +260,36 @@ tests:- event: { action: command.executed }command: { command: "git clone https://github.com/someone/ext ~/.gemini/extensions/ext" }session: { id: s1 }+ - name: shell_cp_on_second_line+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "mkdir -p ~/.claude\ncp /tmp/evil.json ~/.claude/settings.json" }+ session: { id: s1 }+ - name: shell_cp_mid_script+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "cd /tmp\ncp mcp.json ~/project/.mcp.json\necho done" }+ session: { id: s1 }+ - name: shell_cp_in_then+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "if [ -d ~/.cursor ]; then cp /tmp/h.json ~/.cursor/hooks.json; fi" }+ session: { id: s1 }+ - name: shell_mv_in_for_do+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "for p in /tmp/p/*.ts; do mv \"$p\" ~/.cline/plugins/; done" }+ session: { id: s1 }+ - name: shell_backup_settings_multiline+ verdict: no_match+ events:+ - event: { action: command.executed }+ command: { command: "cd ~\ncp .claude/settings.json /tmp/settings.bak\nls" }+ session: { id: s1 }- name: shell_read_settingsverdict: no_matchevents:diff --git a/rules/sensitive-edit/agent-instruction-surface-modified.rule.yaml b/rules/sensitive-edit/agent-instruction-surface-modified.rule.yamlindex bc3a9f96..bbf67bbd 100644--- a/rules/sensitive-edit/agent-instruction-surface-modified.rule.yaml+++ b/rules/sensitive-edit/agent-instruction-surface-modified.rule.yaml@@ -29,7 +29,7 @@ match: >) || (e.event.action == "command.executed" && (e.command.command.matches("(?i)(>{1,2}\\s*|\\btee(\\s+-[^\\s;&|<>]+)*\\s+|\\bsed\\s+([^;&|\\n]*\\s)?-i\\S*\\s+([^;&|\\n]*\\s)?|\\bgit\\s+clone\\b[^;&|\\n]*\\s|\\b(curl|wget)\\b[^;&|\\n]*\\s(-o|-O|--output|--output-document)(\\s+|=)|\\b(set-content|add-content|out-file)\\s+(-(literal|file)?path\\s+)?)['\"]?([^\\s;&|'\"<>]*[/\\\\])?((claude(\\.local)?\\.md|agents(\\.override)?\\.md|gemini\\.md|qwen\\.md|copilot-instructions\\.md|\\.cursorrules|\\.windsurfrules|\\.clinerules)|(\\.claude/(skills|commands|agents)|\\.agents/skills|\\.codex/(prompts|skills)|\\.cursor/(rules|commands)|\\.gemini/commands|\\.github/(instructions|prompts|agents|chatmodes)|\\.kiro/steering|\\.opencode/(agents?|commands?)|\\.config/opencode/(agents?|commands?)|\\.windsurf/(rules|workflows)|\\.clinerules|documents/cline/(rules|workflows))(/[^\\s;&|'\"<>]*)?)['\"]?($|[\\s;&|)<>])") ||- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cp|mv|install|ln|rsync)\\s[^;&|<>\\n]*\\s['\"]?([^\\s;&|'\"<>]*[/\\\\])?((claude(\\.local)?\\.md|agents(\\.override)?\\.md|gemini\\.md|qwen\\.md|copilot-instructions\\.md|\\.cursorrules|\\.windsurfrules|\\.clinerules)|(\\.claude/(skills|commands|agents)|\\.agents/skills|\\.codex/(prompts|skills)|\\.cursor/(rules|commands)|\\.gemini/commands|\\.github/(instructions|prompts|agents|chatmodes)|\\.kiro/steering|\\.opencode/(agents?|commands?)|\\.config/opencode/(agents?|commands?)|\\.windsurf/(rules|workflows)|\\.clinerules|documents/cline/(rules|workflows))(/[^\\s;&|'\"<>]*)?)['\"]?\\s*($|[;&|)])")+ e.command.command.matches("(?i)(^|[;&|(`\\n]|\\$\\(|\\b(then|do|else)\\s)\\s*(sudo\\s+)?(cp|mv|install|ln|rsync)\\s[^;&|<>\\n]*\\s['\"]?([^\\s;&|'\"<>]*[/\\\\])?((claude(\\.local)?\\.md|agents(\\.override)?\\.md|gemini\\.md|qwen\\.md|copilot-instructions\\.md|\\.cursorrules|\\.windsurfrules|\\.clinerules)|(\\.claude/(skills|commands|agents)|\\.agents/skills|\\.codex/(prompts|skills)|\\.cursor/(rules|commands)|\\.gemini/commands|\\.github/(instructions|prompts|agents|chatmodes)|\\.kiro/steering|\\.opencode/(agents?|commands?)|\\.config/opencode/(agents?|commands?)|\\.windsurf/(rules|workflows)|\\.clinerules|documents/cline/(rules|workflows))(/[^\\s;&|'\"<>]*)?)['\"]?\\s*($|[;&|)\\n])")))@@ -271,6 +271,42 @@ tests:- event: { action: command.executed }command: { command: "Set-Content -Path .\\AGENTS.md -Value 'x'" }session: { id: s1 }+ - name: shell_mv_on_second_line+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "cd app\nmv /tmp/g.md AGENTS.md" }+ session: { id: s1 }+ - name: shell_cp_after_clone_line+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "git clone https://x.test/repo /tmp/r\ncp /tmp/r/evil.md ~/.claude/skills/x/SKILL.md" }+ session: { id: s1 }+ - name: shell_cp_mid_script+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "mkdir -p .cursor/rules\ncp /tmp/r.mdc .cursor/rules/r.mdc\necho done" }+ session: { id: s1 }+ - name: shell_cp_in_then+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "if [ -f /tmp/g.md ]; then cp /tmp/g.md GEMINI.md; fi" }+ session: { id: s1 }+ - name: shell_mv_in_for_do+ verdict: match+ events:+ - event: { action: command.executed }+ command: { command: "for f in /tmp/s/*; do mv \"$f\" ~/.agents/skills/; done" }+ session: { id: s1 }+ - name: shell_backup_copy_multiline+ verdict: no_match+ events:+ - event: { action: command.executed }+ command: { command: "cd app\ncp CLAUDE.md CLAUDE.md.bak\nls" }+ session: { id: s1 }- name: shell_read_claude_mdverdict: no_matchevents: