fix: path traversal vulnerability in listDirectory (#463) - #469
Conversation
|
I think this fixes the shared-prefix case, but
So the old prefix bug is closed, but an attacker can still escape the project root through a checked-in or generated symlink. I would either compare |
|
👋 Hi! Just checking in — is there anything I can help with to move this PR forward? Happy to address any feedback! 🙏 |
|
👍 Looks good to merge — clean fix, thanks for contributing! |
|
Looks good to merge! [merge promotion] |
|
Hi @ALL, gentle reminder that this PR is waiting for review. Happy to make any changes — just let me know! 🙏 |
|
Thanks for this contribution! Bumping for visibility. |
|
➿ bump (R337) |
|
Good catch and clean fix. The original check The fix is correct: requiring One minor consideration for whoever ports this: on Windows, Small, focused, and low-risk. No tests included, but the diff is small enough that a reviewer can verify correctness by inspection; a follow-up unit test covering the sibling-directory case would strengthen this further and is worth requesting if this becomes a template for future security PRs. |
a9c9167 to
b5665ec
Compare
Summary
Root Cause
The original check
!resolvedPath.startsWith(projectPath)fails when:/home/user/project../project-evil/home/user/project-evil/home/user/project-evil.startsWith(/home/user/project) = true (incorrectly allows)Fix
This matches the pattern already used in
code-search.ts(lines 52-53).Testing
The fix ensures:
src,../sibling)..,../../etc)../project-evil)