Skip to content

fix(agent-audit): a grant to start a nested agent holds all three trifecta legs, and is named - #1127

Merged
sandstream merged 4 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-protected-audit-nested-agent
Nov 27, 2026
Merged

sandstream merged 4 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-protected-audit-nested-agent

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Protected — owner merges. This PR is stacked on #1119 (nested-agent-bypass, the shared classifier) and imports nestedAgentBypass and nestedAgentCli from it. It also carries #1121 (the rule ledger), merged in, because the Codex and Cursor cases need the ledger's classes. Merge #1121 and #1119 first; this diff then shrinks to its own commit.

Found by kit-research#236 (artex-cc-vs-kit), Measurement §5 "Gap repro" and Plan step 2. Also kit-research#239 (prismor-always-allowed-rules-vs-kit), which re-records the same fixture.

What changes

nestedAgentGrant(arg) in src/agent-trifecta.ts reads a shell grant using the gate's own table from src/nested-agent-bypass.ts, so the gate and the audit share one table. There is no separate internal table.

  • approvals off: the grant's literal words carry a flag that turns the agent's approvals off. Examples: claude --print --dangerously-skip-permissions:*, claude -p --permission-mode bypassPermissions *, codex exec --dangerously-bypass-approvals-and-sandbox, gemini --yolo, npx -y @anthropic-ai/claude-code --dangerously-skip-permissions.
  • arbitrary flags: an agent CLI is followed by a wildcard, so any flag can follow, including the approvals-off ones. Examples: claude:*, claude -p *, codex exec:*, and Cursor Shell(claude).
  • An exact command (claude --version, bare claude) stays narrow.

Both kinds now hold all three trifecta legs and count as a write, the same as Bash(bash:*). Each also gets a named row:

  • nested agent with approvals off: <unit>, severity high;
  • nested agent with arbitrary flags: <unit>, severity medium.

The rule ledger gives Codex prefix_rule and Cursor Shell grants the same class and the same named rows (agent rules: nested agent with …).

Before / after

scripts/nested-demo.sh (scratch): a fresh project with one allow rule in .claude/settings.json, or one Codex rule.

Grant origin/main this branch
Bash(claude --print --dangerously-skip-permissions:*) ✓ lethal trifecta no agent holds … ! write access without confirmation, ! nested agent with approvals off: main session, ! lethal trifecta: main session
Bash(claude:*) ✓ … ! write access …, ! nested agent with arbitrary flags: main session, ! lethal trifecta: main session
Bash(claude --version) ✓ … ✓ … (narrow)
.codex/rules/default.rules: prefix_rule(pattern=["codex","exec","--dangerously-bypass-approvals-and-sandbox"], decision="allow") ✓ … (rule not read) ! agent rules: nested agent with approvals off, class all three legs, writes, nested agent with approvals off, unsandboxed

Test: src/agent-audit-nested-agent.test.ts. On main it fails at import, because nestedAgentGrant does not exist there. On this branch, 59/59 pass across it, agent-trifecta, agent-rule-ledger and the flag-surface tests.

Harness coverage

  • Claude Code: settings grants and subagents, through the trifecta.
  • Codex: prefix_rule.
  • Cursor CLI: Shell(…).
  • Gemini CLI: run_shell_command(…).

The last three go through the ledger. Agents the shared table names: claude, codex, gemini, qwen, cursor-agent, copilot, kiro-cli, droid. Antigravity and Copilot rule stores are not read; see #1121.

Test-Growth: trailer: the 661 net new test lines are mostly #1119's and #1121's. This PR's own test is about 125 lines.

macOS is unverified. The code is pure string handling, with no paths.


Generated by Claude Code

…ule classes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bash(claude --print --dangerously-skip-permissions:*) and Bash(claude:*)
passed the trifecta audit while Bash(bash:*) warned. nestedAgentGrant()
reads a shell grant with the gate's shared table (nested-agent-bypass.ts):
approvals-off flags give "nested agent with approvals off", a wildcard after
an agent CLI gives "nested agent with arbitrary flags". Both hold all three
legs and the write row, like Bash(bash:*). The rule ledger gives Codex
prefix_rule and Cursor Shell grants the same class and named rows.

Found by kit-research#236 (artex-cc-vs-kit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test-Growth: this branch is stacked on #1119 (nested-agent-bypass tests) and carries #1121 (rule ledger tests); its own new test is src/agent-audit-nested-agent.test.ts, about 125 lines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at 35d279b584e7: not approved.

  • 1524 changed lines, over the 1500-line limit for a gate-only approval

Base automatically changed from claude/web-kit-status-sync-p6fg9a-protected-nested-agent-bypass to main November 27, 2026 11:27
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at 1985ebdf4d6b: gates passed. All 33 checks passed on this commit, no file is in a protected class, 5 files and 204 lines changed. This approval is deterministic; it does not judge what the change is for.

@sandstream
sandstream merged commit 8926ced into main Nov 27, 2026
33 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a-protected-audit-nested-agent branch November 27, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants