fix(tools): strict path confinement with sensitive-subpath deny list (#1072)

Rework read_file / write_file confinement after review feedback:

- Remove $HOME from default allow roots. Only project data/ and system
  temp dirs are allowed out of the box.
- Add a sensitive-subpath deny list (.ssh, .gnupg, shell rc files,
  .env, .netrc, SSH key filenames). Checked BEFORE allowlist so it
  blocks even when a broader root is configured.
- Add "tool_path_extra_roots" setting for opt-in broader access.
- Sensitive subpaths remain blocked regardless of configured roots.

Tests: 24 cases covering /etc/shadow, ~/.ssh/authorized_keys,
symlink into .ssh, traversal, shell rc files, key filenames,
extra roots, and dispatch-level end-to-end.
This commit is contained in:
Ernest Hysa
2026-06-02 15:13:30 +01:00
committed by GitHub
parent 16f7feee0a
commit c12ae79c42
3 changed files with 434 additions and 7 deletions
+5
View File
@@ -97,6 +97,11 @@ DEFAULT_SETTINGS = {
"agent_max_tool_calls": 0,
"agent_input_token_budget": 6000,
"agent_stream_timeout_seconds": 300,
# Extra directory roots that read_file / write_file may access, in
# addition to the built-in project data/ and system temp dirs. Each
# entry is an absolute path. Sensitive subpaths (.ssh, .gnupg, shell
# rc files, SSH key files) are always blocked regardless of roots.
"tool_path_extra_roots": [],
"task_endpoint_id": "",
"task_model": "",
"default_endpoint_id": "",