-
-
Notifications
You must be signed in to change notification settings - Fork 52.6k
Description
Bug Description
tools.fs.workspaceOnly: false in config does not allow Write/Edit tools to write outside the workspace root. The setting is accepted by the config schema but never reaches the operation factories that enforce path boundaries.
Steps to Reproduce
- Set
tools.fs.workspaceOnly: falseglobally and per-agent in config - Attempt to use the Write tool to write to
/tmp/test.txt(or any path outside workspace) - Error:
Path escapes workspace root: /tmp
Expected Behavior
Write/Edit tools should allow writing to arbitrary paths when workspaceOnly is false.
Actual Behavior
toRelativePathInRoot() always enforces workspace boundaries regardless of the workspaceOnly config value.
Root Cause Analysis
The config value is correctly resolved by resolveToolFsConfig() and consumed by createToolFsPolicy(). However, in createOpenClawCodingTools() (in subagent-registry-*.js), the workspaceOnly variable is used for the wrapToolWorkspaceRootGuard wrapper but is not passed through to createHostWorkspaceWriteTool() / createHostWorkspaceEditTool(), which in turn call createHostWriteOperations(root) / createHostEditOperations(root) without any opts parameter.
The operation factories unconditionally use toRelativePathInRoot() and writeFileWithinRoot(), which enforce workspace boundaries regardless of config.
The workspaceOnly flag only controls whether wrapToolWorkspaceRootGuard is applied (an outer wrapper), but the inner operations themselves always enforce the boundary — making the outer guard redundant and the config ineffective.
Affected Files (v2026.2.26)
dist/subagent-registry-CVXe4Cfs.js—createHostWriteOperations(root),createHostEditOperations(root),createHostWorkspaceWriteTool(root),createHostWorkspaceEditTool(root)- Same pattern in
dist/reply-Deht_wOB.js,dist/pi-embedded-CaI0IFWw.js,dist/pi-embedded-CQnl8oWA.js
Suggested Fix
Pass { workspaceOnly } opts through the chain:
createHostWorkspaceWriteTool(root, opts)→createHostWriteOperations(root, opts)- When
opts.workspaceOnly === false, use rawfs.writeFile/fs.mkdir/fs.readFileinstead ofwriteFileWithinRoot/toRelativePathInRoot
Workaround
Use exec tool with inline shell commands (e.g. echo 'content' > /path/to/file) instead of Write/Edit tools for paths outside workspace.
Environment
- OpenClaw v2026.2.26 (bc50708)
- macOS Darwin 25.3.0 (arm64)
- Node v22.15.0