Repository navigation
Conversation
pipeline/shell.py built the position sidecar path and the evicted-sidecar removal path by interpolating session_id directly into a filename, without calling pipeline.extract._validate_session_id -- the same check find_session() already runs before its own equivalent join. Both shell callers filter the id before Python ever sees it, so this is hardening rather than a fix for a reachable exploit: a future caller reaching cmd_save_position by another route now inherits the same guarantee instead of nothing. Add the check at the top of cmd_save_position, and on each evicted id in the sidecar-cleanup loop, so the loop is independent of that argument. Co-Authored-By: Max <noreply>
Both spawned reviewers found the same regression: the new _validate_session_id(evicted_id) call sat outside the existing try/except OSError block, so a legacy or hand-edited store holding an already-invalid key in `sessions` would now raise ValueError out of cmd_save_position instead of just being a best-effort skip -- aborting the save's own trailing #450 quarantine bookkeeping, and doing so silently, since none of the shell callers check the exit status. Move the validation inside the existing try, catching ValueError alongside OSError so a poisoned evicted id degrades to "sidecar survives a little late" exactly as #353 already documents, rather than crashing. Add a regression test (poisoned legacy eviction id, still evicted, save still lands) proven red against the un-fixed shape and green against this one. Co-Authored-By: Max <noreply>
fdaviddpt
added a commit
that referenced
this pull request
Sep 4, 2026
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. Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7 Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
What
cmd_save_position(pipeline/shell.py) built the position sidecar path(
position.<session_id>) and the evicted-sidecar removal path byinterpolating
session_iddirectly into a filename, without ever callingpipeline.extract._validate_session_id-- the same checkfind_session()already runs before its own equivalent join.
Both current shell callers (
scripts/post-tool-hook.sh,scripts/session-end-hook.sh,scripts/save-session.sh) already filter theid before Python ever sees it, so nothing reachable today was exploitable;
this is hardening, not a vulnerability fix, matching the issue's own
classification -- a future caller reaching
cmd_save_positionby anotherroute now inherits the same guarantee instead of nothing.
Change
cmd_save_positionnow calls_validate_session_id(session_id)at thetop, matching
find_session.evicted_idin the sidecar-cleanup loop is also validated, insidethe existing
try/exceptso a poisoned legacy id (a store written beforethis fix, or hand-edited) degrades to "sidecar survives a little late" --
exactly what the surrounding comment already documents for a failed
unlink -- rather than raising an uncaught
ValueErrorthat would abortthe save already in progress.
Self-review
Two reviewers (
Explore,oss:auditor) were spawned against the firstcommit and both independently found the same regression: the eviction-loop
validation, in its first form, sat outside the
try/except, so a poisonedlegacy id would raise uncaught mid-save -- worse than doing nothing, since
none of the shell callers check the exit status of
save-position. Fixedin the second commit, with a regression test proven red against the
un-fixed shape and green against the fixed one.
Below the bar, not fixed here:
_validate_session_iditself (unchangedby this diff, in
pipeline/extract.py) rejects/,\and..but not:, so a colon-bearing session_id would reachposition.<id>and, onNTFS, could land as an Alternate Data Stream on
position.<prefix>ratherthan a distinct file. This is a pre-existing gap in a function this diff
only calls, shared with
find_sessionand every other caller -- fixing itis a decision about that function's own contract, out of this issue's blast
radius. Reported for filing as a separate issue rather than fixed here.
Tests
tests/test_save_position_validates_session_id_538.py(new): a hostilesession_id(../../etc/evil,foo/bar,foo\bar,..) passeddirectly to
cmd_save_positionmust raise, paired with a positivecontrol that a well-formed id still writes its sidecar -- red before the
fix (4 failed, 1 passed), green after.
must not abort the save -- red against the first-commit shape (1 failed),
green after moving the validation inside the
try.pytest tests/test_save_position_validates_session_id_538.py tests/test_position_store.py tests/test_position_sidecar_353.py-- 57passed. Full
test_commandintentionally not run locally; CI is themerge gate.
Closes #538