FREE STUDY NOTES · AZ-401

Guard rails for the GitHub Copilot cloud agent

What stops the Copilot cloud agent doing harm: its branch, firewall, workflow approval, reviewer rules and who can assign it work.

From Ultra Transcenders AZ-401 by Tony Rough

An autonomous agent that can read code and push changes needs the same controls as any contributor, plus a few more. GitHub builds several protections in; the engineer’s job is to know what they are, which can be changed, and which gaps remain for the organisation to close.

Built-in protections

Risk Built-in mitigation Can it be changed?
Untrusted people steering the agent Only users with write access can trigger it; comments from others are never passed to it No
Pushing to the wrong place Pushes only to one branch: a new copilot/ branch, or the existing pull request branch when invoked with @copilot; subject to branch protection and required checks Rulesets may block it; admins can add a ruleset bypass for Copilot
Unreviewed merges Opens a draft pull request; cannot mark it ready, approve it or merge it No
Self-approval The person who asked for the pull request cannot approve it No
Unattributed changes A pull request under Copilot’s own identity needs one extra approval where at least one is already required On by default in rulesets (admins can turn off); always applies to branch protection rules
CI running untrusted code Actions workflows wait until a user with write access selects Approve and run workflows Can be set to run automatically
Vulnerable output Built-in CodeQL, GitHub Advisory Database checks on new dependencies (malware and High or Critical CVSS) and secret scanning, plus a Copilot code review pass, with no GitHub Advanced Security licence needed Individual validation tools can be disabled
Prompt injection Hidden characters, such as HTML comments in issues, are filtered out No
Traceability Commits authored by Copilot with the requester as co-author, signed (“Verified”), linking to session logs; audit log events No

The agent firewall

By default the agent’s internet access passes through a firewall that always allows the hosts Copilot needs for GitHub, plus a recommended allowlist of common OS package repositories, container registries, language package registries and certificate authorities. Blocked requests appear as a warning in the pull request body or a comment. Organisation owners configure it on the Internet access page with separate sections for Copilot in the cloud and Copilot code review: Enable firewall and Recommended allowlist can be Enabled, Disabled or Let repositories decide (the default), and Allow repository custom rules decides whether repository admins may add entries. Allowlist entries can be domains (which include subdomains) or URLs (which restrict scheme, host and path). Organisation entries cannot be removed at repository level.

The firewall has documented limits: it covers processes the agent starts through its Bash tool (and, in cloud sandboxes, the built-in Playwright server), not other MCP servers or processes started by setup steps; it works only inside the agent’s environment; and sophisticated attacks may bypass it. It is not compatible with self-hosted runners or with Windows, so those designs must disable it and provide their own network controls.

Common trap: Relying on the agent firewall to stop an MCP server or a setup step from exfiltrating data - the firewall applies to commands the agent runs through its Bash tool, not to other MCP servers or copilot-setup-steps.yml processes.

Setup steps, runners and secrets

When the agent runs on GitHub Actions, .github/workflows/copilot-setup-steps.yml prepares its environment deterministically instead of leaving the model to discover dependencies by trial and error. The file must contain a single job named copilot-setup-steps, and only steps, permissions, runs-on, services, snapshot and timeout-minutes (maximum 59) are honoured. If a step fails, the remaining steps are skipped and the agent starts anyway. Any fetch-depth given to actions/checkout is overridden.

name: "Copilot Setup Steps"
on: workflow_dispatch
jobs:
  copilot-setup-steps:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v7
        with:
          node-version: "20"
          cache: "npm"
      - run: npm ci

runs-on can point at larger GitHub-hosted runners (for more CPU, disk or Azure private networking) or at self-hosted runners; only Ubuntu x64 and Windows 64-bit runners are supported, and GitHub recommends ephemeral, single-use self-hosted runners such as those managed by Actions Runner Controller. Organisation owners can set a default runner type and decide whether repositories may override it. The same file customises Copilot code review unless a separate copilot-code-review.yml is supplied.

The agent receives only Agents secrets and variables, configured at organisation or repository level; it does not see Actions, Codespaces or Dependabot secrets. Names prefixed COPILOT_MCP_ are passed only to MCP servers. In a cloud sandbox only secrets are available, not variables, and secret values are masked in session logs.

Common trap: Storing a package-feed token as an Actions secret for the cloud agent to use - the agent sees only Agents secrets and variables, so the token must be created under Secrets and variables > Agents.

Get the whole book

This note is one section of Ultra Transcenders AZ-401: Designing and Implementing Microsoft Agentic DevOps Solutions, an independent study guide that explains every topic the exam covers by technology, with comparison tables, diagrams and the common traps, plus a glossary linked to Microsoft Learn.

Amazon.co.ukKindlePaperback
Amazon.comKindlePaperback

Free to read with Kindle Unlimited. Opens Amazon in a new tab.

About the book · AZ-401 terms in the glossary · All AZ-401 study notes

More AZ-401 study notes