Skip to content

A Zero-Padded Stdin Descriptor Crashes the Guard's int() Call #2028

Closed

Description

@ptr727

_redirects_stdin in host-setup/agent-safety/claude/gh-write-guard.py calls int(fd) on a redirect's descriptor prefix after only a tok.isdecimal() check, so nothing bounds its length. Python 3.11 and later raise ValueError converting a digit string of more than 4300 digits, the hook exits 1, which is a non-blocking hook error, and the command runs with no check at all.

Bash reads a zero-padded descriptor as descriptor 0, so the crash is reachable with a command bash actually runs. A while read l; do sleep 30; done loop whose stdin redirect is spelled with 4400 zeros before <, reading /dev/zero, crashes the hook, where the same loop with a bare 0< is denied. A descriptor made of 4400 ones also crashes the hook, but bash rejects that line as a syntax error, so only the zero-padded form leaks.

The fix is the one feature/auto-1634 applies to the timeout signal number: strip leading zeros and compare the remainder, or bound its length, before any int() call. A self-test row with a zero-padded descriptor over 4300 digits pins it.

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

Activity

  1. added
    bugSomething isn't working
    agentsAgents instructions
    pre-existingReview finding classed pre-existing per local-strict-review Disposing of Findings
    on Sep 29, 2026
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