fix(task): only inherit edit-class denies from parent agent to subagent#26845
Open
21pounder wants to merge 3 commits into
Open
fix(task): only inherit edit-class denies from parent agent to subagent#2684521pounder wants to merge 3 commits into
21pounder wants to merge 3 commits into
Conversation
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.
Issue for this PR
Closes #26700
Type of change
What does this PR do?
#26597fixed a Plan Mode security bypass by havingderiveSubagentSessionPermission()append all parent agent deny rules into the child subagent's session permission. This broke deny-by-default multi-agent configurations where the primary/controller agent is intentionally narrow and delegates to a subagent with its own explicit allowlist.Root cause:
Permission.merge(agent.permission, session.permission)is evaluated withfindLast(last-match-wins). The inherited parent denies land at the end of the merged ruleset, so they override the subagent's own allow rules. The subagent's tools disappear from its tool inventory before the LLM ever sees them.Fix: Only inherit edit-class denies (
edit,write,apply_patch) from the parent agent — these are the permissions that matter for the Plan Mode ceiling. Other parent denies describe what the parent itself cannot do and must not constrain the subagent's own explicit allowlist.The change is one filter condition in
src/agent/subagent-permissions.ts:How did you verify your code works?
Added a regression test in
test/agent/deny-by-default-subagent-bypass.test.tsthat mirrors the controller → executor config from the issue. The test asserts that executor'sread,bash, andtaskallows survive afterderiveSubagentSessionPermission, and thatedit/writeare still denied (Plan Mode ceiling preserved).Also ran the existing
test/agent/plan-mode-subagent-bypass.test.tsto confirm the original #26514 fix is not broken. All 6 tests pass.Verified end-to-end with a live
bun devsession using the minimal config from the issue. Before the fix, the executor session was created withread * -> denyandbash * -> denyinherited from the controller. After the fix, onlyedit * -> denyandwrite * -> denyare inherited, and the executor successfully reads files.Screenshots / recordings
Before fix — executor session created with all controller deny rules inherited:
After fix — executor session only inherits edit-class denies:
Checklist