You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If projectPath is /home/user/project and directoryPath is ../project-evil, the resolved path /home/user/project-evil passes the startsWith('/home/user/project') check because it's a string prefix match.
The same codebase gets this right in code-search.ts (lines 52-53):
A sandboxed agent or user-controlled directoryPath parameter can list directories outside the declared project root, as long as the sibling directory name starts with the project directory name.
Description
The path traversal check in
listDirectory()can be bypassed using sibling directory names that share a prefix with the project path.Root Cause
In
sdk/src/tools/list-directory.ts(line 16):If
projectPathis/home/user/projectanddirectoryPathis../project-evil, the resolved path/home/user/project-evilpasses thestartsWith('/home/user/project')check because it's a string prefix match.The same codebase gets this right in
code-search.ts(lines 52-53):Impact
A sandboxed agent or user-controlled
directoryPathparameter can list directories outside the declared project root, as long as the sibling directory name starts with the project directory name.Suggested Fix
This matches the pattern already used in
code-search.ts.