No timeout on claude invocations — audit can hang indefinitely #6
Labels
No labels
shellcheck
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
bc1bb/claude-code-audit#6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The
run_auditfunction invokes theclaudeCLI without any timeout. There is notimeoutwrapper, noCLAUDE_API_TIMEOUT, and no watchdog mechanism.Location
audit.sh, lines 254–258 (Forgejo mode) and lines 270–274 (non-Forgejo mode):Risk
If the Claude API becomes unreachable, returns a persistent error, or the session enters an infinite tool-call loop (e.g., due to a prompt injection causing repeated retries), the script hangs indefinitely. Because the outer loop calls
run_auditsynchronously, a single stuck invocation blocks all subsequent audits. In a cron-scheduled context this causes the next run to overlap with the stuck one, potentially leading to multiple hung processes consuming resources and exhausting API quota.Suggested fix direction
Wrap the
claudeinvocation withtimeout <seconds>(e.g.,timeout 1800 claude ...). Log a warning and callsave_statewith the pre-audit SHA when the timeout fires, so the repo is re-audited on the next run rather than silently skipped. The--max-turnsflag (used with--opus) partially mitigates this but does not bound wall-clock time.Severity
minor
Found by
Automated audit by Claude Code