Skip to content

fix(sdk): prevent list_directory path escapes - #1098

Closed
c8dhjp4tyv-bit wants to merge 9038 commits into
CodebuffAI:mainfrom
c8dhjp4tyv-bit:fix/sdk-list-directory-path-boundary
Closed

fix(sdk): prevent list_directory path escapes#1098
c8dhjp4tyv-bit wants to merge 9038 commits into
CodebuffAI:mainfrom
c8dhjp4tyv-bit:fix/sdk-list-directory-path-boundary

Conversation

@c8dhjp4tyv-bit

Copy link
Copy Markdown

Summary

  • Normalize the project root before resolving the requested directory.
  • Compare the real project root and target paths before listing.
  • Reuse the shared path-containment helper so parent paths and sibling-prefix paths are rejected.
  • Extend the filesystem abstraction and test mock with realpath.
  • Add regression tests for the project root, valid child directories, parent traversal, sibling-prefix traversal, and symlink escapes.

Fixes #463

Validation

  • bun run --cwd common typecheck
  • bun run --cwd sdk typecheck
  • bun run --cwd sdk test — 518 passed, 0 failed
  • bun test common/src/__tests__/project-file-tree.test.ts — 12 passed, 0 failed
  • git diff --check

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: list-directory path traversal — missing path.sep in startsWith check

3 participants