Skip to content

Reject ':' in _validate_session_id (#544) - #552

Merged
fdaviddpt merged 1 commit into
mainfrom
fix/544
Sep 4, 2026
Merged

fdaviddpt merged 1 commit into
mainfrom
fix/544

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #544

_validate_session_id() in pipeline/extract.py rejected path separators and ".." but not ":". On NTFS a colon in a filename is read as an Alternate Data Stream separator (filename:stream), so a colon-bearing session_id joined into position.<session_id> could silently write to/read from an existing file's ADS instead of a distinct file of its own.

This adds ":" to the same check, shared by find_session() and (since #538/#541) cmd_save_position() and its eviction-loop cleanup.

No caller today supplies a colon-bearing session_id -- every current caller passes Claude Code's own UUID-shaped ids -- so this is hardening against a future caller, the same framing #538 used for the traversal check.

Test plan

  • New file tests/test_validate_session_id_rejects_colon_544.py: a negative case (colon-bearing id must raise) paired with a positive control (a well-formed UUID id must still pass), mirroring tests/test_save_position_validates_session_id_538.py's shape.
  • Red confirmed before the fix: test_colon_bearing_session_id_is_rejected failed with "DID NOT RAISE ValueError".
  • Green after: 8 passed (the new file's 2 tests plus the existing Harden cmd_save_position: validate session_id before it becomes a path component #538 regression file's 6).
  • Platform-independent by design: the exploit mechanics are NTFS-specific, but _validate_session_id itself is a plain string-shape check with no filesystem dependency, so asserting the ValueError directly exercises the real code path on every CI leg (Linux/macOS/Windows x4 interpreters) rather than being gated behind a Windows-only fixture that would only run on one of them.
  • Scoped narrowly to what the issue asked: only ":" is added. Other NTFS-reserved characters (<, >, |, *, ?, NUL, reserved device names) are not concretely reachable through any current caller and were left out per the issue's own scoping.
  • No README change: this is internal hardening with no user-facing behavior change; README does not document _validate_session_id's internal character checks.
  • Self-reviewed: two spawns (Explore reviewer, oss:auditor) against the committed diff both returned NO FINDINGS.

On NTFS a colon in a filename is read as an Alternate Data Stream
separator (`filename:stream`), so a colon-bearing session_id joined
into `position.<session_id>` could silently land as an ADS on an
existing file rather than a distinct file of its own.

_validate_session_id() already rejected '/', '\' and '..'; this adds
':' to the same check, shared by find_session() and (since #538/#541)
cmd_save_position() and its eviction-loop cleanup.

No caller today supplies a colon-bearing session_id -- all current
callers pass Claude Code's own UUID-shaped ids -- so this is hardening
against a future caller, the same framing #538 used for the traversal
check.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7
@fdaviddpt
fdaviddpt merged commit 620a0f1 into main Sep 4, 2026
16 checks passed
@fdaviddpt
fdaviddpt deleted the fix/544 branch September 4, 2026 22:07
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.

_validate_session_id rejects path separators and ".." but not ":", so a colon-bearing session_id can land as an NTFS Alternate Data Stream

1 participant