Repository navigation
Conversation
STDIN_SESSION_ID reaches save-session.sh's argv below, and that script's own arg loop reads a leading "--dry"/"--force" 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" passed through untouched and silently turned the SessionEnd last-chance flush into a dry-run preview (no summary written, position not advanced). Mirrors the `-*` remedy #576 already applied at the sibling agy-stop-hook.sh call site. 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
…611) * Reject a leading dash in post-tool-hook.sh's session_id guard (#610) 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 * Fix stale line numbers and #600 merge-status overclaim in the #610 fix 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 * Fix docs/windows-skip-triage.md prose-vs-table drift (#612), pushed one 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 --------- 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
scripts/session-end-hook.sh'sSTDIN_SESSION_IDguard allowed a leading dash through itscharacter class (
*[!A-Za-z0-9._-]*does not exclude-), so asession_idof exactly--dryonthe SessionEnd hook's stdin payload passed unrejected and reached
save-session.sh's argv asbash "$SAVE_SCRIPT" "$STDIN_SESSION_ID" --force.save-session.sh's own arg-parsing loop reads aleading-dash value as a FLAG rather than a positional session id —
--drysetsDRY_RUN=true,silently turning the SessionEnd last-chance flush into a no-op dry-run preview: no summary written,
position not advanced, log line reads like an ordinary run.
This mirrors, at a sibling call site, the exact gap issue #576 already closed in
scripts/agy-stop-hook.sh(commit a07f08e) — that fix's own comment noted thesession-end-hook.shguard did not close this same gap, and it did not, until now.
Fixes #600.
Fix
Adds
-*to the case pattern, rejecting any leading-dashsession_id(falls back to discovering thesession id from the latest transcript file instead, same as when no
session_idis sent at all) —identical remedy shape to #576's own fix at the sibling call site.
Tests
Added
TestFlagShapedSessionIdIsRejected600totests/test_session_end_hook_345.py, using themodule's existing harness (
_make_env,_wire_hook,_run_hook). Must-fire case drives the hookwith
session_id="--dry"and asserts the stubbed pipeline still reachescall-haiku(proving a realflush happened, not a silent dry-run no-op). Paired must-not-fire positive control proves the
fixture is live with an ordinary session id.
Red (pre-fix):
1 failed, 1 passed—Green (post-fix):
tests/test_session_end_hook_345.py—9 passed in 3.03s.test_command(pytest) was not run in full; ran the module's own tests plus checkedlane_setup.py's cross-cutting guards for the touched files (both named guards do not exist in thisrepo, so nothing extra applied). CI is the authority for the full matrix.
Docs / changelog
README.md(this repo's onlydocs_targetsentry) read against the fix — still accurate, no changeneeded (internal argv-hardening, invisible from the hook-table description).
changelog.d/600.fixed.mdadded;
python3 .oss/assemble_changelog.py --checkpassed.Self-review
Spawned
Exploreandoss:auditoragainst the committed diff.oss:auditorreturnedNO FINDINGSacross four checklist classes (silent absence, guard-did-not-run, untrusted-boundary, cross-platform
band).
Explorereturned one finding:A third, still-unpatched call site of the identical guard gap exists in
scripts/post-tool-hook.sh.Its
STDIN_SESSION_IDguard (lines 404-406) carries the exact pre-#600 pattern, and itsSTDIN_SESSION_ID_TRUSTEDbranch (lines 549-556) only requiresSTDIN_TRANSCRIPT_PATHto name anexisting file — it never checks that
STDIN_SESSION_IDcorresponds to that transcript. A payloadwith a real
transcript_pathand a craftedsession_idof--drytherefore reachesnohup "$SAVE_SCRIPT" "$SESSION_ID" ... &(line 893) unrejected, turning every per-tool-callbackground save into a silent no-op dry run — same class, same silent-swallow consequence, at a
call site this issue's own brief flagged as an open question ("closed by a different mechanism...
reasoned... not observed to fire live"). Verified by direct code reading: that assumption does not
hold, since the existence check validates the transcript path, not the session id, so it does not
actually close the gap.
Not fixed in this diff, and this paragraph is the pr_anchor for that decision:
post-tool-hook.shis a different call site with its own more complex trust-boundary logic that needs its own design
decision (whether/how to also verify the transcript actually names the given session id) and its own
TDD pass against a background (
nohup ... &) code path with a different test harness shape thanthis issue's synchronous-exit fixture — fixing it here would roughly double this diff's size and
scope. Recommend filing a follow-up issue against
scripts/post-tool-hook.sh:404-406/549-556/893, same class as #600 and #576.🤖 Generated with Claude Code
[AI-generated]