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(opencode): split shell commands before matching delete paths
Claude135bf3a3d046
diff --git a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.tsindex 94b24591..3eebb0e1 100644--- a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts+++ b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts@@ -125,9 +125,14 @@ function shellMutationPaths(tool, args) {if (name !== "bash" && !name.includes("shell")) return []const command = String(args?.command || args?.cmd || "")const paths = []+ // Split on command separators first so the delete-command pattern below stays+ // anchored and linear; a single regex spanning separators is open to+ // polynomial backtracking on adversarial tool input.const pattern =- /(?:^|(?:&&|\|\||;|\n)\s*)(?:sudo\s+)?(?:command\s+)?(?:\/bin\/)?(?:rm|unlink)\s+(?:-[^\s]+\s+)*(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/g- for (const match of command.matchAll(pattern)) {+ /^(?:sudo\s+)?(?:command\s+)?(?:\/bin\/)?(?:rm|unlink)\s+(?:-[^\s]+\s+)*(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/+ for (const segment of command.split(/&&|\|\||;|\n/)) {+ const match = pattern.exec(segment.trimStart())+ if (!match) continueconst path = match[1] || match[2] || match[3]if (path) paths.push(path)}diff --git a/plugins/opencode-beacon/src/beacon.ts b/plugins/opencode-beacon/src/beacon.tsindex 94b24591..3eebb0e1 100644--- a/plugins/opencode-beacon/src/beacon.ts+++ b/plugins/opencode-beacon/src/beacon.ts@@ -125,9 +125,14 @@ function shellMutationPaths(tool, args) {if (name !== "bash" && !name.includes("shell")) return []const command = String(args?.command || args?.cmd || "")const paths = []+ // Split on command separators first so the delete-command pattern below stays+ // anchored and linear; a single regex spanning separators is open to+ // polynomial backtracking on adversarial tool input.const pattern =- /(?:^|(?:&&|\|\||;|\n)\s*)(?:sudo\s+)?(?:command\s+)?(?:\/bin\/)?(?:rm|unlink)\s+(?:-[^\s]+\s+)*(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/g- for (const match of command.matchAll(pattern)) {+ /^(?:sudo\s+)?(?:command\s+)?(?:\/bin\/)?(?:rm|unlink)\s+(?:-[^\s]+\s+)*(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/+ for (const segment of command.split(/&&|\|\||;|\n/)) {+ const match = pattern.exec(segment.trimStart())+ if (!match) continueconst path = match[1] || match[2] || match[3]if (path) paths.push(path)}