Skip to content

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

Open
c8dhjp4tyv-bit wants to merge 1 commit into
CodebuffAI:mainfrom
c8dhjp4tyv-bit:recreate/1098-sdk-list-directory-path-boundary
Open

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

Conversation

@c8dhjp4tyv-bit

Copy link
Copy Markdown

Recreated on the rewritten main after #1098 was auto-closed during repository maintenance. This carries the same reviewed change set on the new history.

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

Prior validation before the history rewrite:

  • 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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant