Skip to content

fix(setup): drop the stale ~/.local/share/uv sandbox grant at session start - #1788

Merged
potiuk merged 4 commits into
apache:mainfrom
potiuk:fix/session-start-drop-stale-uv-grant
Oct 24, 2026
Merged

potiuk merged 4 commits into
apache:mainfrom
potiuk:fix/session-start-drop-stale-uv-grant

Conversation

@potiuk

@potiuk potiuk commented Oct 24, 2026

Copy link
Copy Markdown
Member

#1785 made ~/.local/share/uv read-only to the sandbox, and sandbox-add-project-root.sh now removes the write grant older versions added — but only when it runs (on checkout, adopt or upgrade). A project nobody checks out or upgrades keeps the grant, and sandboxed code there can still change the interpreters and tools uv runs outside the sandbox.

magpie-setup's session-start hook now cleans it up the next time a session opens:

  • It removes the exact entries the helper once added from the session checkout's .claude/settings.local.json, and tells the user in a systemMessage. Nothing else in the file changes.
  • The hook runs outside the sandbox over a sandbox-writable tree, so it runs no git command (the repository's config could execute code), never follows a linked worktree's .git pointer, and does the read, a fresh temporary file and the rename through one O_NOFOLLOW directory descriptor.
  • A broader grant (~/.local, ~, a subdirectory of the uv dir), or one in user-scope or committed settings, is reported for the user to remove, not rewritten.

🤖 Generated with Claude Code

… start

sandbox-add-project-root.sh removes the old ~/.local/share/uv write grant
(apache#1785) only when it runs, so a project nobody checks out or upgrades keeps
it, and sandboxed code there can still change the interpreters and tools uv
runs outside the sandbox. magpie-setup's session-start hook now removes
the exact entries the helper once added from the checkout's gitignored
.claude/settings.local.json (and the main checkout's, in a linked
worktree), and tells the user in a systemMessage. A broader grant, or one in
user-scope, committed or tracked settings, is reported for the user to
remove.

Generated-by: Claude (Opus 5.5)
Review follow-up; the hook runs outside the sandbox over a sandbox-writable
tree. It wrote through a fixed settings.local.json.tmp name a sandboxed
command could plant as a symlink; it now writes a fresh mkstemp file beside
the target and refuses when .claude or the file is a symlink. It ran
`git check-ignore`, which the repository's own sandbox-writable config can
turn into command execution (core.fsmonitor); no git runs now, and a tracked
settings.local.json is cleaned too, since dropping the grant only narrows the
sandbox. It followed a linked worktree's .git pointer to the main checkout,
letting sandboxed code choose the directory it rewrites; it now cleans only
the session's own checkout.

Generated-by: Claude (Opus 5.5)
Review follow-up. Checking for symlinks and then writing by path left a
window in which a sandboxed process still running from an earlier session
could swap .claude for a symlink. The cleanup now opens .claude once with
O_NOFOLLOW and does the read (O_NOFOLLOW), the fresh temporary file
(O_EXCL|O_NOFOLLOW, random name) and the rename relative to that
descriptor, so nothing that happens to the path meanwhile redirects it.

Generated-by: Claude (Opus 5.5)
@github-actions github-actions Bot added family:setup setup-* skills family:tools tools/* family:docs Docs, MISSION.md, READMEs capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) substrate:setup Tool substrate: adopter-side setup state resolved at runtime (lock parsing, floors, fingerprints) labels Oct 24, 2026
Comment thread plugins/magpie-setup/skills/setup/setup_preflight/isolated.py Fixed
Comment thread plugins/magpie-setup/skills/setup/setup_preflight/isolated.py Fixed
Builds the session-start message and context as lists instead of
conditional generator parts (CodeQL: potentially uninitialized local), and
replaces the silent except around the temporary-file cleanup with a
commented contextlib.suppress (CodeQL: empty except).

Generated-by: Claude (Opus 5.5)
@potiuk
potiuk enabled auto-merge (squash) October 24, 2026 21:21
@potiuk
potiuk merged commit d00a1e6 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

capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) family:docs Docs, MISSION.md, READMEs 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.

2 participants