fix(tools): reject parent-directory segments in Claude memory paths - #1652
Open
aniruddhaadak80 wants to merge 1 commit into
Open
fix(tools): reject parent-directory segments in Claude memory paths#1652aniruddhaadak80 wants to merge 1 commit into
aniruddhaadak80 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary\nFixes path-traversal bypass in \ClaudeMemoryTool.isValidPath\ (\packages/tools/src/claude-memory.ts). The previous check looked for the substring ../\ only, so /memories/..\ and /memories/foo/..\ passed validation and were treated as valid memory paths. Now any path segment equal to ..\ is rejected (Windows ..\\\ still rejected as before).\n\n## Changes\n- \packages/tools/src/claude-memory.ts: segment-based ..\ rejection in \isValidPath\n- \packages/tools/src/claude-memory.test.ts: regression tests for /memories/.., /memories/foo/.., /memories/../secrets.txt\ asserting \Invalid path\ with no document fetch\n\n## Testing\n- Repro before fix via isolated check: /memories/..\ -> true, /memories/foo/..\ -> true (should be false)\n- \�unx vitest run src/claude-memory.test.ts: 13 passed\n- \�unx vitest run src/tools-shared.test.ts src/claude-memory.test.ts: 26 passed\n- \�unx biome check src/claude-memory.ts src/claude-memory.test.ts: clean\n- Pre-existing, unrelated: \�unx tsc --noEmit\ fails on \ sconfig baseUrl\ (upstream #1545 class), \src/tool-operations.test.ts\ fails on @ai-sdk/provider-utils lazyValidator\ export mismatch — both reproduce without this change\n\n## Notes\n- No behavior change for valid paths (/memories, /memories/, /memories/notes.txt\ still accepted)\n- AI assistance used for drafting; all code run and verified locally by contributor