Skip to content

fix(container-gateway-hook): run in bash privileged mode; fail closed without a home - #1793

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/gateway-hook-privileged-mode
Oct 24, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/gateway-hook-privileged-mode

Conversation

@potiuk

@potiuk potiuk commented Oct 24, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #1789. The container-gateway session hook runs outside the sandbox; two more inputs to it came from the session environment, which project settings can set:

  • Bash read the environment before the hook's first line. BASH_ENV (a file bash executes), exported functions (BASH_FUNC_git%% would replace git) and SHELLOPTS all applied. The shebang is now #!/bin/bash -p: privileged mode ignores all three. That only holds when the hook is executed directly — as bash <path> nothing inside the script can undo what the shell already imported (an exported function can shadow even exec) — so the setup, verify and docs now wire it by its absolute path, executed directly: a ~ in the hook command is also expanded from $HOME by the launching shell. isolated-setup-verify flags a ~/$HOME or bash/sh hook command.
  • The account-home lookup failed open. When the account database's home cannot be determined, the hook now does not start, rather than falling back to $HOME alone.

Type of change

  • Cross-cutting (sandbox / agent isolation)
  • Skill change (isolated-setup-install / isolated-setup-verify: absolute, direct hook command)
  • Documentation (secure-agent-setup.md)

Test plan

  • prek run on the changed files passes
  • pytest tools/agent-isolation/tests/test_container_gateway_hook.py (outside /tmp/claude*, where the suite does not skip): 71 passed
  • New regression tests with the hook executed through its shebang — BASH_ENV, exported git, SHELLOPTS each fail on the hook before this change; exported exec guards the re-exec trap rejected during review
  • roborev review clean

RFC-AI-0004 compliance

  • Sandbox — closes a way for a project's settings to get code run outside the sandbox

Gen-AI disclosure: drafted with Claude Code (Opus 5); reviewed by the submitter.

🤖 Generated with Claude Code

… without a home

Bash honours BASH_ENV, exported functions and SHELLOPTS before the
hook's first line runs, and all three come from an environment project
settings can set. The shebang is now #!/bin/bash -p, which ignores them;
it only applies when the hook is executed directly, so setup, verify and
the docs wire it by absolute path, never through bash/sh or a ~ that the
launching shell would expand from $HOME. Refuse to start when the
account home cannot be determined.

Generated-by: Claude Opus 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:sandbox Tool substrate: agent isolation, egress control, settings audit labels Oct 24, 2026
@potiuk
potiuk enabled auto-merge (squash) October 24, 2026 22:27
@potiuk
potiuk merged commit 67ee53c into apache:main Oct 24, 2026
12 checks passed
@potiuk
potiuk deleted the fix/gateway-hook-privileged-mode branch October 24, 2026 23:26
potiuk added a commit that referenced this pull request Oct 25, 2026
Since #1793 the gateway hook is registered by its absolute path, which
differs between macOS (/Users/<you>) and Linux (/home/<you>). In a
~/.claude/settings.json synced across machines that path points at
nothing on the next machine and the gateway never starts. The setup guide
and install Step L now put the hook in ~/.claude/settings.local.json when
the user settings are synced, with a "Fixing your other machines" passage
(move the entries, then a jq one-liner per machine). Verify check 12a and
the update skill flag a registered path that does not exist on the machine
they run on, and a synced registration as drift.

Generated-by: Claude (Opus 5.5)
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:sandbox Tool substrate: agent isolation, egress control, settings audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant