fix(lr-d049): validate loop registry ID to block path traversal#225
Merged
Conversation
msg.id from WS messages loop_registry_files and loop_registry_save_files was used directly in path.join without validation, allowing a client to supply a path-traversal payload (e.g. ../../../etc/passwd) and read or write files outside .claude/loops/. Fix: enforce ^loop_[A-Za-z0-9_-]+$ on the ID before any path operation, plus a defense-in-depth path.resolve/startsWith check. Both handlers (files read and save) are guarded. Invalid IDs receive loop_registry_error. Regression tests added to test/security.test.js section 18 (7 tests). All 260 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…logical tests - Extract module-level validateLoopId() from project-loop.js and export it; all loop-dir path construction routes through the shared helper. - Guard triggerFromQueue() in project-loop.js: validate loopFilesId (which includes client-supplied linkedTaskId from schedule_create) before any path.join call. - Guard register() in scheduler.js: validate caller-supplied data.id at store time so a tainted ID cannot persist to later path construction. - Rewrite section 18 tests to call the real exported validateLoopId and drive handleLoopMessage via a minimal ctx stub; deleting the local re-implementation that made the tests tautological. - All 261 tests pass (0 fail). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s nit) Circular import prevents scheduler.js from calling validateLoopId() from project-loop.js directly. Added a comment noting the mirror relationship and the drift risk so future changes to the allowlist don't miss one site. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
No description provided.