copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

preToolUse hooks are not enforced in subagents

Open sumvalley opened this issue 8 months ago • 1 comments

Describe the bug

preToolUse hooks configured in config.json are correctly enforced on the main agent, but are not enforced on subagents spawned via the task tool. This means any tool restriction can be trivially bypassed by delegating the operation to a subagent.

Affected version

 1.0.12 (Windows)

Steps to reproduce the behavior

 1. Configure a preToolUse hook (at ~\.copilot\config.json) that blocks a specific tool (e.g. sql, powershell, etc.) 2. Have the main agent call that tool → correctly blocked ✅ 3. Have the main agent spawn a subagent and ask it to call the same tool → hook not enforced, tool succeeds ❌

Expected behavior

preToolUse hooks should apply to all agents in the execution tree — main agent and any subagents alike.

Additional context

Any security boundary enforced via hooks can be bypassed using the task tool, including file access controls, command restrictions, and audit logging.

sumvalley avatar Mar 30 '26 01:03 sumvalley

This is an important boundary issue.

If hooks are used for policy, approval, or audit, they need to apply to the whole execution tree. A subagent should not become a way to step outside the root agent's declared controls.

The clean model seems to be:

  • interactive permission prompts can vary by mode
  • user or workspace hooks still run for every tool call
  • hook payloads include parent/root agent identity so downstream logs can preserve lineage

Without that, teams cannot tell whether their hook coverage represents the actual agent run or only the root session.

AgenticThinkingUK avatar May 10 '26 21:05 AgenticThinkingUK