Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

5.4 KB
Raw Blame

Project sandbox command policy

  • Date: 2026-08-20
  • Type: feature
  • Scope: core, server, web, docs
  • PR: #374
  • Breaking: yes — every project starts denying the factory destructive commands (rm -rf and friends) under every approval mode; disable the offending rule (or the whole policy) in Project Settings to restore the old behavior

中文版

Added a Project-level sandbox command policy: a deny-rule list applied at the approval boundary to both tools that reach a shell — the command exec_command launches and what input_command types into an already-running one — so a hit is rejected under every approval mode, allow-all included, and the model sees Tool call denied by policy. instead of a person's cancellation. Session.run wraps the injected approval callback with the policy, so the refusal happens before any host is asked and context_engine keeps handling nothing but OmniMessage. The rules are stored as the [command_policy] block of .project_config.toml (Project-owned, so an Agent editing its own configuration cannot reach them) and snapshotted into the Session at creation. The Project settings dialog was rebuilt as a tabbed layout along the way.

Details

  • The rules are plain editable data with no special tiers. The factory set is seeded into each new project like the model presets (copied at creation, never rewritten afterward); a pre-seeding project with no stored list behaves as the factory set until its first saved edit materializes it. Every rule — name, pattern, optional description, per-rule switch — can be edited, disabled, deleted, or added; "Restore defaults" loads the factory set back into the editor and Save writes it.
  • Factory set (deliberately small, each entry destructive with no undo): rm carrying both a recursive and a force flag, mkfs, dd writing straight to a block device, the classic fork bomb, and shell redirection onto a block device; /dev/null targets stay legal. Four more cover the same five on Windows, where exec_command resolves pwsh or cmd: Remove-Item -Recurse -Force / rd /s /q, format C: / Format-Volume, a raw write to \\.\PhysicalDriveN / Clear-Disk, and the cmd fork bomb.
  • Ordinary spellings are normalized before the rules run, so plain typing does not slip through: a leading path (/bin/rm), a wrapper (sudo, env, command, nice, xargs), quoting or a backslash escape of the command word ("rm", r''m, \rm), and a literal sh -c '<payload>' all match. Normalization removes quote marks and nothing else — it does not expand, substitute or decode.
  • ApprovalDecision gains a third value: "forbidden" is the command policy's veto, answered by the Session.run wrapper and never by a host. The denial output stays one fixed aborted line either way — Tool call denied by user. or Tool call denied by policy. — and the approval_decision event carries the decision itself, so the model's text, the Trace viewer and the tool card's decision label all name who denied with no extra field. An existing callback returning "allow" / "deny" behaves exactly as before.
  • New routes GET|PUT /api/projects/:p/command-policy (member read / owner write): the GET serves the effective list plus the factory set for restore; the PUT carries the full list and materializes it, rejecting uncompilable patterns up front.
  • An accident guardrail, not a security boundary — a statement about pattern matching rather than about this implementation. A command assembled at run time ($IFS, X=rm; $X, a substitution, eval, base64 into a shell, python -c, an interpreter reached through a pipe) is deliberately not covered and is not planned to be: shell is a programming language, and each such pattern costs maintenance forever while buying only the appearance of coverage. MCP tools stay out of scope too: the knob that exists there is the per-server permission level from #364, which fixes the level its tools report to the approval mode and deliberately nothing more. For an actual boundary rather than a speed bump, the mechanism is process confinement (bubblewrap / dsh), in progress as #354; this policy complements it and does not replace it. Documented in Configuration § Command policy.
  • Project settings became a tabbed dialog — General (display name, project id, delete), Members (the permission table; the tab is hidden in the single-user desktop app), Defaults (the new-chat defaults block and default model), Security policy (the rule list above) — with a left tab rail and row-styled settings pages.

Compatibility

Existing and new projects alike begin rejecting the factory destructive commands, even in allow-all mode — routine flows that relied on rm -rf (e.g. deleting node_modules) get the fixed denial Tool call denied by policy., whether the command is launched with exec_command or typed into a running shell with input_command. To restore a specific behavior, disable or edit that one rule (or switch the whole policy off) in Project Settings → Security policy; no data migration is involved. Projects created before this change carry no [command_policy] block and follow the factory set until their first saved edit writes the list into .project_config.toml.