loopx icon indicating copy to clipboard operation
loopx copied to clipboard

[Bug]: Claude adapter bakes an unquoted interpreter path, so a Python under a spaced path never starts and the --harden gate fails open

Open JasonBuildAI opened this issue 1 month ago • 0 comments

Preflight

  • [x] I searched existing issues and discussions for this behavior.
  • [x] This report is not an unpatched security vulnerability.
  • [x] The report and attachments contain no credentials or private/internal material.

Issue origin

Observed or reproduced in a real environment (native Windows 11, cp936 console, Python 3.11).

LoopX version or commit

aedb376db (main), loopx/claude_goal_mode/scripts/install.py

Host or runtime surface

Claude Code

LoopX area

Host or runtime integration

Problem

Who is affected: Windows users of the Claude Code adapter whose selected interpreter lives under a path that contains a space - the python.org all-users install (C:\Program Files\Python311\python.exe), or any profile directory with a space (C:\Users\John Smith\...). That is the common Windows combination, because on those hosts python3 resolves to the 0-byte WindowsApps alias, so the installer correctly falls back to python, which is exactly the spaced all-users path (the fallback landed in #6229, which named this quoting residual as its successor).

What goes wrong: install.py bakes the selected interpreter into three machine-executed command strings - the --harden PreToolUse hook, the statusline, and the /loopx slash command with its allowed-tools rule - without quoting it. Claude Code runs those strings through a shell, which splits the unquoted program path at the first space, so the command never starts Python.

Severity: the failure is silent and the security-relevant surface fails open. The hook exits non-zero with empty stdout, which Claude Code treats as a non-blocking hook error, so the tool call proceeds ungated instead of being denied by the documented fail-closed should_run gate. The statusline renders nothing and /loopx never runs.

Minimal reproduction

  1. Give any host a runnable Python under a path that contains a space, e.g. a directory junction (or copy) at C:\Program Files\Python311 pointing at a real Python 3.11 install, and put that directory on PATH so shutil.which("python") returns it while python3 is absent or the dead WindowsApps alias.
  2. python loopx/claude_goal_mode/scripts/install.py --scope project --project <tmp> --harden --skip-mcp
  3. Read the baked command from <tmp>/.claude/settings.json and run it the way Claude Code does: through a shell, with the event JSON on stdin (for example subprocess.run(command, shell=True, input=event, capture_output=True)).
  4. The statusline command in the same file and the !`...` line of <tmp>/.claude/commands/loopx.md bake the same interpreter.

Expected behavior

The baked command starts the confirmed-runnable interpreter: the --harden gate returns its decision (for example {} when no goal is armed instead of being skipped), the statusline renders its segment, and /loopx runs the setup helper.

Actual behavior

The shell splits the path and nothing reaches Python:

  • hook command D:\...\Program Files\Python311\python.EXE "D:/.../hooks/goal_policy.py" -> rc=1, empty stdout, stderr 'D:\...\Program' is not recognized as an internal or external command -> the tool call is not gated at all;
  • statusline command -> rc=1, empty stdout, so no segment is rendered;
  • the /loopx command body bakes the same unquoted path, so the command never runs.

With the interpreter token quoted, the same three surfaces work on the same host: the hook exits 0 and prints {}, and the statusline exits 0 with its "no goal here" line.

Sanitized diagnostics

# before (unquoted interpreter token)
command: <SPACED_PY>\python.EXE "<PLUGIN>/hooks/goal_policy.py"
rc: 1
stdout:
stderr: '<SPACED_PY>' is not recognized as an internal or external command

# after (quoted interpreter token, same host, same settings)
command: "<SPACED_PY>\python.EXE" "<PLUGIN>/hooks/goal_policy.py"
rc: 0
stdout: {}

Additional context

Follow-up to the merged #6229, whose slice boundary named this residual: "an interpreter path containing spaces is still interpolated unquoted into the hook/statusline command strings and the allowed-tools rule, so a confirmed-runnable interpreter in a spaced directory reproduces the same silent-dead-command symptom".

JasonBuildAI avatar Oct 11 '26 16:10 JasonBuildAI