Problem
Model-invoked filesystem tools do not enforce the repository boundary.
readFile builds its target with:
fullPath := filepath.Join(workdir, path)
content, err := os.ReadFile(fullPath)
A relative path containing .. can therefore escape workdir. A symlink
inside the repository can also resolve to a file outside it. Because tool
results are returned to the agent, local file contents can be sent to the
configured model provider.
listFiles accepts a caller-controlled path and walks it without the same
boundary validation. Write and patch tools should be audited against the same
invariant.
Safe reproduction
Use two temporary sibling directories:
- Put
outside.txt in the parent temporary directory.
- Use the other directory as
workdir.
- Call
read_file with ../outside.txt.
- Assert that the tool rejects the request and never returns the sentinel
content.
- Create an in-repository symlink to
outside.txt and assert that it is also
rejected.
No real user file or secret is needed to reproduce the defect.
Acceptance criteria
Context
GPTCode research initially inferred safety from QUALITY.md, which documents
the intended boundary for research evidence. Direct inspection of
internal/tools/tools.go contradicted that answer. This issue tracks the
executable enforcement required for model-invoked tools.
Problem
Model-invoked filesystem tools do not enforce the repository boundary.
readFilebuilds its target with:A relative path containing
..can therefore escapeworkdir. A symlinkinside the repository can also resolve to a file outside it. Because tool
results are returned to the agent, local file contents can be sent to the
configured model provider.
listFilesaccepts a caller-controlled path and walks it without the sameboundary validation. Write and patch tools should be audited against the same
invariant.
Safe reproduction
Use two temporary sibling directories:
outside.txtin the parent temporary directory.workdir.read_filewith../outside.txt.content.
outside.txtand assert that it is alsorejected.
No real user file or secret is needed to reproduce the defect.
Acceptance criteria
repository-boundary policy.
.., absolute-path, prefix-confusion, and symlink escapes are rejected.go test ./internal/toolsandmake verifypass.Context
GPTCode research initially inferred safety from
QUALITY.md, which documentsthe intended boundary for research evidence. Direct inspection of
internal/tools/tools.gocontradicted that answer. This issue tracks theexecutable enforcement required for model-invoked tools.