# Security model `plugin_filesystem` gives an agent **write** access to a slice of your disk. Everything in this file exists to answer one question: *what can this binary actually touch?* If you read only one line: **it can create, overwrite, edit, move and delete files inside the directories in `roots.json` and nowhere else**, and when `roots.json` is missing the allowlist is `/workspace` and `$HOME`. ## One gate, every entry point A path arriving from `--mcp`, from `?action=sandbox_test`, or from a roots mutation goes through the same five checks, in this order: | # | Check | What it stops | |---|---|---| | 1 | **Shape** — absolute, no NUL, no control bytes, no `..` segment anywhere | `..` traversal, `%2e%2e`, NUL smuggling, relative-path confusion | | 2 | **Canonicalise** — `realpath()` on POSIX, `GetFullPathNameA()` then `GetFinalPathNameByHandleA()` on Windows | symlink indirection, `//`, redundant `.` segments | | 3 | **Prefix-match against every root**, in both the configured and the canonical form | a sandbox that silently breaks on macOS `/tmp` → `/private/tmp` | | 4 | **Deny list** — `/proc`, `/sys`, `/dev` always, plus operator `denied` entries | reading `/proc/self/environ` under an allowed `/`-ish root | | 5 | **Write mode only** — re-resolve the *parent*, refuse a symlinked leaf | writing *through* a link that points out of the sandbox | Step 2 before step 3 is the whole point. Checking the raw string and then resolving is the bug that makes a symlink sandbox worthless, so resolution happens first and the prefix test only ever sees a real path. `..` is refused outright rather than normalised away. A caller that means the parent directory sends the parent's absolute path. That single rule kills every encoded-traversal variant at once. ## NUL bytes `yyjson` preserves the full length of a JSON string, but every C helper below it stops at the first NUL. Without a guard, `a.txt\u0000secret` becomes `a.txt` — a path the caller never asked for. `ju_cstr()` compares `strlen(s)` with `yyjson_get_len()` and refuses the value outright; any string treated as a path, pattern, or file body passes through it. `tests/run.sh` asserts the refusal. ## Writes `write_file` never writes to the target. Content goes to `.tmp-`, is flushed and `fsync`ed, then `rename()`d over the target. Same-directory so the rename is atomic, same-filesystem by construction. A process killed mid-write leaves the old file or the new one — the suite proves it by `SIGKILL`ing the connector mid-request and checking both the target bytes and the absence of a stray `.tmp`. `edit_file` is all-or-nothing: every edit must match before anything is written. `move_file` refuses to overwrite — silently replacing a file an agent was never shown is the one failure mode an unattended tool must not have. ## The permission switches are not decoration The plugin page's per-tool toggles are read by `--mcp`, not just displayed. A disabled tool answers with an `isError` reply naming the tool and telling the operator where to switch it back on, so an agent gets an explanation instead of a missing tool. `list_allowed_directories` cannot be switched off — it is how you debug a refusal you did not expect. ## What the binary cannot do Enforced by `tests/run.sh` grepping the source, not by this page's promise: * **no network.** No socket, no `connect`, no HTTP client, no `libcurl`. * **no process spawning.** No `system()`, no `popen()`, no `fork`+`exec`. * **no manual `Content-Length`** framing of its own in CGI mode. * **no CDN, no `