Skip to content

log() writes untrusted model reply text unsanitized, so an embedded newline forges a second log entry — sanitize once in scripts/log.sh, not per call site #599

Closed

Description

@fdaviddpt

Routed out of the self-review on #597 / #598, where it was reported as report-for-filing rather than fixed in that diff. Filing it so the class has a home; nothing about it blocked that pull request.

The shape

The reject-log lines in the NDC branch of scripts/save-session.sh write the first 80 bytes of the model's reply into the log with no newline handling:

log "ndc" "REJECTED (...): $(head -c 80 "$HAIKU_TEXT_FILE" 2>/dev/null)"

Since #593 the reply is model-authored from the conversation's own text, so a newline inside those 80 bytes puts attacker-influenced content at column 0 of the log — which reads as a second, forged log entry to a person or a script parsing that file.

Why it is not #598's to fix

The identical shape already existed before that diff: the sibling IS_REJECTED log line one branch above, and again at save-session.sh:788. #598 added one more call site to a pattern that was already there. Fixing it at the new site alone would leave the class open and make the codebase read as though it had been handled.

The fix that actually removes the class

Sanitize in scripts/log.sh's log() itself, once, for every caller. That is a design decision this issue does not pre-make: escape the newline, strip it, or refuse the message. Whichever is chosen, it wants a test with a positive control — a message carrying an embedded newline must produce exactly one log entry, paired with a case proving an ordinary multi-field message still logs at all.

Ranking

The auditor left the row open between forges and misreports and asked for a maintainer read. My reading is misreports — can ship behind a filed issue — not forges: the ranking table's forges row is about text reaching column 0 of a receipt this loop parses, and .remember/'s log file is read by a human rather than by a maintainer-loop receipt parser. If something downstream is in fact parsing that log as structured input, that reading is wrong and this becomes blocking; say so on this issue rather than assuming the label above settles it.

[AI-generated]

Activity

  1. added
    bug
    priority:low
    filed-by-loop
    on Sep 6, 2026
  2. self-assigned this
    on Sep 6, 2026
  3. added
    cohort-7
    lane-capture
    on Sep 6, 2026
  4. added a commit that references this issue on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcohort-7filed-by-looplane-capturepriority:low

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions