Skip to content

fix: decide and document the transcript-path trust boundary for manual callers - #438

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/431
Aug 29, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/431

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #431.

Closes the remainder of #424's containment (read) row, the one item still blocking 0.24.0 after #430 hardened the two hooks with no transcript_path of their own to offer.

The decision

No containment check was added inside pipeline/host.transcript_path() / pipeline/extract.py's find_session(). That function is the ONE channel both a legitimately-supplied value (from session-start-hook.sh/session-end-hook.sh's own validated stdin payload, exported fresh on every run) and an untrusted ambient one travel through. A containment rule narrow enough to actually matter -- restricted to the project directory, or to CLAUDE_CONFIG_DIR/~/.claude -- would also reject the legitimate value on a host or a mount this repo does not model: CLAUDE_CONFIG_DIR is itself relocatable (#166) and is Claude Code's own layout, not a Codex- or Gemini-neutral one, which is exactly the host-specific seam pipeline/host.py's own module docstring already declines to invent. Trusting wherever the host says the transcript lives, rather than reconstructing or gating it, is the whole point of #407 -- reconstruction is what #157/#174/#263 got wrong.

So the decision is #424's second option: a caller with no hook preamble of its own -- a manual scripts/save-session.sh run, scripts/doctor.sh, a direct python3 -m pipeline.extract -- trusts the ambient environment by design, the same way it already trusts $PATH or $HOME. The hooks that run on every tool call with no human watching stay the hardened boundary.

That decision is now written down rather than left implicit: pipeline/host.py's and pipeline/extract.py's docstrings and the README's transcript-path section state which callers are hardened and which are trusted, and why. scripts/doctor.sh now WARNs -- naming the value, with control characters stripped so it cannot forge a second report line -- when it finds REMEMBER_TRANSCRIPT_PATH already set in its own environment, checked ahead of path resolution so an unresolvable install does not also silence it.

Self-review

Both the Explore reviewer and oss:auditor ran against the first commit and returned real findings, addressed in a second commit:

  • Argued down: the reviewer proposed a CLAUDE_CONFIG_DIR/HOME containment check as a cheap middle ground. Investigated and rejected -- CLAUDE_CONFIG_DIR is Claude-Code-specific (confirmed by the very comment the reviewer cited), so gating on it would break legitimate Codex/Gemini transcripts, and a broader $HOME containment would break the existing test_supplied_transcript_path_is_used_verbatim positive control, which deliberately supplies a path outside $HOME to represent a legitimate host-reported location on a different drive/mount. Full argument is in pipeline/host.py's docstring.
    • Below-bar: one finding is real and has no reachable caller in this diff -- worth recording here rather than as a filing. It is this: the "never under the project it describes" phrasing in the first commit's docs was overstated, since CLAUDE_CONFIG_DIR is user-relocatable; that one is fixed (below), but the underlying observation that these docstrings assert absolutes about host behaviour this repo cannot fully verify (Codex/Gemini transcript layouts are simply not known here) is a standing property of the whole module, not a defect introduced by this diff, and there is no single call site to point a fix at.
  • Fixed: the reviewer's overstated "never under the project it describes" wording (README.md, pipeline/host.py).
  • Fixed: both the reviewer and the auditor independently found doctor.sh's new WARN sat after resolve-paths.sh's own early exit 0 on failure, so it silently never fired on an unresolvable install -- moved earlier, confirmed red-then-green.
  • Fixed: the auditor found the WARN printed the raw env value with no control-character stripping, unlike doctor.sh's own --json branch's _json_escape() (added for No way for an external caller to resolve a {slug}-keyed external store without reimplementing session_dir_slug #408 for exactly this reason) -- an embedded newline could forge a second report line. Piped through tr -d '[:cntrl:]'.
  • Fixed: the auditor found the new test file's win32 skip was module-wide even though one test never touches bash or the filesystem -- scoped per-test.

Test plan

  • tests/test_transcript_path_trust_431.py (new, 6 tests) -- watched fail before the fix, pass after, for both the doctor.sh ordering and control-character findings (temp-swapped scripts/doctor.sh back to the pre-fix version, confirmed red, restored, confirmed green)
  • Full suite: 1796 passed, 43 skipped (platform-specific, expected), before and after the review round
  • python3 .oss/assemble_changelog.py --check passes with the new changelog.d/431.security.md fragment

fdaviddpt and others added 2 commits August 29, 2026 04:24
…l 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]>
- 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]>
@fdaviddpt
fdaviddpt merged commit 6a5f5ca into main Aug 29, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/431 branch August 29, 2026 03:09
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.

save-session.sh, doctor.sh and a direct pipeline.extract call still trust an ambient REMEMBER_TRANSCRIPT_PATH

1 participant