What happened?
The dangerous-command rules in packages/coding-agent/src/step/command-policy.ts:93-105 miss several standard, unobfuscated forms of the exact command classes they are meant to catch. Since the default permission preset is bypass ("Run ordinary tools without approval; dangerous commands still ask") and an unmatched command analyzes as ordinary and is allowed with no confirmation (decideStepToolCall, permissions.ts), these execute silently in the default configuration:
dd bs=4M if=disk.img of=/dev/sda / dd of=/dev/sda if=/dev/zero — the copy-device rule /\bdd\s+if=/iu requires if= immediately after dd; any bs=/of= first defeats it.
git push -f origin main / git push origin +main — destructive-git only matches --force, not -f or +refspec.
git -C repo reset --hard / git -c x=y push --force — the regex requires the subcommand to immediately follow git, so any global option defeats all three git rules.
systemctl poweroff / systemctl halt / init 0 — DANGEROUS_LIFECYCLE_COMMANDS only contains reboot/shutdown.
:> /dev/sda — /\b:>\s*\/dev\//u can never match realistic input: \b before : requires a preceding word character, so only odd forms like x:> /dev/sda match. The rule is effectively dead code.
Steps to reproduce
/\bdd\s+if=/iu.test("dd bs=4M if=disk.img of=/dev/sda") // false
// destructive-git:
/\bgit\s+(?:reset\s+--hard|clean\s+-[^\n]*f|push\s+[^\n]*--force(?:-with-lease)?)/iu.test("git push -f origin main") // false
/\b:>\s*\/dev\//u.test(":> /dev/sda") // false
Feeding each command through analyzeCommandPolicy returns { kind: "ordinary" }, and decideStepToolCall("run_command", ..., bypass) returns { action: "allow" } — while rm -rf ./build and git push --force correctly return confirm.
Expected behavior
Standard forms of these dangerous commands should trigger confirmation, as the bypass preset promises. Suggestions: match of=/dev/ anywhere in dd args; evaluate git via parsed argv (as isRecursiveForceRemove already does) to cover -f, +refspec, and git -C/-c prefixes; add poweroff/halt and init 0|6 to the lifecycle set; fix or drop the :> rule; add tests using each rule’s standard spellings. Happy to implement this if you’d like.
Version
main @ e411b1a
What happened?
The dangerous-command rules in
packages/coding-agent/src/step/command-policy.ts:93-105miss several standard, unobfuscated forms of the exact command classes they are meant to catch. Since the default permission preset isbypass("Run ordinary tools without approval; dangerous commands still ask") and an unmatched command analyzes asordinaryand is allowed with no confirmation (decideStepToolCall,permissions.ts), these execute silently in the default configuration:dd bs=4M if=disk.img of=/dev/sda/dd of=/dev/sda if=/dev/zero— thecopy-devicerule/\bdd\s+if=/iurequiresif=immediately afterdd; anybs=/of=first defeats it.git push -f origin main/git push origin +main—destructive-gitonly matches--force, not-for+refspec.git -C repo reset --hard/git -c x=y push --force— the regex requires the subcommand to immediately followgit, so any global option defeats all three git rules.systemctl poweroff/systemctl halt/init 0—DANGEROUS_LIFECYCLE_COMMANDSonly containsreboot/shutdown.:> /dev/sda—/\b:>\s*\/dev\//ucan never match realistic input:\bbefore:requires a preceding word character, so only odd forms likex:> /dev/sdamatch. The rule is effectively dead code.Steps to reproduce
Feeding each command through
analyzeCommandPolicyreturns{ kind: "ordinary" }, anddecideStepToolCall("run_command", ..., bypass)returns{ action: "allow" }— whilerm -rf ./buildandgit push --forcecorrectly returnconfirm.Expected behavior
Standard forms of these dangerous commands should trigger confirmation, as the bypass preset promises. Suggestions: match
of=/dev/anywhere in dd args; evaluate git via parsed argv (asisRecursiveForceRemovealready does) to cover-f,+refspec, andgit -C/-cprefixes; addpoweroff/haltandinit 0|6to the lifecycle set; fix or drop the:>rule; add tests using each rule’s standard spellings. Happy to implement this if you’d like.Version
main @ e411b1a