Repository navigation
Conversation
STDIN_SESSION_ID reaches save-session.sh's argv on the background nohup save path (`nohup "$SAVE_SCRIPT" "$SESSION_ID" ... &`), and that script's own arg loop reads a leading-dash value as a FLAG rather than a positional session id -- the character class this guard applied (`[!A-Za-z0-9._-]`) already allowed a leading dash, so a session_id shaped exactly like "--dry", paired with a real transcript_path, passed through untouched and was trusted by the STDIN_SESSION_ID_TRUSTED branch (which verifies only that a transcript_path was supplied, not that this id actually names it -- an established #468 trust decision this fix does not revisit). save-session.sh's own auto-detect fallback then correctly identified the real session from the transcript_path, but with DRY_RUN silently true: no summary written, no position advanced, log line reads like an ordinary run. Third call site in this class, after #576 (agy-stop-hook.sh) and #600 (session-end-hook.sh). A new end-to-end fixture drives the real post-tool-hook.sh and reaps the forked save-session.sh, pinned red against the unpatched guard (the "=== DRY RUN ===" banner reaching the autonomous log for a crafted session_id) and green after, with a positive control proving an ordinary session_id still produces a genuine save. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
Self-review (Explore) caught the new test's docstrings/messages citing pre-comment-insertion line numbers for post-tool-hook.sh (off by +15, the exact width of the #610 rationale comment this same commit inserted). Corrected to the actual committed line numbers: the guard case statement at 419-421 (was cited 404-406), STDIN_SESSION_ID_TRUSTED at 564-576 (was 549-557), and the nohup dispatch at 908 (was 893). Audit (oss:auditor) caught a second, more substantive overclaim: the original commit message, changelog fragment and test docstring described #576 and #600 as both "already closed" siblings. #576 (agy-stop-hook.sh) is merged into this branch's history; #600 (session-end-hook.sh, PR #609) is not -- `git merge-base --is-ancestor 511e3d3 HEAD` fails, and #609 is still open. session-end-hook.sh in this tree still carries the pre-#600 vulnerable pattern; that is a fact about an unmerged sibling PR, not something this commit introduces or is responsible for fixing, but this commit's own prose should not have implied it was already fixed. Both are documentation-only corrections: the guard fix and its test's assertions are unchanged and still pass (2 passed). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
…ne row further by #610 CI on PR #611 (windows-latest, py3.11) failed in tests/test_windows_skip_triage_prose_totals_595.py: this PR's own new row (tests/test_post_tool_dry_flag_injection_610.py) grew the table to 104 rows / 84 unclear, but four prose sentences elsewhere in the doc still cited the pre-existing stale totals (102 / 82) -- a pre-existing drift already filed as #612 (two earlier PRs, #605 and #606, each merged green against their own base and left the prose one row further behind), which this PR's own table addition made one row worse and is why the failure surfaced specifically on this branch. Re-derived the correct totals directly from the table itself (104 total rows, 84 unclear, 8 convertible, 12 not-convertible -- the latter two already matched) rather than trusting any externally-reported numbers, and updated all four prose citations: "## The count: 104, not 107", "finds **104** modules", "not that read. 84 modules.", "bulk of these 104 reasons". Confirmed against the live table rather than assumed. tests/test_windows_skip_triage_prose_totals_595.py: 3 failed, 2 passed before this fix (confirmed locally); 7 passed (that module plus its sibling table-diff guard, test_windows_skip_triage_497.py) after. This also resolves the concern #612 was filed for -- the prose now matches the table exactly, with no residual drift. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
fdaviddpt
added a commit
that referenced
this pull request
Sep 7, 2026
…) (#615) The doc restated four of its own table's counts (total module count, three times; convertible/not-convertible/unclear verdict counts, once each) as free prose next to the table that already carries them as structured data. A reactive test (#595) caught a mismatch after the fact, but the numbers still drifted three times in quick succession (#595, #596, a follow-up on #611) -- each time because a PR adding one table row was reviewed and merged green against its own stale base, before a sibling PR's prose fix had landed. A same-PR test cannot see a drift introduced by a different PR's base. This removes the class rather than the next instance: the prose numbers are deleted, so the table is the only place any of these counts live and there is nothing left for a PR to leave out of sync. The old reactive test (tests/test_windows_skip_triage_prose_totals_595.py) is replaced by tests/test_windows_skip_triage_no_stale_prose_counts_613.py, which guards against one of these numbers creeping back into the prose by hand, with a positive control proving the detector still fires on #595's own original sentences. Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c 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
post-tool-hook.sh'sSTDIN_SESSION_IDguard (the case pattern at what is nowpost-tool-hook.sh:419-421) never excluded a leading dash -- the same character-class gap
already closed at two sibling call sites, #576 (
agy-stop-hook.sh, merged) and #600(
session-end-hook.sh, PR #609, not yet merged as of this PR). A crafted PostToolUsepayload with
session_id: "--dry"paired with a real, existingtranscript_pathpassed theguard untouched, was trusted by the
STDIN_SESSION_ID_TRUSTEDbranch (which verifies only thatsome transcript_path was given, never that this session_id names it -- an established #468
trust decision, see "Judgment call" below), and reached
save-session.sh's argv on thebackground
nohupsave path asnohup "$SAVE_SCRIPT" "$SESSION_ID" ... &.save-session.sh'sown arg loop reads a leading-dash value as the
--dryFLAG rather than a positional session id.With no other positional arg,
save-session.sh's own auto-detect then correctly identifies thereal session from its transcript directory -- so the exploit's damage is not misattribution, it
is DRY_RUN silently true: no summary written, no position advanced, and nothing about the hook's
own exit code (always 0; it only forked a background process) reveals it.
Fixes #610.
Judgment call (issue explicitly asked this be stated)
Chose to close only the guard-level gap (adding
-*to the case pattern), mirroring #576/#600exactly. Did not strengthen the
STDIN_SESSION_ID_TRUSTEDbranch to positively verify thesession_id names the resolved transcript. Reasoning:
STDIN_TRANSCRIPT_PATHis independentlyexistence-checked before it can be trusted at all, and once the leading-dash class is closed the
residual risk is a misattribution (a well-formed but wrong session_id paired with a real
transcript_path for a different session) rather than an argv-injection -- a materially
different, already-documented #468 trust decision (
pipeline/host.py's docstring,tests/test_transcript_path_trust_431.py) that this fix deliberately does not reopen.TDD
Red (before the fix, exploit test failed):
session_id="--dry"with a real transcript reachedthe
=== DRY RUN ===banner insave-session.sh's own log --1 failed, 1 passed(exploitfailed, positive control passed).
Green (after the fix):
2 passed. The positive control (an ordinary session_id) independentlyproves the harness reaches a real Haiku spawn via a faked
claudebinary (same techniquetests/test_spawn_containment.pyalready uses), so the exploit assertion is not passing merelybecause nothing ran.
New fixture note: an artificial
transcript_paththat does not live under the real Claude Codesession directory makes
save-session.sh's own session-id auto-detect fail outright ("invalidsession ID") rather than reproduce the silent dry-run -- the working fixture places the
transcript at the correct, real session-directory location, which is also the realistic shape a
genuine payload's
transcript_pathalways has.Self-review (both findings fixed in a second commit)
(off by +15, matching the new rationale comment this commit inserted). Corrected.
already-closed siblings. Verified: agy-stop-hook.sh does not sanitise conversationId before passing it as argv to save-session.sh (splices) #576 is merged into this branch (
git merge-base --is-ancestor a07f08e HEADsucceeds); session-end-hook.sh: unextended dash-guard lets --dry reach save-session.sh via SessionEnd session_id #600 is not (git merge-base --is-ancestor 511e3d3 HEADfails -- it lives only in open PR Reject a leading dash in session-end-hook.sh's session_id guard (#600) #609). Corrected the prose across the commit comment,changelog fragment and test docstring.
session-end-hook.shin this tree still carries thepre-session-end-hook.sh: unextended dash-guard lets --dry reach save-session.sh via SessionEnd session_id #600 vulnerable pattern, but that is fix/600's lane and already tracked/PR'd -- not
something this PR fixes or files anew.
Docs / changelog
changelog.d/610.fixed.mdadded.docs/windows-skip-triage.md: added a row for the new test module'swin32skip (bashsubprocess dependency, same reason/verdict as its sibling
tests/test_post_tool_session_id.pyit is modeled on).
README.md(docs_targets): grepped forsession_id/transcript_path/dry run/guard-relatedcontent; no user-facing documentation of this internal guard's security guarantee exists to
update -- no change needed.
Not run
The repo's full
pytestsuite was not run locally (per policy: CI is the gate across the wholematrix; only the targeted new test file plus its closest sibling
(
tests/test_post_tool_session_id.py) and the changelog-fragment/windows-skip-triageself-checks were run here).
Closes #610
🤖 Generated with Claude Code
Verified by the maintainer
This PR's own new
docs/windows-skip-triage.mdtable row (added above) pushed a pre-existingprose-vs-table drift in that same file one row further out of sync (#612 tracks the original
instance, caused by two earlier PRs -- #605 fixing #595, #606 fixing #596 -- each merging green
against its own stale base). CI caught it on this PR (windows-latest, py3.11:
tests/test_windows_skip_triage_prose_totals_595.py), and I resumed the dispatched agent(commit
49ad889, same branch) to re-derive the four prose totals directly from the table andfix them in place, rather than dispatching a fresh lane for what was already this lane's own
file. Independently confirmed the root-cause chain via
git merge-base --is-ancestorand byreading
docs/windows-skip-triage.md's own git history (7819c5e,d5123ee) before resumingthe lane, and re-read the follow-up commit's diff before pushing it.
Filed #613 for the recurring pattern behind this (prose duplicating a table's own counts,
drifting on every PR that is not rebased past the last one to touch the table) -- this PR and
#612 fix one more instance of it, not the underlying design.
[AI-generated]