Skip to content

fix(setup): session-start hook runs a trusted, isolated interpreter - #1791

Merged
potiuk merged 2 commits into
apache:mainfrom
potiuk:fix/session-hook-trusted-python
Oct 24, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
potiuk:fix/session-hook-trusted-python

Conversation

@potiuk

@potiuk potiuk commented Oct 24, 2026

Copy link
Copy Markdown
Member

The magpie-setup SessionStart hook runs outside the sandbox but took python3 from PATH, which project settings can set. It now uses only fixed system and Homebrew locations (Python 3.11+), which no sandbox grant may cover. It runs them with -I -S and a one-line bootstrap instead of PYTHONPATH and -P, so no PYTHON* variable, site-packages or the opened project reaches sys.path. uv-managed interpreters are left out: trusting them needs the gateway hook's full writable-root checks, and this hook only prints a notice. Without a system Python it prints its own notice alone.

🤖 Generated with Claude Code

The SessionStart hook runs outside the sandbox but took python3 from PATH,
which project settings can set and which is often a uv-managed interpreter.
It now uses only fixed system and Homebrew locations, then uv's managed
CPython (read-only to the sandbox since apache#1785), first one 3.11 or newer,
and runs it with -I and a one-line bootstrap instead of PYTHONPATH and -P,
so no PYTHON* variable, user site-packages or the opened project reaches
sys.path.

Generated-by: Claude (Opus 5.5)
Review follow-up. Trusting uv-managed interpreters needs the gateway hook's
full writable-root checks, and this hook only prints a notice, so it now
takes only fixed system and Homebrew locations (which no sandbox grant may
cover) and otherwise prints its own notice alone. It runs with -I -S:
setup_preflight needs only the standard library.

Generated-by: Claude (Opus 5.5)
@github-actions github-actions Bot added family:setup setup-* skills family:tools tools/* substrate:setup Tool substrate: adopter-side setup state resolved at runtime (lock parsing, floors, fingerprints) labels Oct 24, 2026
@potiuk
potiuk enabled auto-merge (squash) October 24, 2026 22:11
@potiuk
potiuk merged commit e4aa7a6 into apache:main Oct 24, 2026
11 checks passed
potiuk added a commit that referenced this pull request Oct 25, 2026
Ships the fixes merged since 0.9.0.dev202610241347 to marketplace installs:
the container-gateway hook hardening (#1784, #1789, #1790, #1793, #1804),
host-only uv state (#1785), session-start cleanup of the stale uv grant
(#1788), the trusted session-start interpreter (#1791), the sandboxed prek
home (#1792) and per-machine gateway hook registration (#1797).

Generated-by: Claude (Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

family:setup setup-* skills family:tools tools/* substrate:setup Tool substrate: adopter-side setup state resolved at runtime (lock parsing, floors, fingerprints)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant