Repository navigation
Merged
Conversation
…R_TRANSCRIPT_PATH, and the sidecar membership check stops claiming a comparison it never made #424: pipeline/host.transcript_path() trusts REMEMBER_TRANSCRIPT_PATH once it names a real file, and pipeline/extract.py's find_session() returns that value before _validate_session_id()'s traversal check ever runs. A value set anywhere in the ambient environment therefore bypasses the traversal validator entirely and is read, summarized, and pushed by hooks.d/after_save/50-git-backup.sh. Only session-start-hook.sh and session-end-hook.sh have a legitimate transcript_path to offer, each freshly extracted from their own stdin payload; scripts/post-tool-hook.sh and scripts/user-prompt-hook.sh now unset REMEMBER_TRANSCRIPT_PATH near the top of each, the same pattern #417 already applied to REMEMBER_HOOK_CWD in these same two files. #426: the #353/#403 sidecar membership check logged "disagrees with last-save.json" whenever a session id was absent from the sessions map, but [ -f ] passes on an unreadable file and $(< file) cannot distinguish "read empty" from "the read failed" -- so an absent last-save.json, an unreadable one, and a genuinely evicted session all produced the identical comparison claim, though a comparison only happened in the last case. Behaviour was already correct in all three; only the receipt overstated what was checked. Closes #424 Closes #426 Co-Authored-By: Max <noreply>
…BER_TRANSCRIPT_PATH reader pipeline/host.transcript_path()'s docstring and README.md's transcript-path section both described the existence-check gate without noting that it is not a containment check -- find_session() returns whatever this function hands it before its own traversal validator runs. post-tool-hook.sh and user-prompt-hook.sh now unset the variable before it can reach them; nothing protects consolidation, /remember:doctor, or a manual pipeline.extract invocation from the same ambient-environment leak. Found in self-review (Explore + oss:auditor) of the #424/#426 commit; the exposure itself in those three call sites is reported to the maintainer for filing rather than fixed here, since it reopens the same host.transcript_path() containment question the #424 issue left open and doctor.sh belongs to a sibling lane. Co-Authored-By: Max <noreply>
3 tasks done
fdaviddpt
added a commit
that referenced
this pull request
Aug 29, 2026
…l callers (#438) * fix: decide and document the transcript-path trust boundary for manual callers (#431) Closes the remainder of #424's containment (read) row. The two per-tool-call hooks (#430) stay the hardened boundary; a manual save-session.sh run, doctor.sh, and a direct pipeline.extract invocation trust the ambient REMEMBER_TRANSCRIPT_PATH by design -- documented in pipeline/host.py, pipeline/extract.py and README.md, with doctor.sh now warning loudly when it finds the variable set rather than staying silent about it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix: harden #431's transcript-path decision against self-review - doctor.sh's REMEMBER_TRANSCRIPT_PATH warning moved ahead of path resolution, so an unresolvable install does not also silence it via resolve-paths.sh's own early exit -- it did before. - the warning strips control characters from the value before printing it, so an embedded newline cannot forge a second report line. - host.py's docstring and README.md now give the sharper reason a containment check was rejected: transcript_path()/find_session() is the one channel both a legitimately-supplied and an ambient value travel through, so a check narrow enough to matter would also reject the legitimate one; and the "known session store" is Claude-Code-specific, not host-neutral, contradicting the earlier "never under the project" overstatement. - the new test file's win32 skip is now scoped per-test instead of module-wide, since one test never touches bash or the filesystem. Found by this branch's own self-review (Explore + oss:auditor) before handoff. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- 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.
#424 (blocking, security)
pipeline/host.transcript_path() trusts REMEMBER_TRANSCRIPT_PATH once os.path.isfile() passes, and pipeline/extract.py's find_session() returns that value BEFORE _validate_session_id()'s traversal check ever runs. A value set anywhere in the ambient environment -- an .envrc in a cloned repo, a modified dotfile -- bypasses the traversal validator entirely and is read, summarized into the memory store, and committed/pushed by hooks.d/after_save/50-git-backup.sh.
Only session-start-hook.sh and session-end-hook.sh have a legitimate transcript_path to offer -- each extracts it fresh from its own stdin payload on every run. scripts/post-tool-hook.sh and scripts/user-prompt-hook.sh, the two hooks that trigger routine autosaves and have no transcript_path of their own, now
unset REMEMBER_TRANSCRIPT_PATHnear the top of each -- the same pattern #417 already applied to REMEMBER_HOOK_CWD in these same two files.Judgement call, as flagged in the brief: chose the unset-in-hooks framing over a containment check inside host.transcript_path() itself. A per-host expected-transcript-directory is not knowable across Claude Code, Codex and Gemini CLI (Gemini documents no such variable at all), and pipeline/host.py's own module docstring already declines to invent a host-specific seam for exactly that reason. The unset is correct regardless of whether cross-hook environment reuse is reachable on any live host -- neither hook has a payload of its own to offer, matching the #417 precedent's own reasoning, which this PR does not re-litigate.
Not fixed here, reported for filing below: self-review (an Explore reviewer) found and I verified live that scripts/save-session.sh (documented manual usage), scripts/doctor.sh, and a direct
pipeline.extractinvocation are NOT covered by this unset and remain exploitable by the identical ambient-leak scenario --REMEMBER_TRANSCRIPT_PATH=/etc/hosts python3 -c "from pipeline import extract; print(extract.find_session('../../etc/passwd'))"returns/etc/hostsunconditionally. This reopens the very containment-in-host.py question the #424 issue left open, and scripts/doctor.sh belongs to a sibling lane (fix/427), so it is not fixed in this PR.Docs: pipeline/host.py's transcript_path() docstring and README.md's transcript-path section both now say plainly that this is an existence check, not a containment check, and name which callers are and are not covered by the new unset.
Closes #424
#426 (non-blocking, receipt quality)
scripts/post-tool-hook.sh's #353/#403 sidecar membership check logged "disagrees with last-save.json" whenever a session id was absent from the sessions map -- but
[ -f ]passes on a present-but-unreadable file and$(< file)cannot distinguish "read empty" from "the read itself failed", so an absent last-save.json, an unreadable one, and a genuinely evicted session all produced the identical comparison claim, though a comparison only happened in the last case. Behaviour was already correct and conservative in all three (fall back to read-position); only the receipt overstated what was checked.Chose to add a status check (a new
_LAST_SAVE_STATEof absent/unreadable/read) over narrowing the message, since the three states are genuinely distinguishable cheaply and a maintainer reading a log line about a specific state is more useful than one that says nothing.Worth flagging in review: the natural first attempt,
$(< "$LAST_SAVE_FILE" 2>/dev/null), is wrong -- adding any token inside the substitution (including a redirect) defeats bash's no-fork$(< file)fast path, turning it into an always-succeeding empty command that reads nothing. The stderr redirect has to sit OUTSIDE the substitution:{ X=$(< "$file"); } 2>/dev/null. Caught by the pre-existing test suite going red on the wrong version; the correct form is in the committed diff and is exercised by three new tests plus the existing positive control.Closes #426