Skip to content

The Guard's Stdin Redirect Scan Runs Past a Reserved Word #2032

Closed

Description

@ptr727

_redirects_stdin in host-setup/agent-safety/claude/gh-write-guard.py scopes its scan to the loop's own invocation by stopping at the first separator operator. It does not stop at a reserved word, so a redirect on the next command inside a compound command reads as the loop's input bound.

Allowed today, and the loop reads the caller's stdin with nothing bounding it:

if while read l; do sleep 30; done then echo x < f; fi

The < f belongs to echo, not to the loop. bash -n accepts the line and bash runs it. The same holds after do, }, fi, and done of an enclosing compound.

The scan should end where the loop's command ends, which is a reserved word in command position as well as a separator. #1637 is the sibling defect in the process-substitution check one line above it.

Found by a local strict review pass on feature/auto-2028 (#2028). The code predates that branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsAgents instructionsbugSomething isn't workingpre-existingReview finding classed pre-existing per local-strict-review Disposing of Findings

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions