Skip to content

fix(tools): reject parent-directory segments in Claude memory paths - #1652

Open
aniruddhaadak80 wants to merge 1 commit into
supermemoryai:mainfrom
aniruddhaadak80:fix/claude-memory-path-traversal
Open

fix(tools): reject parent-directory segments in Claude memory paths#1652
aniruddhaadak80 wants to merge 1 commit into
supermemoryai:mainfrom
aniruddhaadak80:fix/claude-memory-path-traversal

Conversation

@aniruddhaadak80

Copy link
Copy Markdown

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

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.

1 participant