Skip to content

fix(container-gateway-hook): derive the checkout root without repository config - #1804

Merged
potiuk merged 2 commits into
apache:mainfrom
potiuk:fix/gateway-hook-root-without-repo-config
Oct 25, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
potiuk:fix/gateway-hook-root-without-repo-config

Conversation

@potiuk

@potiuk potiuk commented Oct 25, 2026

Copy link
Copy Markdown
Member

A .git directory planted in a sandbox-writable checkout could set core.worktree to a parent directory. git then reports a toplevel that still contains the session's working directory, so the existing containment check passes. But the worktree records are then keyed by a different path, so the main checkout's record is never consulted and its settings are skipped.

The hook now also finds the root the way the filesystem shows it: the nearest directory holding a .git, read without any repository config. It refuses when git's toplevel differs, and whenever core.worktree is set. The new test plants exactly that .git directory; it fails against the previous hook and passes with this change.

🤖 Generated with Claude Code

…ory config

A .git directory planted in a sandbox-writable checkout could set
core.worktree to a parent directory: git then reports a toplevel that
still contains the session cwd (so the existing containment check passes)
but keys the worktree records differently, so the main checkout's record
is never consulted and its grants are skipped. The hook now also finds the
root the way the filesystem shows it, the nearest directory holding a .git,
refuses when git's toplevel differs, and refuses whenever core.worktree is
set. The new test fails against the previous hook.

Generated-by: Claude (Opus 5.5)
@github-actions github-actions Bot added family:setup setup-* skills family:tools tools/* capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) substrate:sandbox Tool substrate: agent isolation, egress control, settings audit labels Oct 25, 2026
@potiuk
potiuk enabled auto-merge (squash) October 25, 2026 00:16
…iscover a bare repo

Review follow-up, defense in depth. The root checks ran only when a .git was
found on the way up. Now core.worktree refuses whether or not one is,
a repository git finds with no .git on the way up refuses, and every git
call runs with safe.bareRepository=explicit, so HEAD / config / objects
planted in a project without .git are never treated as a repository. The
new test is a regression guard: git already declined a toplevel from inside
such a directory, so it did not reproduce as a bypass on the previous hook.

Generated-by: Claude (Opus 5.5)
@potiuk
potiuk merged commit d600695 into apache:main Oct 25, 2026
12 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:setup setup-* skills family:tools tools/* substrate:sandbox Tool substrate: agent isolation, egress control, settings audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant