You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A Zero-Padded Stdin Descriptor Crashes the Guard's int() Call #2028
_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
Bound the Guard's Stdin Descriptor Before int() (#2033)