v1.6.1

Subprocess argv-only Schema

Last updated


What run_command accepts as argv, and how sh -c scripts are parsed and validated.
run_command accepts only argv: string[] (minItems 1) plus optional write_paths, since v1.0.25 network (boolean, default off), and since v1.3.0 sandbox (boolean, default true; false runs outside the sandbox after a password check and ignores network / write_paths). background_command adds timeout_min (1-60, default 60) and keywords (the error keywords its output watch looks for) to the same set; run_command_background was renamed background_command and its interval and prompt parameters were dropped (Removed in v1.3.2). It does not accept a command: string with auto-tokenization. This zero-parsing approach removes shell-injection surface in the agent layer.
At the top level, since v1.3.2 ['sudo', '<binary>', ...] is accepted: no sudo flags, no nested sudo / su, and the target must be a bare binary not on denied_command; it raises a sudo: <cmd> confirmation that always asks for the system password and then runs as sudo -n <binary> ... outside the sandbox. Since v1.3.11 cancelling such a call (foreground or background_command) sends SIGTERM to sudo, which relays it to the root command, instead of SIGKILLing the process group, which a root child would survive; if it has not exited within the 2-second WaitDelay, sudo is then killed. rm is routed to the trash (sudo rm deletes for real); its targets follow the path tiers — inside the working directory it runs under auto, elsewhere in $HOME it asks, outside $HOME it needs the system password — and cd is rejected because the work directory is set by the user in the TUI; the agent cd that switched the work directory was Removed in v1.3.0.
Shell features (pipes, redirects) require an explicit ["sh", "-c", "cmd | pipe"] (or bash -c). That script is parsed with mvdan.cc/sh rather than string-matched, and every command node inside it is checked:
RuleEffect
Bare command names only/usr/bin/curl is rejected — the binary must be written as curl
No dynamic commandsA command built from a variable or command substitution is rejected outright
No rm or sudoBoth are rejected inside sh -c; the sudo error points to the argv form ['sudo', '<binary>', ...]
Denied binariesAnything on denied_command is rejected, inside sh -c as well
Shell builtinsA fixed set (cd, echo, test, export, ...) passes without an allowlist entry
Nested sh -cRecursively validated with the same rules; a nested script that is not a static string is rejected