anomalyco / anomalyco/opencode
glob (V2) searches outside the active Location without external_directory approval
@jlongster is already working on this.
Since Aug 28, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Describe the bug
The V2 glob tool resolves its path via path.resolve(location.directory, input.path) and hands the result straight to ripgrep. There is no containment check and no external_directory permission assertion.
That means an absolute path or a ../ sequence escapes the active Location and silently searches (and returns) files outside it, with no approval. Every other filesystem tool (read, edit, write, apply_patch, bash) requires external_directory approval for the same escape, and the V1 glob tool already asserted external directory access (assertExternalDirectoryEffect). So this is a regression in the V2 port.
Steps to reproduce
glob { pattern: "*.env", path: "/etc" }
glob { pattern: "**/*.conf", path: "../../" }
Both run without any approval and return paths outside the Location.
Affected code
packages/core/src/tool/glob.ts — cwd = path.resolve(location.directory, input.path ?? ".") is passed to ripgrep.glob directly.
Fix: resolve through LocationMutation and assert external_directory when the directory lands outside the Location (mirroring read/edit).
Environment
- opencode version: latest dev
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.