fix(security): add optional workspace-only path guards for fs tools

This commit is contained in:
Peter Steinberger
2026-02-14 23:50:04 +01:00
parent 55a25f9875
commit 5e7c3250cb
14 changed files with 201 additions and 25 deletions

View File

@@ -577,6 +577,11 @@ You can already build a read-only profile by combining:
We may add a single `readOnlyMode` flag later to simplify this configuration.
Additional hardening options:
- `tools.exec.applyPatch.workspaceOnly: true` (recommended): ensures `apply_patch` cannot write/delete outside the workspace directory even when sandboxing is off.
- `tools.fs.workspaceOnly: true` (optional): restricts `read`/`write`/`edit`/`apply_patch` paths to the workspace directory (useful if you allow absolute paths today and want a single guardrail).
### 5) Secure baseline (copy/paste)
One “safe default” config that keeps the Gateway private, requires DM pairing, and avoids always-on group bots:

View File

@@ -32,7 +32,8 @@ The tool accepts a single `input` string that wraps one or more file operations:
## Notes
- Paths are resolved relative to the workspace root.
- Patch paths support relative paths (from the workspace directory) and absolute paths.
- Optional: set `tools.exec.applyPatch.workspaceOnly: true` to restrict patch paths to the workspace directory (recommended when untrusted users can trigger tool execution).
- Use `*** Move to:` within an `*** Update File:` hunk to rename files.
- `*** End of File` marks an EOF-only insert when needed.
- Experimental and disabled by default. Enable with `tools.exec.applyPatch.enabled`.

View File

@@ -167,7 +167,7 @@ Enable it explicitly:
{
tools: {
exec: {
applyPatch: { enabled: true, allowModels: ["gpt-5.2"] },
applyPatch: { enabled: true, workspaceOnly: true, allowModels: ["gpt-5.2"] },
},
},
}
@@ -178,3 +178,4 @@ Notes:
- Only available for OpenAI/OpenAI Codex models.
- Tool policy still applies; `allow: ["exec"]` implicitly allows `apply_patch`.
- Config lives under `tools.exec.applyPatch`.
- Optional: set `tools.exec.applyPatch.workspaceOnly: true` to restrict patch paths to the workspace directory (recommended when untrusted users can trigger tool execution).

View File

@@ -181,6 +181,7 @@ Optional plugin tools:
Apply structured patches across one or more files. Use for multi-hunk edits.
Experimental: enable via `tools.exec.applyPatch.enabled` (OpenAI models only).
Optional: restrict patch paths to the workspace directory with `tools.exec.applyPatch.workspaceOnly: true`.
### `exec`