security-guidance 2.0.8: sg-python.sh interpreter probes have no timeout, so a non-returning python3 blocks every hook
Component: plugins/security-guidance 2.0.8, hooks/sg-python.sh
Platform: Windows 11 Pro 10.0.26200 x64, Git for Windows bash 5.3, Claude Code 2.1.283
Summary
probe() (lines 59-63) runs each candidate interpreter directly, with no time bound. The bare-interpreter pass (lines 92-94) and the fallback pass (lines 106-108) both try python3 first. When python3 resolves to something that never returns, the shim blocks until the outer hook timeout. This happens on every hook that goes through the shim (UserPromptSubmit, PostToolUse and the other events in hooks/hooks.json).
We hit this with the App Execution Alias for python3.exe from the Windows Python install manager (PythonSoftwareFoundation.PythonManager 26.3.240.0). The alias did not return in the non-interactive hook environment, so every hook stalled until its timeout. Disabling the alias restored normal behavior.
Minimal reproduction (no alias needed)
- Create a stub that never returns. Make a file named
python3in a directorySTUB, with the two lines#!/bin/shandsleep 60, and mark it executable. - Control run:
timeout 20 bash "$PLUGIN/hooks/sg-python.sh" "$PLUGIN/hooks/security_reminder_hook.py" < /dev/null - Stub run, with the stub first on PATH:
PATH="STUB:$PATH" timeout 20 bash "$PLUGIN/hooks/sg-python.sh" "$PLUGIN/hooks/security_reminder_hook.py" < /dev/null
Observed on this host:
- The control run exits 0 in 378 ms.
- The stub run exits 124 after 20,046 ms, which is the external timeout. A working
pythonis on PATH the whole time.
Expected
The shim skips a bad candidate after a short bound and falls through to python or py -3.
Suggested fix
- Bound each probe, for example with
timeout 5when it is available, or with a background probe and a watchdog. - On Windows and MSYS, skip
python3when it resolves underWindowsApps, where the App Execution Alias lives.
Related failure modes of the same selection loop, with different symptoms: #6085 and #6251 (an MSIX Python is selected, then fails with ENOENT), and #5024 (hardcoded version list).
Source: anthropics/claude-plugins-official