Skip to content

fix(lr-d049): validate loop registry ID to block path traversal#225

Merged
akuehner merged 3 commits into
mainfrom
fix/lr-d049-loop-registry-path-traversal
Jun 11, 2026
Merged

fix(lr-d049): validate loop registry ID to block path traversal#225
akuehner merged 3 commits into
mainfrom
fix/lr-d049-loop-registry-path-traversal

Conversation

@akuehner

Copy link
Copy Markdown
Member

No description provided.

akuehner and others added 3 commits June 11, 2026 09:42
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>
@akuehner akuehner merged commit 6e911f9 into main Jun 11, 2026
@akuehner akuehner deleted the fix/lr-d049-loop-registry-path-traversal branch June 11, 2026 14:00
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