Repository navigation
fix(gate): refuse a nested coding agent started with its approvals off - #1119
Merged
sandstream merged 1 commit intoNov 27, 2026
Merged
sandstream merged 1 commit into
sandstream merged 1 commit into
Conversation
`claude --print --dangerously-skip-permissions`, `claude -p --permission-mode bypassPermissions`, `codex exec --dangerously-bypass-approvals-and-sandbox` and `gemini --yolo -p` all passed gate-bash with exit 0, while the gate already refuses `git commit --no-verify` for skipping a control. They now exit 2. src/nested-agent-bypass.ts holds a table of agent CLIs and the approval-off flags their vendors document (Claude Code, Codex, Gemini, Qwen, Cursor, Copilot, Kiro, Droid), and reads through shells, wrappers, npx and the Windows shells. It is pure and exported for agent-audit's grant reader. Wiring in install-gate.ts is two lines. Found by kit-research artex-cc-vs-kit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
sandstream
deleted the
claude/web-kit-status-sync-p6fg9a-protected-nested-agent-bypass
branch
November 27, 2026 11:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Protected — owner merges (touches
src/install-gate.tsandsrc/commands/gate.ts).Found by kit-research
docs/research/artex-cc-vs-kit.md(kit-research PR #236), Measurement 5 and Plan item 1:gate-bashrefusesgit commit --no-verify, but passed these four with exit 0:claude --print --dangerously-skip-permissions "…"claude -p --permission-mode bypassPermissions "…"codex exec --dangerously-bypass-approvals-and-sandbox "…"gemini --yolo -p "…"claude -p "…"(control)What changes
src/nested-agent-bypass.ts: a table of agent CLIs and the approval-off flags their vendors document. Each entry quotes its doc URL; flags I could not find in vendor docs are left out (listed below).sh -c/bash -lc,eval,env/sudo/xargs/timeout(the gate's existing wrapper set),npx/bunx/npm exec/pnpm dlx(by package name too, e.g.@anthropic-ai/claude-code@latest),$(…)and backticks,cmd /c, and PowerShell-Command/-EncodedCommand. Here-document bodies that are data are skipped, the same way the other policy refusals skip them.decideBashGate(install-gate.tsgoes from 1311 to 1313 lines against the 1339 limit; with feat(install-gate): block a prebuilt binary install without a kit triage release receipt #1109 (+7) and fix(gate): refuse npx <bin> when the bin is another package's npm name #1111 (+3) it would be 1323).src/commands/gate.ts: the refusal no longer gets "Triage it first" stapled on (one regex alternative, as forcannot be undone).starts a nested agent with its approvals off (claude --dangerously-skip-permissions): it would run commands nobody approves, outside this session's permission prompts. Drop the flag: the nested session then asks before each tool, and --allowedTools pre-approves only the tools it needs. Running an agent unattended is the person's decision, not the agent's (fail-closed).docs/ENFORCEMENT_AND_AUDIT.md(gate-bash section); fragmentchanges/nested-agent-bypass.md.adr check: 4 enforced ADRs, no new violations.Coverage table
claude--dangerously-skip-permissions,--permission-mode bypassPermissions(and=)codex--dangerously-bypass-approvals-and-sandbox,--yolo,-a neverwith-s danger-full-access(and long /=forms)gemini--yolo,-y,--approval-mode yoloqwen--yolo,--approval-mode yoloagent,cursor-agent--force,-f,--yolocopilot--allow-all-tools,--allow-all,--yolo,COPILOT_ALLOW_ALL=<true>kiro-cli--trust-all-toolsdroid--skip-permissions-unsafeNot covered, and why:
--full-auto: not in the current Codex CLI reference (the documented relative is--approve-for-me, which keepson-requestapprovals and theworkspace-writesandbox).-a neveralone keeps the sandbox, and-s danger-full-accessalone keeps approvals, so neither is refused alone.--allow-dangerously-skip-permissions: it adds the mode to the cycle but does not start in it.--dangerously-allow-all: Amp's own docs document only theamp.dangerouslyAllowAllsetting, not the flag, so it is left out.auggie): no approval-off flag in their CLI docs.--auto-approvedefaults to true). Refusing everycline "<prompt>"is an owner decision, so it is not in this PR.q chat --trust-all-tools): the AWS reference page now redirects away and I could not quote it; its successorkiro-cliis covered. Antigravity has no documented CLI flag.-c approval_policy=…overrides, or env vars other thanCOPILOT_ALLOW_ALL.API for agent-audit (stable)
All three are pure: no I/O, no environment reads.
nestedAgentRefusal(heredocs)is the gate's wrapper and is not meant for other callers.Tests
src/nested-agent-bypass.test.ts(52 tests): every flag in the table, 13 carrier forms, 12 negatives (claude --version, a prompt that mentions the flag, the flag after--,codex -a neveralone, …), the argv API, and the four repro commands throughdecideBashGate.src/gate-bash-refusal.test.tsgains one compiled-CLI case (exit 2, flag named, no triage advice).Before (on main, classifier present but not wired):
After:
All
install-gate*andgate-bash*tests: 1141 pass, 0 fail.Platforms
Tested on Linux. The Windows forms (
cmd /c, PowerShell-Command/-EncodedCommand,claude.cmd,codex.exe) are covered by unit tests and run in the Windows CI shards. macOS is unverified: no CI job runs it, though nothing here touches the filesystem or processes.Owner choices
agent, soagent --forcefrom some other tool would also be refused (fail-closed).-yfor Gemini is deprecated but still documented, so it is refused.--no-verify. The person runs the command themselves.Generated by Claude Code