feat(exec): add a macOS Seatbelt sandbox backend
`tools.exec.sandbox` only supported bubblewrap, which depends on Linux kernel namespaces, so macOS had no process-level isolation for shell commands: SECURITY.md told macOS users the sandbox was simply unavailable. Add a `seatbelt` backend that generates an SBPL profile for sandbox-exec(1) with the same policy bwrap applies. The workspace is read-write, the media directory is read-only, the workspace's parent is unreadable so config.json and its API keys stay hidden, and everything else is denied by default. Two macOS details the profile has to get right, both found by running the generated command rather than by reading the SBPL reference: - sh(1) reads `/` while resolving a path, and `(subpath "/usr")` does not cover the root itself. Without `(literal "/")` every wrapped command aborts during shell startup. - Denying the parent directory also blocks traversal into the workspace, so commands fail with ENOTDIR before they run. The ancestors of every allowed path are therefore re-allowed for `file-read-metadata` only: they stay searchable, but the config directory still cannot be listed or read. Paths are SBPL-escaped so a quote or backslash in a workspace path cannot terminate a literal early and widen the rules that follow it. Network access stays unrestricted to match bwrap, which does not pass `--unshare-net`. Windows keeps its existing warn-and-run-unsandboxed path, and selecting `seatbelt` on Linux fails loudly on the missing sandbox-exec(1) exactly as selecting `bwrap` does on macOS today. Verified on macOS 26.6.2 against the real sandbox-exec(1): workspace writes, media reads and /tmp scratch succeed, while writing media, reading config.json, listing the config directory, writing outside the workspace and reading ~/.ssh are all denied. Refs #1448 Refs #2569
This commit is contained in:
1 parent
fea28b1a00
commit
e217468e0a
6 files changed
+361
-11
No files matched your search
@@ -2092,7 +2092,7 @@ MCP tools are automatically discovered and registered on startup. The LLM can us
|
||||
## Security
|
||||
|
||||
> [!TIP]
|
||||
> For production deployments, set both `"restrictToWorkspace": true` and `"tools.exec.sandbox": "bwrap"` in your config. `restrictToWorkspace` enables nanobot's application-level workspace guards; `tools.exec.sandbox` provides process-level isolation for shell commands.
|
||||
> For production deployments, set both `"restrictToWorkspace": true` and `"tools.exec.sandbox"` (`"bwrap"` on Linux, `"seatbelt"` on macOS) in your config. `restrictToWorkspace` enables nanobot's application-level workspace guards; `tools.exec.sandbox` provides process-level isolation for shell commands.
|
||||
|
||||
For API keys, tokens, and other secrets, see [Environment Variables for Secrets](#environment-variables-for-secrets) — avoid storing them directly in `config.json`.
|
||||
|
||||
@@ -2110,13 +2110,13 @@ For API keys, tokens, and other secrets, see [Environment Variables for Secrets]
|
||||
|--------|---------|-------------|
|
||||
| `tools.restrictToWorkspace` | `false` | When `true`, enables nanobot's application-level workspace guards for workspace-aware tools. File tools resolve paths under the active workspace; selected internal roots can be added as read-only or explicitly write-enabled roots, and media uploads are read-only by default. Shell execution rejects workspace-external `working_dir` values and applies best-effort command path checks, but this is not an OS sandbox. |
|
||||
| `tools.maxSessionMessagesPerMinute` | `6` | Maximum messages one source session may send during any rolling 60-second window. Additional sends are rejected to stop runaway agent loops. |
|
||||
| `tools.exec.sandbox` | `""` | Sandbox backend for shell commands. Set to `"bwrap"` to wrap exec calls in a [bubblewrap](https://github.com/containers/bubblewrap) sandbox — the process can only see the workspace (read-write) and media directory (read-only); config files and API keys are hidden. Automatically enables workspace restriction for file tools. **Linux only** — requires `bwrap` installed (`apt install bubblewrap`; pre-installed in the Docker image). Not available on macOS or Windows (bwrap depends on Linux kernel namespaces). |
|
||||
| `tools.exec.sandbox` | `""` | Sandbox backend for shell commands. Set to `"bwrap"` (Linux) or `"seatbelt"` (macOS) to wrap exec calls in an OS sandbox — the process can only see the workspace (read-write) and media directory (read-only); config files and API keys are hidden. Automatically enables workspace restriction for file tools. `"bwrap"` requires `bwrap` installed (`apt install bubblewrap`; pre-installed in the Docker image) and depends on Linux kernel namespaces. `"seatbelt"` uses the `sandbox-exec(1)` binary shipped with macOS. Neither backend is available on Windows, where nanobot logs a warning and runs commands unsandboxed. |
|
||||
| `tools.exec.enable` | `true` | When `false`, the shell `exec` tool is not registered at all. Use this to completely disable shell command execution. |
|
||||
| `tools.exec.timeout` | `60` | Default hard timeout in seconds for shell commands. Config values may exceed the per-call tool cap; set `0` to disable the hard timeout for trusted long-running commands. |
|
||||
| `tools.exec.pathPrepend` | `""` | Extra directories to prepend to `PATH` when running shell commands. Use this when configured tools should win executable lookup precedence, such as a Python virtual environment's `bin` or `Scripts` directory. |
|
||||
| `tools.exec.pathAppend` | `""` | Extra directories to append to `PATH` when running shell commands (e.g. `/usr/sbin` for `ufw`). |
|
||||
| `tools.exec.sandboxRoBinds` | `[]` | Extra absolute paths to read-only bind into the `"bwrap"` sandbox with `--ro-bind-try`, such as `/home/user/.local/bin` or `/home/user/.cargo/bin` when those paths are also in `pathPrepend`/`pathAppend`. These roots are also accepted by the shell absolute-path guard only while bwrap is active. Bind only directories whose contents are safe for agent commands to read; paths equal to or containing the active workspace are ignored so they cannot uncover its masked parent directory. |
|
||||
| `tools.exec.sandboxRwBinds` | `[]` | Extra absolute paths to read-write bind into the `"bwrap"` sandbox with `--bind-try`, for trusted tool caches or scratch directories. Use sparingly: paths listed here are intentionally writable by shell commands inside the sandbox. Paths equal to or containing the active workspace are ignored. |
|
||||
| `tools.exec.sandboxRoBinds` | `[]` | Extra absolute paths to expose read-only inside the exec sandbox (`--ro-bind-try` for `"bwrap"`, an SBPL `file-read*` rule for `"seatbelt"`), such as `/home/user/.local/bin` or `/home/user/.cargo/bin` when those paths are also in `pathPrepend`/`pathAppend`. These roots are also accepted by the shell absolute-path guard only while a sandbox is active. Bind only directories whose contents are safe for agent commands to read; paths equal to or containing the active workspace are ignored so they cannot uncover its masked parent directory. |
|
||||
| `tools.exec.sandboxRwBinds` | `[]` | Extra absolute paths to expose read-write inside the exec sandbox (`--bind-try` for `"bwrap"`, an SBPL `file-read* file-write*` rule for `"seatbelt"`), for trusted tool caches or scratch directories. Use sparingly: paths listed here are intentionally writable by shell commands inside the sandbox. Paths equal to or containing the active workspace are ignored. |
|
||||
| `tools.webuiAllowRemotePackageInstall` | `false` | When `false`, the WebUI can install missing optional packages only from a browser opened on the same machine as nanobot. Set to `true` only when a trusted remote admin is allowed to install Python packages into this nanobot environment. |
|
||||
| `tools.ssrfWhitelist` | `[]` | CIDR ranges exempted from the shared SSRF guard used by web fetches and HTTP/SSE MCP connections. Prefer exact host CIDRs such as `192.168.1.50/32`; broad ranges increase SSRF exposure. |
|
||||
| `channels.*.allowFrom` | omitted | Access control per channel. Omit to use pairing-only mode; set `["*"]` to allow everyone; or list specific user IDs. See [Pairing](#pairing) for details. |
|
||||
|
||||
Reference in new issue
Block a user