AI agents that run code on your behalf raise an obvious question: What can they reach? An agent that can call any domain or write anywhere on the filesystem can leak source code, tokens, or data, or pull in a malicious package, putting your projects and credentials at risk.
GitLab Duo Agent Platform limits that risk with a remote execution sandbox. The sandbox restricts network and filesystem access for flows that run on a GitLab Runner to a fixed baseline plus the domains you approve.
In this article, you'll learn which agent-config.yml settings change what the sandbox enforces, and how to test the sandbox with a flow that prints its own evidence.
The challenge: Sandbox rules are easy to get wrong
Top-level group owners (or instance administrators on GitLab Self-Managed) set the baseline, and projects can extend it with a configuration file.
The rules are simple to state and easy to get wrong. Does a project's allowlist apply, or is it ignored? Does a denylist entry beat a recommended domain? What changes between flexible and strict mode?
GitLab's own security analysis of AI agent sandboxes makes a related point: Every service on an allowlist adds to what a workload can reach because an agent that takes over one of those services borrows its connectivity. So the practical next step is to check what your allowlist does.
How the sandbox works
The sandbox uses Anthropic Sandbox Runtime (SRT) to wrap each flow run. It enforces two sets of rules:
- Network: Every request is intercepted and checked against allowed domains. Four destinations are always allowed:
localhost,host.docker.internal, your GitLab instance domain, and the Duo Workflow Service. - Filesystem: The flow can write to the working directory and
/tmp. Reads of~/.sshare blocked, and the sandbox's own settings directory is protected.
The sandbox applies when the image includes SRT, the session runs on a runner, and the job can create user and mount namespaces. If one of those conditions fails, the flow still runs, but without the sandbox. The job log shows a warning, such as Warning: SRT found but can't create sandbox (insufficient privileges), running command directly, and network policy settings no longer apply. A flow can run fine and still be unprotected.
You can enforce sandbox requirements and prevent flows from operating unprotected by enabling Don't run flows when the sandbox is unavailable. Introduced in GitLab 19.6, this configuration can be activated by top-level group owners under Execution environment sandbox in their group's GitLab Duo settings, or by instance administrators via the Admin area on GitLab Self-Managed and GitLab Dedicated.
When activated, any flow unable to initialize the sandbox will automatically fail the job rather than proceeding without protection. Key details include:
- Scope: The mandate automatically extends to all underlying projects and subgroups within the group, and cannot be overridden in individual
agent-config.ymlfiles. - Limitation: Because enforcement depends on detecting the
srtexecutable in the job, projects utilizing custom container images or asetup_scriptdetermine their own binary source, meaning complete isolation cannot be guaranteed in those scenarios.
To review step-by-step instructions, refer to the Require flows to run in the sandbox documentation.
The sandbox became generally available in GitLab 18.8. The network_policy setting arrived in 18.10, and group and instance network controls in 18.11.
Configure the sandbox with agent-config.yml
The configuration file lives at .gitlab/duo/agent-config.yml. GitLab reads it only from the default branch, so changes take effect after they merge. You can't use predefined CI/CD variables inside the file. For the full list of keys, see the agent-config.yml reference.
| Key | What it does |
|---|---|
image | Sets the Docker image for the flow |
setup_script | Runs commands before the flow starts |
network_policy | Defines allowed and denied domains, recommended domains, and Unix sockets |
Choose the image
To change the Docker image the flow runs in, set the image key:
image: python:3.11-slim
Without the image key, the flow uses the default GitLab Duo Agent Platform image. It's based on Red Hat Universal Base Image (UBI) 9 Minimal, runs as root, and includes SRT, git, glab, GitLab Duo CLI, and common language runtimes (Node.js, Python, Go, Ruby, and Java). The runtime inventory lists the pinned versions.
The sandbox applies to a custom image only if SRT is installed in it. Without SRT, the flow can reach any domain the runner can reach and can access the full filesystem, so neither your network policy nor the filesystem rules apply. If you need isolation with a custom image, install SRT and configure a network policy, or restrict traffic at the runner with firewall rules or network policies.
A custom image also needs git and curl. Minimal images, such as Alpine variants, might need you to install them in setup_script.
For compliance requirements such as the Federal Risk and Authorization Management Program (FedRAMP), GitLab also provides a hardened image based on Red Hat UBI 9 Minimal. It runs as a non-root user (the default image runs as root) and needs no outbound internet access when the flow runs:
image:
registry.gitlab.com/gitlab-org/duo-workflow/default-docker-image/workflow-generic-image-hardened:<tag>
Because setup_script also runs as a non-root user on that image, it can't install system packages. To add packages, extend the image with your own layer. On the hardened image, SRT creates the sandbox through an unprivileged user namespace, so the runner host must allow them (see Check your runner). For more details, visit the Configure images documentation.
Prepare dependencies with setup_script
To install dependencies before the flow starts, list the commands under the setup_script key:
setup_script:
- apt-get update && apt-get install -y jq
- pip install -r requirements.txt
Commands run in order, before the flow. Pay attention to where they run: setup_script executes before SRT is applied and outside it. The commands can see every variable in the flow environment, including the triggering user's OAuth token and the service token. Anyone who can change this file can influence what runs in another user's environment.
Keep the script short. Use Code Owners and approval rules so security reviewers must approve every change to this file. For example, add this CODEOWNERS entry:
.gitlab/duo/agent-config.yml @your-group/security-reviewers
Restrict the network
To restrict which domains the flow can reach, add a network_policy block:
network_policy:
include_recommended_allowed: true
allowed_domains:
- example.com
denied_domains:
- pypi.org
Turn on include_recommended_allowed only when you need it. It opens access to a broad set of package registries, source hosts, and cloud domains, and any of those endpoints could serve as a route for data to leave. The Sandbox Probe project, described later, turns this setting on deliberately. Because pypi.org is on the recommended list, the project denylist has a recommended domain to override. Domains can use wildcards such as *.example.com, but a bare * isn't allowed.
One group-level checkbox controls how project settings combine with the group's settings: Allow projects to extend network sandbox settings. When the checkbox is on, the group uses flexible mode. When it's off, the group uses strict mode:
| Field | Flexible mode (checkbox on) | Strict mode (checkbox off) |
|---|---|---|
allowed_domains | Merged with the group allowlist | Ignored |
denied_domains | Merged with the group denylist | Merged |
include_recommended_allowed | Overrides the group setting | Can only turn it off |
In the probe, a domain on both lists (pypi.org) was blocked, so denied domains win over allowed ones. The proxy decides each request like this:
flowchart LR
req["Request to a domain"] --> base{"Always allowed? localhost, host.docker.internal, your GitLab instance, Duo Workflow Service"}
base -- yes --> pass
base -- no --> denied{"In denied domains?"}
denied -- yes --> blocked["Blocked: 403 from proxy"]
denied -- no --> allowed{"In allowed domains?"}
allowed -- yes --> pass["Allowed"]
allowed -- no --> blocked
Check your runner
On GitLab.com, flows use GitLab-hosted runners by default. If you bring your own runner, give it the gitlab--duo tag. Without the tag, jobs stay queued. Use an executor that supports Docker images (docker, docker-autoscaler, or kubernetes). The shell executor isn't supported.
The sandbox needs the job to create user and mount namespaces. Privileged mode is one way to meet that requirement, but it isn't always enough. For example, a runner host that sets user.max_user_namespaces to 0 still blocks the sandbox.
Test the rules with the Sandbox Probe flow
Reading the rules tells you what should happen. To see what does happen, I built the Sandbox Probe agentic flow. The flow is deterministic. The agent only executes two scripts from your project and posts each output as a note on the issue where you mentioned it. It doesn't choose checks or interpret results.
sandbox-probe.shposts a full report with the expected and actual result for every check.sandbox-evidence.shposts compact raw command output, kept under 4,096 characters so the session view doesn't cut it.
Check the Sandbox line first. The report opens with a line that says ACTIVE or NOT ACTIVE. ACTIVE means the sandbox settings are present and a write outside the allowed paths was blocked. NOT ACTIVE means the flow probably ran without the sandbox, so the other results don't describe a sandboxed run.
sandbox-probe.sh runs 14 checks in three groups:
- Configuration compares the expected rules with the effective sandbox settings on the runner.
- Filesystem tries writes to allowed and protected paths. The process runs as root in the default image, so a blocked write can only come from the sandbox.
- Network calls the domains in probe-targets.txt (five by default) through the proxy, each tested three ways (verbose HTTPS, a page fetch, and a plain HTTP request), so a block is visible from the client side and the proxy side.
The project's own agent-config.yml uses only the network_policy shown earlier. It sets no image and no setup_script on purpose, so every check runs inside the sandbox.
What the probe found
I ran the probe in both modes on Oct. 16, 2026. Both runs matched all 14 expected outcomes. On Nov. 17, 2026, I re-ran flexible mode with the version of the probe that adds the Sandbox line and the targets file. It also matched all 14 outcomes, and the report opened with Sandbox: ACTIVE.
| Domain | Flexible | Strict | Why |
|---|---|---|---|
gitlab.com | Allowed | Allowed | Always allowed |
registry.npmjs.org | Allowed | Allowed | Recommended domain |
pypi.org | Blocked | Blocked | Project denied_domains |
example.com | Allowed | Blocked | Project allowed_domains applies only in flexible mode |
httpbin.org | Blocked | Blocked | Not listed anywhere (control) |
A few details are worth noting:
- The block message doesn't name the rule. The proxy answers
blocked-by-allowlistfor every blocked domain, even forpypi.org, which the project denylist blocks. The configuration checks show which rule applied. - Some paths can't be tested.
~/.sshdoesn't exist in the default image, so its read rule can't be exercised. Traffic to localhost, link-local, and private network ranges bypasses the proxy and isn't covered by the probe. - Credentials stay in the environment. The sandbox limits where traffic goes and where files can be written, but the variables that flows need for Git and Duo Agent Platform operations remain available inside it, including credentials such as the GitLab token.
Try it yourself
To test your own sandbox rules, follow these steps:
- Fork the Sandbox Probe project into your top-level group as a private project.
- Enable the Sandbox Probe flow in your fork with the Mention trigger.
- Comment on an issue in your fork:
@ai-sandbox-probe-<your-top-level-group> Run the sandbox probe.
To test your own domains, edit .gitlab/duo/probe-targets.txt on the default branch of your fork. Add one domain per line, with an optional expect=PASS or expect=BLOCKED. The probe then checks those domains instead of the default five.
You need the Maintainer or Owner role on your fork to enable the flow, and the Owner role on the top-level group to change the network mode. Changing the mode affects every project in the group that uses GitLab Duo Agent Platform. Run the full flexible-versus-strict comparison in a group you own, and restore the original settings afterward.
To go deeper, read the Remote execution environment sandbox and Configure flow execution documentation. For the broader question of what an agent can reach, see GitLab's earlier look at the pipeline perimeter for AI-assisted coding.

