Skip to content

agy-stop-hook.sh's newline-delimited stdout protocol has no escaping; an embedded newline shifts every later field (misreports) #578

Closed

Description

@fdaviddpt

Filed from release-auditor round 1 on the v0.27.0..HEAD delta (2026-09-05).

Class: misreports -- can ship behind a filed issue (non-blocking), with a stated escalation condition below.

scripts/agy-stop-hook.sh:96-125 marshals four payload fields through a newline-delimited stdout protocol (print() per field in the embedded python3 -c, then sed -n 1p...4p). The protocol has no escaping, so a newline inside any field shifts every later field by one line.

Observed on the auditor's machine, with a control that fired:

--- CONTROL (well-formed payload) ---
CONVERSATION_ID=[abc-123]   TRANSCRIPT_PATH=[/tmp/t.jsonl]   WORKSPACE_PATH=[/proj]   PARSE_STATUS=[ok]
--- conversationId contains an embedded newline ---
CONVERSATION_ID=[abc]       TRANSCRIPT_PATH=[EVIL]           WORKSPACE_PATH=[/tmp/t.jsonl]  PARSE_STATUS=[/proj]

Consequences, all certain from the code: REMEMBER_TRANSCRIPT_PATH is exported with a value from a field nobody named; CLAUDE_PROJECT_DIR (the root under which memory is written) is exported with a different wrong field; and _PARSE_STATUS != "ok", so the #568 warning arm fires and names the wrong reason.

The three sibling hooks reject exactly this at entry (session-end-hook.sh:156-159 and :177-181, both *$'\n'*|*$'\r'*), with the comment explaining that a path legitimately contains slashes and dots and cannot share STDIN_SESSION_ID's character allowlist. The new adapter carries neither arm.

Escalation condition (stated for the maintainer to decide, not ranked here): if a route exists by which a party other than agy itself sets conversationId, this becomes containment (write) -- a mutating route whose write root comes from an argument -- which blocks unconditionally under the ranking table. The auditor could not establish such a route within this audit, so it is not ranked there. The partial brake is scripts/resolve-paths.sh:326, [ ! -d "$PROJECT_DIR" ], which soft-fails when the shifted value is not an existing directory -- a brake, not a containment check.

Fix that removes the whole finding: reject \n/\r in these fields at entry (same as the sibling hooks), or emit the four fields as JSON instead of newline-delimited lines.

[AI-generated]

Activity

  1. added
    bug
    priority:medium
    filed-by-loop
    cohort-6
    on Sep 5, 2026
  2. self-assigned this
    on Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcohort-6filed-by-looppriority:medium

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions