#23486: Tools/FS: default host-mode filesystem access to workspace-only
agents
size: S
trusted-contributor
Cluster:
Sandbox File System Fixes
## Summary
- harden host-mode filesystem tools (`read`/`write`/`edit`) to workspace-only by default
- add explicit escape hatch `tools.fs.allowOutsideWorkspace=true` for host-mode access outside workspace
- preserve existing sandbox-mounted behavior unless `tools.fs.workspaceOnly=true`
- extend security signaling by flagging `tools.fs.allowOutsideWorkspace=true` as insecure/dangerous in audit output
## Testing
- pnpm test src/agents/pi-tools.read.workspace-guard.test.ts src/security/audit.test.ts
- pnpm test:e2e src/agents/pi-tools.workspace-paths.e2e.test.ts
- pnpm check
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR hardens filesystem tool security by making host-mode sessions workspace-only by default, requiring explicit `tools.fs.allowOutsideWorkspace=true` to access paths outside the workspace.
Key changes:
- Host-mode `read`/`write`/`edit` tools now default to workspace-contained (blocks `/etc/passwd`, symlink escapes, etc.)
- New `tools.fs.allowOutsideWorkspace` flag provides explicit escape hatch for host-mode when needed
- Sandbox-mounted behavior unchanged (preserves legacy `tools.fs.workspaceOnly` semantics)
- Security audit properly flags `allowOutsideWorkspace=true` as dangerous
- Comprehensive test coverage for path blocking, symlink prevention, and escape hatch
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk - it strengthens security defaults without breaking existing functionality.
- The PR implements a well-architected security hardening with comprehensive test coverage. The logic correctly distinguishes between sandbox and host modes, preserves backward compatibility for sandboxed sessions, and provides a clear escape hatch. All filesystem tools are consistently protected, and the security audit system properly flags the dangerous config option.
- No files require special attention
<sub>Last reviewed commit: 6896b4c</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#5952: feat(tools): add fs.restrictToWorkspace config option
by reubence · 2026-02-01
80.0%
#16043: fix(sandbox): align fs-bridge and fs-paths write checks with tool-g...
by steflsd · 2026-02-14
78.3%
#19344: fix(sandbox): allow writes when workspaceAccess is 'none'
by mingming099 · 2026-02-17
76.6%
#8846: fix(tools): block LLM writes to hooks directories
by yubrew · 2026-02-04
75.4%
#15757: feat(security): add hardening gap audit checks
by saurabhsh5 · 2026-02-13
74.8%
#16320: security: harden default tool policies and secure shell execution
by SuccessSoham · 2026-02-14
74.2%
#23783: Tools: add strict allowlist mode and fail closed on unknown entries
by bmendonca3 · 2026-02-22
74.0%
#11820: fix(sandbox): remap container paths in sandboxed file tools
by steflsd · 2026-02-08
73.6%
#21136: fix(security): harden agent autonomy controls
by novalis133 · 2026-02-19
73.6%
#23811: Config: fail closed when exec host=sandbox but sandbox mode is off
by bmendonca3 · 2026-02-22
73.4%