Security model
An agent reads untrusted input, such as a pull request's code, description and comments. The design assumes that this input can contain a prompt injection, and limits what the agent can do after one.
Writes
An agent writes to the session's subject with a registered tool, such as
github_post_comment. The tool runs on the worker and takes only the write's content.
It writes to the session's subject and nowhere else. It mints its own token for the
call, so the sandbox needs no credential that grants write access. The tool call and
its arguments are in the session's history. A tool can set how many times the harness
runs it per step run. github_post_comment runs at most once. In a dry run the harness does not run the
activity of a tool that writes, so nothing is written.
dagster_submit_diagnosis is the exception: its subject is a Dagster deployment, and it
writes to Linear issues. It creates issues only in the team its settings name, and it
records and reopens only issues that its attachments, or the agent's match, lead it
to. It acts as the Linear write app, with the worker's shared token, which never
reaches a sandbox.
In a dry run it writes nothing and returns what it would have written.
The Linear tools and step activities, such as linear_post_plan_verdict, act as the
same write app. Each comments only on the issue that is the session's subject.
The sandbox's credentials are read-only unless the agent
sets allow_sandbox_writes: true. The loader rejects an agent whose
credentials grant write access without it. With it, the agent writes with commands in
its sandbox, such as git push. Each command and its output are in the session's
history. An agent declares only the access it needs. A step can narrow its agent's
credentials to read-only grants, and the loader rejects a step that widens them. A
GitHub credential is limited to the work item's repository.
In a dry run every sandbox credential is read-only, so each write from the sandbox
fails. For an agent with allow_sandbox_writes, the prompt tells the agent that a
refused write is expected. It also tells the agent not to retry the write and not to
make it another way.
Pushing a fix
An agent that pushes a fix with the registered tool github_push keeps read-only
credentials in its sandbox. A step run has the tool only when its agent or its step
names the tool. In the pull-request agent, only the fix and review-and-fix steps
name it. The auto-swe:review-and-fix label and the fix and review_and_fix intents
start an agent run at those steps. The agent commits in its sandbox. The tool runs on
the worker. It reads the commits after the checked-out commit from the sandbox and
writes each again with GitHub's Git Database API, with the same message and changes.
Its token has contents: write and never enters the sandbox. The tool:
- writes only to the head branch of the work item's pull request, and only when that branch is in the work item's repository;
- runs at most once per step run;
- refuses when the branch's head is not the commit the step run checked out;
- refuses changes that are not committed, and commits that are not a line of single-parent commits on the checked-out commit;
- updates the branch without force, so GitHub refuses the update if the branch moved after the tool read it;
- refuses commits that together change more files than the
max_changed_filessetting allows; - refuses a commit whose message fails the base branch's pre-commit
commit-msghooks, or the command in thecommit_message_checksetting, which run in the sandbox; - refuses a commit that changes a file under
.github/workflows/, a symbolic link, a submodule, or a path that git quotes because of unusual characters.
A prompt injection in the pull request can still make the agent commit code that the person who asked for the fix did not ask for. The App is the author of each pushed commit, and the commits are on the pull request. CI runs on them as on any push. The pull request still needs its reviews before it merges.
github_push writes a linear.issue's implementation the same way, with the same
refusals, to auto-swe/<identifier>, the branch named after the issue. An agent run's
first push is the exception:
- It creates the branch from the commit the step run checked out.
- When an earlier agent run on the issue left the branch, it replaces that branch's commits with force, without checking the branch's head.
- It refuses when the branch has a commit since the checked-out commit that the App did not commit, such as a fix a person pushed to the draft pull request.
A later push in the same agent run updates the branch without force.
github_open_pull_request opens a draft pull request from that branch. It never marks
a pull request ready for review.
Branch protection
The GitHub ruleset on main blocks:
- every push to
mainother than the merge of a pull request; - every force-push to
main; - the deletion of
main.
A pull request needs one approving review and a code owner's review before it merges. Only the repository admin role can bypass the ruleset. Terraform does not manage the repository's GitHub settings, including this ruleset.
An agent that pushes from its sandbox needs contents: write. It can push to any
branch other than main, including a branch with an open pull request. github_push
writes only to the head branch of the work item's pull request.
Tokens on the worker are scoped per call
The worker mints a GitHub App installation token for each of its own calls, limited to the one repository and the permissions that call needs:
| Use | Permissions |
|---|---|
| The pull request context: the comment author's permission, the linked issues, the comments, and files on the base branch | contents: read, issues: read, pull_requests: read |
The earlier comments of a reply's review thread, to classify the reply (github_classify_intent) | pull_requests: read |
👀, or 👍 for feedback, on a comment in the pull request's conversation or a review thread (github_acknowledge) | pull_requests: write |
Reading the reactions on the agents' comments (github_collect_reactions) | pull_requests: read |
github_post_comment: the comment and its 👍 and 👎 | pull_requests: write |
github_post_review: reading the diff | contents: read, pull_requests: read |
github_post_review: the review, its replies in review threads, and the 👍 and 👎 on its comments | pull_requests: write |
github_reply_in_thread: the reply and its 👍 and 👎 | pull_requests: write |
github_post_fix_report: reading the review threads | pull_requests: read |
github_post_fix_report: the review, its replies, and their 👍 and 👎 | pull_requests: write |
github_post_review and github_post_fix_report: resolving a review thread | contents: write, pull_requests: write. GitHub refuses resolveReviewThread to an App token without contents: write |
github_push: reading the pull request's head, reviews and comments, and the base branch's pre-commit config | contents: read, issues: read, pull_requests: read |
github_push: reading a linear.issue's branch and the base branch's pre-commit config | contents: read |
github_push: the blobs, trees and commits, and creating or updating the branch | contents: write |
github_open_pull_request: the draft pull request | pull_requests: write, contents: read |
| Resolving a plugin from a public marketplace | contents: read |
The token for resolving a plugin is also limited to the work item's repository. Any GitHub token can read public repositories, so this token can read the marketplace. A token expires within an hour of being minted.
Credentials in the sandbox
An agent's credentials: lists what the
sandbox's commands can reach. Daytona Secrets hold each credential. The session mounts a
sandbox's Secrets when it creates the sandbox. In the sandbox, an environment variable
holds the Secret's placeholder (dtn_secret_…), never its value. Daytona's egress proxy
replaces the placeholder with the value in the headers of HTTPS requests to the
Secret's hosts, and in no other request. No command in the sandbox can therefore read a
credential's value, with or without sudo.
| Credential | Variable | Hosts | Value |
|---|---|---|---|
github | GH_TOKEN | api.github.com | An installation token for the work item's repository, with the permissions the agent declares |
github | GIT_AUTH | github.com | The base64 of x-access-token:<token>, for the same token, which git sends as Basic auth |
linear | LINEAR_API_KEY | api.linear.app | Bearer <token>: a client-credentials token of the Linear OAuth app for the access level, which acts as the app and expires after 30 days |
nessie | NESSIE_TOKEN | nessie.app.autointel.ai | The reader-role token that the nessie-reader-token-refresher Lambda writes to dagster/nessie/m2m-reader-token |
dagster | DAGSTER_CLOUD_API_TOKEN | s44-automotive.dagster.cloud | auto-swe/dagster/read-token or auto-swe/dagster/write-token, for the access level |
Every sandbox that needs the same credential mounts the same Secret. For GitHub, each
repository and permission set has two Secrets, one for GH_TOKEN and one for
GIT_AUTH. Both hold the same token, in the forms the table lists. The
refresh_credentials activity creates
a Secret the first time a step run needs it. Before each command in a step run, if a
Secret's value expires within its provider's refresh_before, refresh_credentials
gives the Secret a new value, and running sandboxes use it within about 30 seconds. The
old token stays valid until it expires, so requests in between still succeed.
refresh_before is 15 minutes for a GitHub token, an hour for the Nessie token and a
day for a Linear token.
The DynamoDB table auto-swe-credential-expiry holds each credential's expiry, so every
worker reads the same expiry. A command that still calls GitHub more than 15 minutes
after it starts can find its token expired. The next refresh is never less than 5
minutes after the current one.
When a Secret is due for a new value, its provider can have no newer value yet, such as
the Nessie provider before the nessie-reader-token-refresher Lambda runs. The
refresh_credentials activity then tries again 5 minutes later.
The GitHub Secrets always hold App installation tokens, including on a local worker
with GITHUB_TOKEN set. A token's permissions are therefore the ones the agent
declares. An agent must declare at least one GitHub permission. GitHub gives a
token requested without permissions every permission of the installation.
In a dry run every credential is read-only: each GitHub permission is read, and the
Linear token comes from the read app.
The worker's own Linear writes use a read,write,app:mentionable token of the Linear
write app. Every worker uses the one token in auto-swe/linear/write-token. A worker
that finds no token there, finds one that expires within a day, or has the token
refused, mints a new token and writes it there. Linear allows an app 1,000 active client-credentials tokens, and
each Lambda cold start creates an execution environment that starts without a token, so
minting one in each would reach Linear's limit. The token never enters the sandbox.
Any code in the sandbox can still send requests to a credential's hosts, with the credential's access, while the sandbox runs.
Nessie returns S3 credentials for each table a client loads, in the response body. For a
reader token they allow only GetObject on that table's files, and they expire after
an hour. They reach the client in the sandbox without passing through the worker, so the
worker cannot remove them from a command's output. The client reads the table's files
from S3. The nessie credential's hosts do not include S3's hosts, so an agent that
reads table data must list the warehouse's S3 hosts in sandbox.egress.
The checkout
The first checkout in a sandbox clones the repository without blobs and with its full
history. It writes git's Authorization header, which holds the GIT_AUTH
placeholder, into the repository's config, so every git command in the checkout sends
it, including the agent's. Each later step run fetches its commit into that clone and
checks it out. The checkout script reads no system or global git configuration and runs
no hook. Plugin fetches clone public repositories without a credential.
What the sandbox can reach
The Daytona account is on Tier 3. On Tier 3 a sandbox without an egress allowlist has
full internet access. Unless the agent sets egress: all, the session creates every
sandbox with an egress allowlist. When the allowlist would have no hosts, the session
creates the sandbox with all outbound traffic blocked instead.
Egress lists the hosts the allowlist has.
A sandbox with an allowlist does not reach Daytona's essential services, such as AWS, Google Cloud and Azure endpoints, unless the allowlist lists them. Daytona's proxy refuses a connection to any host that is not in the allowlist.
With an allowlist, Daytona's proxy decrypts the sandbox's HTTPS traffic to every host, including hosts with no Secret.
A sandbox with egress: all has full internet access, so code the agent runs can send
what it reads to any host, including cloud storage that someone else controls.
A credential's value is not in the sandbox, so code there cannot send it anywhere.
Code the agent runs can still send what it reads to a host in the allowlist, with any
credential that the code supplies itself. For example, a pull request can include a
GitHub token for another repository, and github.com accepts a push with that token.
registry.npmjs.org accepts npm publish with any account's token in the same way. A
package registry whose credential is committed to the repository, such as an _auth
value in .npmrc, accepts an upload with that credential. An agent must therefore
list only the hosts its commands need.
The allowlist is the main control on where a prompt injection in a pull request's content can send the repository's code. Besides the credentials' hosts, the allowlist has the hosts in:
- the agent's
sandbox.egress, which changes only with a change toauto_swe; - the
egresslist in the repository's.auto-swe/config.yaml, which the session reads from the base branch.
A repository's list can name only hosts in the agent's
sandbox.approved_repo_egress, which changes only with a change to auto_swe. It has
no *. entries, because a *. entry on a shared domain, such as *.amazonaws.com,
would allow uploads to storage that anyone can create. A pull request cannot add a host
to the allowlist of its own step runs. A person who can merge to the base branch can
turn on an approved host for every later pull request. A repository's list cannot remove
the agent's hosts.
The review agent runs only when a person asks for it. A person asks by adding the
auto-swe:review or auto-swe:review-and-fix label, or by starting a comment with
@ai-auto-swe. The pull request context checks the comment's author, or the person who
added the label, through GitHub's
collaborator permission API. It skips the work item unless that person has write access
to the repository. The check covers the label because GitHub's triage role can add
labels without write access. GitHub reports no access for a bot, such as
github-actions[bot] or another App, so the pull request context also skips the work
item when a bot adds the label. The webhook drops a comment from a bot, including the
App's own, so the agents cannot start each other.
No agent runs on a pull request from a fork. The webhook drops the pull request events and check events of a pull request from a fork. A comment event names no head repository, so the pull request context skips a pull request from a fork instead.
A sandbox keeps the egress it was created with. Step runs share a sandbox only when their egress is the same.
AWS through the MCP server
An agent reads AWS resources through the AWS MCP Server's tools. The worker calls those
tools with an OAuth token from the read-only role auto-swe-agent-readonly. No AWS
credential enters the sandbox. The role's credentials allow reads only in calls made
through the AWS MCP Server. aws___run_script runs a Python script that the agent
wrote, in an AWS-hosted environment, with the same credentials, so the role must stay
read-only.
MCP tools describes the role and the token.
An MCP tool's result is stored in each place that How a call runs lists. Anyone who can read those places can read what an agent read through a tool, such as CloudWatch log lines, without access to the AWS resource it came from.
Comments sent to TypeSafe
To route a comment that mentions the App, the worker sends the comment's text to
TypeSafe's API. For a comment in a review thread, it also sends the path of the thread's
file. For a reply in a review thread, it also sends the thread's earlier comments, up
to MAX_EARLIER_COMMENTS of them, and whether each is the App's. It sends the first
EARLIER_COMMENT_MAX_CHARS characters of each comment's text. Nothing else about the
pull request leaves the worker for TypeSafe. The worker sends the comment and the
thread's earlier comments before the pull request context checks the author's access, so
a comment from someone without write access is also sent. TypeSafe's answer determines
which trigger matches, and so the step an agent run starts at. A comment written to
change the answer can at most select another of the agent's triggers. The context still
skips a comment whose author lacks write access, before the step's agent loop.
Dagster failures sent to TypeSafe
The triage workflow asks Jev, on TypeSafe's API, two kinds of question about a Dagster+ failure:
- The cause's category. The triage context sends what the agent's prompt shows under
Failed run and Errors:
- the failed run's id, link, code location, job, partition, launcher and commit, and its failed steps and checks;
- the run's error messages, the exceptions behind them and the code lines of their innermost frames.
- The grade of a diagnosis.
dagster_submit_diagnosissends:- each failure's code location, partition, target and deepest exception;
- the agent's proposed cause, the evidence for it and the ruled-out causes, which hold whatever the agent quotes from Dagster+, Nessie, the repository or Linear;
- for a match to an existing issue, that issue's identifier, title and cause.
An error message or an evidence item can include whatever the run or the agent read, such as a row's values or a URL with a key in its query string.
The pull request's own configuration
The repository's .claude/settings.json, instructions and skills come from the pull
request, so a pull request can change them. The session skips any part of the
settings file that it cannot load, as Repository context
lists, so the settings file cannot stop the session. An enabled plugin that cannot be
resolved fails that step run, and the session continues. Hooks run in the sandbox like any
other command, with the sandbox's credentials. @ imports outside the checkout are
skipped.
Four kinds of configuration come from the pull request's base branch instead, so a pull request cannot change them for its own run:
.auto-swe/config.yaml, which overrides an agent's settings, such as how many nits a review posts and which paths it skips, and adds hosts to the sandbox's egress;- the files an agent lists in
repo_context.base_instructions, such asREVIEW.md, the repository's review rules; - the script an agent names in
repo_context.base_setup_script, such as.auto-swe/setup.sh; - the
commit-msghooks in.pre-commit-config.yaml, whichgithub_pushruns on a commit message.
A pull request that changes one of them runs under the base branch's version, and its change applies after it merges.
The script that repo_context.base_setup_script names runs before the agent starts,
without a model deciding to run it, so it comes from the base branch. It runs with the
sandbox's credentials and egress, and with none of its own. It runs against the checkout
of the pull request's head. A command in
the script that runs code from the checkout, such as pnpm install with the packages'
install scripts, runs code that the pull request can change.
The agent cannot use Deep Agents' task tool. Its subagent would run outside the
agent loop's call limit and hooks, and its model calls would not count toward the session's
token counters.
The webhook
The webhook function's URL requires no AWS authentication. The function checks each
delivery's X-Hub-Signature-256 against the webhook secret in constant time, and
answers 401 without parsing a delivery that fails the check. It runs at most 10
invocations at once.
The shared payload bucket
The worker and the webhook function write payloads to ai-ordering-payloads-prod, so
that ai_ordering's codec server can decode them. Both functions can read, write and
list that bucket, and so can ai_ordering's workers. Each application can therefore
read the other's payloads.
The storage driver calls HeadObject on a key before writing it, which needs
GetObject and ListBucket. Its keys have no per-application prefix that the grant
could be limited to. A bucket per application would separate the payloads, but the
codec server reads only this bucket.