[PR #7473] fix: prevent subagent permission bypass via tools field inheritance #12412

Open
opened 2026-02-16 18:17:19 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7473

State: open
Merged: No


Summary
Fixes a security vulnerability where subagents bypassed permission restrictions due to direct tools array inheritance from parent agents.
Problem
Agents with restricted tool access could access parent agent tools they shouldn't have permission to use. The tools field was being spread directly from agent config, bypassing permission evaluation.
Solution

  • Exclude tools field from agent config spread to prevent inheritance
  • Filter tools by agent-specific permission rules in ToolRegistry
  • Apply permission filtering in session initialization and prompt construction

Fixes: #7474
Related: #5894, #3808, #7296, #6527

Test Coverage
4 test files with comprehensive coverage validating agents cannot access tools outside their permission scope.

Verified manually to finally fix this issue. I had been stuck on 1.0.200 for few days due to this and having a rather complex multi-sub-agent configuration that relies on permissions guard rails working correctly.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7473 **State:** open **Merged:** No --- **Summary** Fixes a security vulnerability where subagents bypassed permission restrictions due to direct tools array inheritance from parent agents. **Problem** Agents with restricted tool access could access parent agent tools they shouldn't have permission to use. The `tools` field was being spread directly from agent config, bypassing permission evaluation. **Solution** - Exclude `tools` field from agent config spread to prevent inheritance - Filter tools by agent-specific permission rules in ToolRegistry - Apply permission filtering in session initialization and prompt construction Fixes: #7474 Related: #5894, #3808, #7296, #6527 **Test Coverage** 4 test files with comprehensive coverage validating agents cannot access tools outside their permission scope. Verified manually to finally fix this issue. I had been stuck on 1.0.200 for few days due to this and having a rather complex multi-sub-agent configuration that relies on permissions guard rails working correctly.
yindo added the pull-request label 2026-02-16 18:17:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12412