Commit Graph
3 Commits
Author SHA1 Message Date
sam fa7f4e011a fix(tools): judge the rm guard by base name so absolute paths cannot bypass it
checkRecursiveDelete compared the raw segment name, `seg.Name != "rm"`, while
every sibling rule in the same table resolves the command through baseName --
checkMkfs, checkBlockDeviceWrite, checkKillAll, checkSystemPower,
checkSelfTermination and checkDaemonLaunch all call baseName(seg.Name), and
baseName's own doc says its purpose is that /sbin/reboot and reboot are judged
the same. The test suite already pinned that convention for /sbin/poweroff.

Because tokenise yields the raw first word, `/bin/rm -rf /` produced
seg.Name == "/bin/rm", the rule declined, no other rule matched, and Hardline
returned nil. Since provider/builtin calls command.Hardline on the shell tool's
command field before every execution, an absolute path defeated the
recursive-root-delete gate entirely. `/bin/rm -rf /etc` (any critical path, not
just the root) was equally reachable; an overlay probe confirmed both, and
confirmed the sibling /sbin/poweroff case was already correct.

Resolve through baseName, matching the rest of the rule table, and add table
cases for absolute-path rm plus an allow case for an ordinary absolute-path
recursive delete so the normalisation cannot over-block.

Found by an adversarial package sweep (temp tracker: tools-command-1,
.local/issue-tracker/).
2026-09-15 01:51:03 +10:00
sam 6be754787d polish: add install.sh, XDG setup, deployments/ examples, and github-token docs\n\n- Add install.sh following XDG Base Directory specification (~/.config/archie, ~/.local/share/archie, ~/.local/bin)\n- Add interactive setup for code forge (GitHub / Gitea / Standalone) and LLM provider selection (Ollama model picker / Cloud keys)\n- Implement NoopForge in internal/forge/noop.go for running Archie in standalone mode without a forge\n- Enable loginctl user linger and systemd user unit setup in install.sh\n- Add docs/github-token.md with step-by-step guidance for Classic PAT generation\n- Add top-level deployments/ directory with scenario templates (single-forge GitHub, multi-forge GitHub+Gitea, local Ollama standalone, systemd runbook) 2026-07-30 01:25:46 +10:00
sam bb7b779b35 feat: refuse unrecoverable shell commands
Add internal/tools/command: an always-on floor under the shell tool,
enforced in the provider adapter so the lifted tau files stay diffable.

This is not a security boundary and does not pretend to be one. Anything
with a shell has countless ways past a rule list. What it buys is that
the failures with no recovery -- where you cannot intervene afterwards
because the machine, the filesystem, or the gateway itself is gone --
are not reachable by an ordinary mistake.

Rules: recursive delete of / and system directories, mkfs, raw block
device writes, fork bombs, kill -1, shutdown/reboot/init/systemctl
power, and sudo -S with no SUDO_PASSWORD configured. Two more are
archie's own: an agent must not stop the daemon that hosts /stop
(pkill/systemctl/docker), nor start a second one outside the supervisor.

The parsing is the actual work. Patterns are anchored to command
position, so `git commit -m "revert the rm -rf / change"` and
`echo "rm -rf /"` are ordinary commands, while `echo x; rm -rf /` and
`$(rm -rf /)` are not. Quoting, separators, ${VAR} braces, environment
assignments and privilege wrappers are all parsed rather than matched.

Probing the first version found two bypasses that made every rule
optional, both of which a model writes unprompted rather than only an
attacker: `bash -c "rm -rf /"` and `xargs rm -rf /` hide the command in
an argument. Segments are now followed into shell -c payloads, eval, and
command wrappers (xargs, timeout, nice, env, nohup, ...), bounded by a
nesting limit. Tests cover both directions -- the refusals and, at equal
length, the ordinary commands that must not trip them.
2026-07-29 18:45:43 +10:00