# Policy Injection

Which path and command policies `config.json` hands to the sandbox, and their built-in defaults.

`filesystem.LoadRuntime()` reads `~/.config/agenvoy/config.json` at startup and hands the merged policy to `go-pkg/sandbox` and `go-pkg/filesystem`. Since v1.5.0 the path rules (`loadPathRules`) are applied before the rest of the file is parsed, so the built-in denied, read-only and writable paths hold even when `config.json` is corrupt; the TUI then offers to reset it (the old file is kept as `config.json.corrupt`), while `agen -p` exits with an error. Some policies ship embedded in the binary and merge with the user's entries; others exist only as user config.

| Policy | Embedded default | config.json key | Purpose |
|---|---|---|---|
| Sensitive paths | go-pkg `filesystem/jsons/sensitive_path.json` (`configs/jsons/sensitive_path.json` before v1.3.10) | `sensitive_path` | Paths holding credentials, key material, shell startup files or tool settings (since v1.3.7 also `.git`, `.claude`, `.bashrc` / `.zshrc` and the other shell rc files, `.mcp.json`), for reads and writes alike — reachable only after a per-session grant: a plain confirmation inside `$HOME`, the system password outside it. Four buckets: `dirs`, `files`, `prefixes`, `extensions` |
| Exclusions | `configs/jsons/exclude_list.json` | — | Paths excluded from listing / walking / searching |
| Read-only commands | `configs/jsons/read_only_command.json` (532 entries since v1.3.3, 409 after `cd` was dropped in v1.3.0) | `read_only_command` | Commands that skip the confirm gate. Since v1.0.25 a `run_command` call (since v1.3.1 also the background variant, now `background_command`) matches when the binary alone, the binary plus its first argument, or the binary plus its first two arguments is on the list (`git` global flags such as `-C <dir>` are skipped first); any argument that is a sensitive path, or `network: true`, cancels the match |
| Denied commands | — | `denied_command` | Binaries `run_command` refuses outright, inside `sh -c` too |
| Denied paths | `configs/jsons/denied_path.json` (22 entries since v1.5.0, always merged) | `denied_path` | Paths permanently off limits for reads and writes; no prompt can approve them. Entries must be absolute or `~/`-prefixed, the root is refused, and symlink targets are denied as well. A value that is not a string array is ignored with a warning, keeping the built-in list |
| Read-only path | `~/.config/agenvoy` (built in) | — | Since v1.5.0. Readable but never written, moved or removed by the file tools, `write_paths` or a sandboxed command; no prompt can approve it. Not configurable |
| Writable path | `configs/jsons/writable_path.json` (`~/.config/agenvoy/download`) | — | Since v1.5.0. The exception inside the read-only path; the deepest rule wins. User-defined writable paths are not supported; not configurable |
| Readable paths | go-pkg `filesystem/jsons/readable_path.json` | `readable_path` | Since v1.3.10. Locations outside `$HOME` that `read_files` / `find_files` read without a prompt (system and package directories such as `/usr`, `/etc`, `/opt`, `/Library`); an existing absolute path in a `run_command` argv that is outside `$HOME` and not on the list cancels the read-only allowlist match |
| SSRF exemptions | — | `net_white_list` | Hosts exempt from the `http_request` SSRF guard |

The command policy is a **denylist**. There is no binary allowlist: `white_list` and `path_white_list` were removed, and `sensitive_map` was renamed to `sensitive_path`; a config still carrying any of these keys is ignored silently (the startup warning was dropped in v1.1.2). Path access outside `$HOME` is granted per session through the confirmation prompt, not through a config list.

`denied_path` is handed to `go-pkg/sandbox` as its denied map, and since v1.5.0 the read-only and writable paths go with it (`readonly_dirs` / `readonly_files`, `writable_dirs`: macOS `deny file-write*`, Linux read-only binds). On Linux, denied entries that do not exist or are symlinks are left out of the `bwrap` binds; on macOS a missing entry is still denied as a directory. On the agenvoy side `boundary.Resolve` checks `denied_path`, and `boundary.ResolveWrite` / `boundary.CheckWrite` and `boundary.WriteBinds` check both `denied_path` and the read-only path, before any file tool write or `write_paths` bind proceeds.
