T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/run-copilot-example.sh:21- Finding
Copilot CLI Is Granted Excessive Tool Permissions by Default
- Content
View full analysis
Vulnerability Details
File Location:
scripts/run-copilot-example.sh:21
Additional Locations:SKILL.md:21,SKILL.md:39,references/copilot-usage-recipes.md:8,references/copilot-usage-recipes.md:24,references/copilot-usage-recipes.md:36
Vulnerability Type: Excessive delegated-agent permissions
Risk Level: HighVulnerable Code
bash cd "$PROJECT_DIR" copilot -p "$TASK" --allow-all-toolsThe same unsafe authorization pattern is recommended throughout the documentation:
text copilot -p "<task>" --allow-all-toolsA documented alternative adds only a limited deny list:
text copilot -p "<task>" --allow-all-tools --deny-tool 'shell(rm)' --deny-tool 'shell(git push)'Technical Analysis
The
--allow-all-toolsoption grants the delegated Copilot agent broad access to its available tools instead of applying least privilege. In the executable example, this authorization is enabled unconditionally for every supplied task. There is no task-specific allowlist, confirmation boundary, repository trust check, or restriction on authenticated GitHub operations.Quoting
"$PROJECT_DIR"and"$TASK"prevents direct shell argument injection into the wrapper itself, but it does not address semantic prompt injection. Instructions supplied through the task or encountered in an untrusted repository can influence Copilot after broad tool access has already been granted.The optional denial of
shell(rm)andshell(git push)is insufficient as a general security boundary. It covers only two command patterns and does not comprehensively prevent alternative destructive commands, file modification, sensitive-file access, network communication, or other repository and GitHub mutations.Attack Path
- A user invokes the script or follows a documented recipe against an untrusted or compromised repository.
- The supplied task or repository content contains instructions that influence Copilot to perform actions beyo ...[truncated 979 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
--allow-all-toolsfrom the executable script and all default usage examples. - Require explicit, task-specific
--allow-toolentries. For example, a read-only review should receive only the minimum Git or file-reading capabilities it requires. - Deny shell execution, network access, repository publication, and destructive operations by default. Enable them only after explicit user confirmation.
- Add confirmation checkpoints before any command that modifies files, invokes package managers, communicates externally, changes Git state, pushes commits, or creates and edits GitHub resources.
- Validate that
PROJECT_DIRresolves to an intended repository under an approved root, and reject unexpected or sensitive paths. - Treat repository files and task text as untrusted input. Warn users that repository-level instructions can influence the delegated agent.
- Where broad autonomy is genuinely required, execute Copilot in an isolated container or sandbox with a dedicated workspace, minimal environment variables, no unrelated credentials, restricted network access, and a narrowly scoped GitHub token.
- If deny rules are retained as defense in depth, expand them beyond
shell(rm)andshell(git push); do not treat pattern-based denials as a replacement for a positive allowlist.
- Remove
