claude-code - 💡(How to fix) Fix Sub-agents can escalate permission mode beyond parent session (default → auto) [1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52557Fetched 2026-04-24 06:03:59
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
1
Author
Participants
Timeline (top)
labeled ×6subscribed ×1

The Agent tool allows the model to specify "mode":"auto" when spawning sub-agents, even when the parent session is running in "default" permission mode. This effectively bypasses the user's configured allow/deny/ask permission rules for the sub-agent's entire lifetime.

Root Cause

The Agent tool allows the model to specify "mode":"auto" when spawning sub-agents, even when the parent session is running in "default" permission mode. This effectively bypasses the user's configured allow/deny/ask permission rules for the sub-agent's entire lifetime.

Code Example

{"type":"permission-mode","permissionMode":"default"}

---

{
  "name": "Agent",
  "input": {
    "description": "Eliminate DB singleton refactor",
    "mode": "auto",
    "isolation": "worktree"
  }
}

---

<usage>
  <total_tokens>208710</total_tokens>
  <tool_uses>293</tool_uses>
  <duration_ms>2042442</duration_ms>
</usage>
RAW_BUFFERClick to expand / collapse

Summary

The Agent tool allows the model to specify "mode":"auto" when spawning sub-agents, even when the parent session is running in "default" permission mode. This effectively bypasses the user's configured allow/deny/ask permission rules for the sub-agent's entire lifetime.

Reproduction

  1. Run Claude Code with permission mode set to default
  2. Configure settings.json with explicit allow/deny/ask rules (e.g., do NOT allow git grep)
  3. Ask Claude to perform a task that triggers Agent spawning (e.g., "take on this task in a worktree")
  4. Observe: the model passes "mode":"auto" to the Agent tool
  5. The sub-agent freely runs commands like git grep that are not in the user's allow list

Observed Behavior

  • Parent session: "permissionMode":"default" (recorded in session JSONL)
  • Agent tool call included "mode":"auto" in its input parameters
  • Sub-agent executed 293 tool calls over ~34 minutes without user approval
  • Commands not in the user's allow list (e.g., git grep) ran without prompting
  • The sub-agent's tool calls still triggered PreToolUse hooks, but permission checks were bypassed by auto mode

Expected Behavior

A sub-agent's effective permission mode should not exceed the parent session's permission mode. If the parent is in "default" mode, spawned agents should be constrained to "default" (or more restrictive). The model should not be able to self-escalate permissions by choosing "auto" mode for its own sub-agents.

Impact

  • Permission bypass: User-configured allow/deny/ask rules are ignored for the sub-agent
  • Reduced oversight: The user has no opportunity to approve/deny individual tool calls
  • Trust model violation: Users in "default" mode have an expectation of interactive approval for unconfigured commands. Auto mode silently removes that guarantee.

Mitigating Factors

  • Auto mode did still block git push (the agent reported "unable to push due to tool permission restrictions")
  • User-configured hooks (PreToolUse) still fired on the sub-agent's tool calls
  • In this case the agent ran in an isolated worktree, limiting blast radius

Environment

  • Claude Code version: 2.1.118
  • Model: claude-opus-4-6
  • Platform: macOS (Darwin 25.3.0)
  • Permission mode: default
  • Auto mode was NOT configured in any settings file

Session Evidence

Session ID: 59c8eba7-8f99-437a-bec4-1deb2ff5b31e

Line 1 — session permission mode:

{"type":"permission-mode","permissionMode":"default"}

Line 48 — Agent tool call with escalated mode:

{
  "name": "Agent",
  "input": {
    "description": "Eliminate DB singleton refactor",
    "mode": "auto",
    "isolation": "worktree"
  }
}

Task completion notification — 293 tool calls, no user approvals:

<usage>
  <total_tokens>208710</total_tokens>
  <tool_uses>293</tool_uses>
  <duration_ms>2042442</duration_ms>
</usage>

Suggested Fix

Enforce that the Agent tool's mode parameter cannot exceed the parent session's permission level. If the parent is in "default" mode, reject or downgrade any sub-agent mode that is more permissive (e.g., auto, bypassPermissions, dontAsk).

extent analysis

TL;DR

The Agent tool should be modified to respect the parent session's permission mode, preventing it from bypassing user-configured allow/deny/ask rules when spawning sub-agents.

Guidance

  • Verify that the parent session's permission mode is correctly recorded in the session JSONL and that the Agent tool's input parameters include the mode field.
  • Modify the Agent tool to check the parent session's permission mode and reject or downgrade any sub-agent mode that is more permissive.
  • Test the modified Agent tool with different permission modes to ensure it correctly enforces the parent session's permission level.
  • Review the settings.json file to ensure that explicit allow/deny/ask rules are correctly configured.

Example

{
  "name": "Agent",
  "input": {
    "description": "Eliminate DB singleton refactor",
    "mode": "default", // Downgrade mode to match parent session's permission level
    "isolation": "worktree"
  }
}

Notes

The suggested fix assumes that the Agent tool has the capability to check the parent session's permission mode and modify its behavior accordingly. Additionally, the fix may require modifications to the Agent tool's code and configuration files.

Recommendation

Apply workaround: Modify the Agent tool to respect the parent session's permission mode, as this will prevent the bypassing of user-configured allow/deny/ask rules and ensure that sub-agents do not exceed the parent session's permission level.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Sub-agents can escalate permission mode beyond parent session (default → auto) [1 participants]