MSBA-370 · Lesson 7 of 12 · 18 min
Sandboxes and permissions
▶ Video coming soon A video version of this lesson is on the way.
Seraphine led the seventh session, because it was the one she cared about most. She began with a story from Skerry's first month of agent use. A developer had asked agent mode on his laptop to "clean up the old test fixtures". The agent found a folder of fixture files, a script that regenerated them from a staging database, and an environment variable holding the staging password. It ran the script. Nothing was harmed, because staging was a copy, but the agent had reached a database the developer had forgotten he could reach. "The agent did nothing wrong by its own lights," Seraphine said. "It used what was there. Our job is to decide what is there."
This lesson covers how agents are contained: sandboxes, the cloud agent's firewall and token, secrets, and the permission and autonomy choices the GH-600 outline places under guardrails. MSBA-371 completes the guardrails domain with policies, human-in-the-loop design and audit.
What a sandbox is
A sandbox is an environment that limits what code running inside it can affect. For agents, a sandbox answers four questions: which files can it read and write, which programs can it run, which network destinations can it reach, and which credentials does it hold? A strong sandbox also starts from a known state and is thrown away afterwards, so that nothing the agent did persists unless someone keeps it on purpose.
The cloud agent is sandboxed by design. Each session runs in a fresh environment powered by GitHub Actions, with a clone of one repository, a token limited to that repository, and outbound network access controlled by a firewall. When the session ends the environment is discarded. Local agents are not sandboxed by default; they run with the developer's account, files, network and credentials. Teams that want local agents contained can run them inside a dev container or a virtual machine with only the project files and no personal credentials, and some editors and Copilot CLI have been adding sandboxing options for terminal commands.
The cloud agent's firewall
By default the cloud agent's internet access is restricted by a firewall. GitHub maintains a recommended allow list of destinations the agent commonly needs, such as package registries for popular languages, operating system package mirrors and certificate services. Repository administrators can turn the recommended list off, add their own destinations, or, in GitHub's words, disable the firewall entirely, which GitHub advises against. When the firewall blocks a request, the agent's pull request or session log shows a warning naming the blocked destination, so a person can decide whether it was legitimate.
| Setting | Effect | When to use |
|---|---|---|
| Firewall on, recommended allow list on | Common package registries reachable; everything else blocked | Most repositories; the default |
| Firewall on, custom entries added | Specific extra destinations reachable | A private package registry or documentation site the agent needs |
| Recommended list off, custom list only | Only named destinations reachable | Repositories with strict data rules |
| Firewall off | Unrestricted outbound access | Rarely; increases the risk of data leaving |
The firewall exists because of a specific risk: an agent reading untrusted text, such as an issue written by an outsider or a web page, might be manipulated into sending repository contents somewhere. Blocking unexpected destinations turns that kind of leak into a visible warning. Tidewater added one custom entry, the domain of the map tile service that TrailCheck's tests downloaded sample tiles from, after the warning appeared in a session log.
The cloud agent's token and secrets
The cloud agent works with a GitHub token scoped to the repository it is working in, acting on behalf of the person who assigned the task. It can read the repository, push to its own branches and create pull requests, but it cannot reach other repositories, change settings or push to protected branches. It does not receive the repository's ordinary GitHub Actions secrets. Secrets and variables that the agent or its MCP servers legitimately need are stored in a dedicated Copilot environment in the repository's settings, where they can be reviewed separately from deployment secrets.
Worked problem
Deciding what the agent should hold
TrailCheck's tests need a read-only key for the hiker report sample data, and its deployment workflow uses a key that can publish the live site. Lena wants the cloud agent to run the tests. Which keys should it have?
Show solution
- The read-only sample data key is needed to run tests, so it goes in the Copilot environment.
- The publishing key is not needed for any agent task and would let a manipulated agent change the live site, so it stays in the production environment used only by the reviewed deployment workflow.
- Even the sample data key is scoped to read-only, so a leak would expose only sample data.
- The team records the decision in the repository so that future additions are reviewed the same way.
Least privilege for agents
The guardrails domain asks candidates to scope permissions and execution contexts to enforce least privilege. For agents this means each agent gets the smallest set of tools, files, network destinations and credentials that lets it do its job, and no more. The principle is old; what is new is that agents can be steered by text they read, so anything they can reach must be assumed reachable by whoever wrote that text. Seraphine's rule of thumb was blunt: give an agent only what you would give a capable stranger who follows instructions literally.
| Layer | Least-privilege control at Skerry |
|---|---|
| Tools | Custom agents list allowed tools; MCP servers expose only approved tools |
| Files | Cloud agent sees one repository; local agents run in dev containers for sensitive projects |
| Network | Firewall with the recommended list and a few reviewed entries |
| Credentials | Copilot environment holds only test credentials; no production keys anywhere agents run |
| Branches | Agents push only to their own branches; rulesets protect default branches |
| Merges and deployments | People approve; environment protection rules guard production |
Autonomy levels
The GH-600 outline asks candidates to classify agent actions by operational, security and compliance risk and to assign autonomy levels that keep delivery fast while meeting policy. Tidewater adopted a simple four-level scale that Skerry also used. The aim is the one in the outline: put human judgment where it reduces real risk, and remove approvals that do not.
Most of Tidewater's agent work sat at level 2: the agent could change code on its own branch and propose a pull request, and people decided whether it merged. Running tests and linters in the agent's own environment was effectively level 4, because those actions had no effect outside the sandbox. Installing new dependencies was level 3 for local agents. Merging, deploying, changing repository settings and anything touching hiker personal data stayed with people at every level, because they were irreversible or compliance-sensitive.
Approvals that matter
The outline's last guardrail skill is easy to overlook: preserve execution velocity by minimizing approvals that do not materially reduce risk. An approval that people click through without reading adds delay and teaches them to approve everything. Tidewater removed two approvals after the first month: running the test command, which could only affect the agent's own environment, and reading files in the repository. It kept the approval for workflow runs on agent pull requests, because those workflows could use real secrets, and it kept human review of every pull request.
Untrusted input and prompt injection
The reason sandboxes matter more for agents than for ordinary scripts is that agents act on text. An issue body, a code comment, a web page, a dependency's README and a tool result are all text that reaches the model, and any of them can contain instructions. Prompt injection is the name for text written to make an agent do something its user did not ask for, such as reading a secret and posting it somewhere. Models are trained to resist it, and GitHub adds its own protections, but no current defence is complete. The practical response is to assume that an agent reading untrusted text may be steered, and to limit what a steered agent could do.
That is why the controls in this lesson are layered. The firewall limits where data could go. The scoped token limits what the agent could change. The Copilot environment limits which secrets it holds. Review limits what reaches the default branch. Workflow approval limits what runs with real secrets. Any one layer could fail; an attacker would need several to fail at once. MSBA-371 covers prompt injection in more depth; here the point is that sandbox design starts from the assumption that the agent's instructions might not all come from its user.
Who can assign work
Permission to assign work to an agent is itself a control. For the cloud agent, only people with write access to a repository can assign issues to Copilot or start sessions there, and the agent's actions are attributed to the person who started it. In a public repository like TrailCheck, outside contributors can open issues but cannot assign them, so an outsider cannot start an agent session directly. They can still write the text an agent might later read, which is why Tidewater's maintainers read an outsider's issue before assigning it, and edited out anything that looked like instructions to an agent.
Local sandboxes in practice
Lena set up a dev container for TrailCheck after Seraphine's story. The container held the repository, Node and the project's tools, and nothing else: no cloud credentials, no SSH keys, no browser sessions. When she used agent mode inside it, the agent's terminal commands ran in the container rather than on her laptop. The container did not stop the agent from doing something unwise inside the project, but it stopped a mistake or a manipulated command from reaching anything beyond it. She kept her personal credentials outside, and used them only for the final push, which she did herself.
| Control | Local agent without container | Local agent in a dev container | Cloud agent |
|---|---|---|---|
| Files reachable | Everything the user can read | Project files only | One repository clone |
| Credentials | User's own | Only what is put in the container | Scoped token and Copilot environment |
| Network | Unrestricted | Unrestricted unless configured | Firewall allow list |
| Lifetime | Persistent | Rebuilt when needed | Discarded after each session |
Reviewing the containment itself
Controls drift. A firewall entry added for one task stays for years; a secret added to the Copilot environment for a test outlives the test. Skerry reviewed each repository's agent settings every quarter: firewall entries, Copilot environment secrets, configured MCP servers and custom agents. Each item needed a reason and an owner, and anything without both was removed. Tidewater adopted a lighter version, reviewing its three repositories' settings once each term, and in the first review removed a firewall entry for a documentation site that the team had stopped using.
A checklist for new agent settings
Tidewater ended the session with a short checklist that anyone changing agent settings had to answer in the pull request or settings change note: what access is being added, which tasks need it, what a manipulated agent could do with it, and who will review it next term. The checklist took a minute to complete and made every change to the agent's reach a deliberate decision with a reason on record.
Common mistakes
MistakeRunning local agents with personal credentials in the environment.
InsteadUse dev containers or clean environments without personal or production credentials for sensitive work.
MistakeTurning the cloud agent's firewall off to fix a blocked request.
InsteadAdd the specific legitimate destination to the allow list.
MistakePutting deployment keys where the agent can read them.
InsteadGive the Copilot environment only what agent tasks need, scoped as narrowly as possible.
MistakeRequiring approval for every agent action.
InsteadRequire approval where it reduces real risk; remove approvals that people click through.
Summary and key terms
- A sandbox limits files, programs, network and credentials, starts from a known state and is discarded afterwards.
- The cloud agent runs in a temporary environment with a repository-scoped token and a firewall using a recommended allow list.
- Secrets the agent needs go in the repository's Copilot environment; ordinary Actions secrets are not passed to it.
- Least privilege means the smallest set of tools, files, network and credentials that does the job.
- Autonomy levels match agent freedom to risk; irreversible and compliance-sensitive actions stay with people, and pointless approvals are removed.
- Sandbox
- An environment that limits what code running inside it can affect.
- Agent firewall
- The cloud agent's control on outbound network access, based on an allow list.
- Recommended allow list
- GitHub's maintained list of destinations the cloud agent commonly needs.
- Copilot environment
- A repository environment holding the secrets and variables available to the cloud agent.
- Least privilege
- Giving each agent only the access its task requires.
- Autonomy level
- A defined degree of freedom for an agent, matched to the risk of its actions.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Does the cloud agent receive a repository's ordinary Actions secrets?
Show answer
No; it receives only what is in the Copilot environment.
What appears when the firewall blocks a destination?
Show answer
A warning in the pull request or session log naming the destination.
Which actions stay with people at every autonomy level?
Show answer
Irreversible or compliance-sensitive actions, such as merging, deploying and changing settings.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.