Content Exclusion Gap: AI Security Boundaries by Mode¶
Content exclusion rules that work for completions and chat can be silently ignored by agent-mode features.
The gap¶
GitHub Copilot's content exclusion feature lets organizations name files that Copilot should ignore. When exclusions are active, Copilot suppresses inline code suggestions in excluded files, and Copilot Chat cannot use those files to generate responses.
These exclusions do not apply to:
- Agent mode in Copilot Chat (IDEs)
- GitHub Copilot CLI
- Copilot coding agent
You exclude a file from completions and chat because it holds secrets, proprietary logic, or compliance-sensitive data. That file stays fully accessible when an agent reads the repository to plan and run tasks.
Security implications¶
Organizations that treat content exclusions as a security boundary may not realize that agent-mode access is unrestricted. The exclusion mechanism was built for the completions and chat model. In that model, Copilot responds passively to what the developer is working on. Agent-mode features work differently. They traverse the repository, read files, and make decisions based on file contents. The exclusion rules do not intercept this access path. GitHub's documentation states directly that content exclusions do not apply to agent mode in IDEs, the GitHub Copilot CLI, or the Copilot coding agent.
The transferable lesson¶
This pattern is not specific to GitHub Copilot. Any AI system with multiple interaction modes risks the same gap:
- Completion mode is passive and responds to the current file
- Chat mode is reactive and answers questions using file context
- Agent mode is active and traverses the repository, reading files on its own
Security rules built for passive modes do not automatically transfer to active modes. Each mode has different access patterns. Verify exclusion mechanisms independently for every mode.
Mitigation strategies¶
Content exclusions do not cover agent modes, so organizations need extra controls:
- Filesystem permissions: restrict read access to sensitive files at the OS or container level so agents cannot reach them in any mode
- Pre-commit hooks: detect and block commits that reference excluded content
- Repository structure: isolate sensitive files in separate repositories with restricted agent access
- Agent-specific instruction files: use AGENTS.md or copilot-instructions.md to tell agents to avoid specific paths (guidance, not enforcement)
- Review gates: require human review of every agent-generated PR that touches sensitive directories
Example¶
A repository has sensitive pricing logic in src/pricing/engine.py. The organization configures a content exclusion in GitHub Copilot settings:
# .github/copilot-exclusions.yml (organization-level setting)
excluded_paths:
- "src/pricing/**"
With this exclusion active:
- Inline completions: Copilot does not suggest code when the developer has
src/pricing/engine.pyopen. The exclusion works as intended. - Copilot Chat (ask mode): pasting content from
engine.pyand asking "explain this" is blocked. The file is excluded from chat context. - Copilot agent mode: a developer asks the agent to refactor the checkout flow to reduce latency. The agent traverses the repository, reads
src/pricing/engine.pyto understand the pricing logic, and puts its contents in the plan it generates. The exclusion does not apply.
The same file the organization meant to protect is fully visible to the agent. The exclusion rule was built for the completions and chat access model. The agent's active traversal path falls outside its scope.
Key Takeaways¶
- Content exclusion rules in Copilot do not apply to Agent mode, CLI, or the coding agent
- Security boundaries designed for completions/chat do not automatically extend to agent interaction modes
- Verify exclusion coverage independently for every interaction mode, not just the original one
- Use filesystem-level controls or repository isolation when content exclusion rules are insufficient
- Instruction-based exclusions (telling the agent to avoid files) are not enforcement — they are guidance
When this backfires¶
The mitigations above are not foolproof:
- Filesystem permissions work only if agents run with restricted OS-level credentials. Many IDE-based agent features inherit the developer's full permissions, so OS restrictions need deliberate credential separation, not just configuration.
- Pre-commit hooks detect after the fact, even when enforcing agent behavior with hooks. An agent that reads a sensitive file but never commits anything leaves no trace in the hook output.
- Repository isolation shifts risk rather than removing it. Sensitive repositories still need their agent access controls reviewed independently, and cross-repo agent tasks can pull credentials or logic across boundaries.
- Instruction-based exclusions (AGENTS.md, copilot-instructions.md) are guidance, not enforcement. A broad enough task prompt can lead an agent to traverse paths the instructions meant to exclude, the task scope security boundary problem, especially if the agent reasons that reading the file is needed to finish the task.
- Review gates on agent PRs catch writes but not reads. If the agent reads sensitive data to build a plan and then produces a PR that does not reference that data directly, the read goes undetected.
The underlying issue is architectural: exclusion policies built for passive modes do not propagate to active modes. Until GitHub or other vendors build exclusion enforcement into the agent traversal layer itself, filesystem-level controls are the only reliable boundary.