Why it matters
An agent combines three things that are dangerous together: untrusted input, code execution and credentials. A README, an issue comment or a dependency changelog can carry instructions, and the agent may act on them with the permissions it was given for a legitimate task. Conventional application security still applies, but the identity doing the acting is new and its permissions are usually broader than a human's would be for the same job.
Mental model
It is onboarding a contractor with a badge: scope the badge and log every door. The metaphor breaks because this contractor reads every document it can reach and treats each one as an order, so a memo on the desk becomes a change to its permissions.
How it works
Step 1 of 8
The agent is a new identity
Not a user, not a service account shared with a human. The scope is written for the task and expires with it, which is why the permissions are the design and the prompt is not.
root · current
Agent identity · one task
The agent is a principal, not a feature. Its permissions are granted before it reads anything and revoked when the run ends, so the scope is a decision about the task rather than about the model.
Root of the hierarchy
Figure. The agent decomposed into the four permissions it holds — read, write, network and credentials — each scoped and expiring with the run. The crossed branch is policy taken from repository content, which is input the agent reads and not a surface it may be granted.
What to notice. The repositories, the egress list and the token lifetimes are an authored example; the page publishes no measurements, so no counts are drawn. This is an identity decomposition, not a prompt checklist: each surface is a separate grant with its own owner and expiry, and content appears only as input that cannot change them. Omitted: the identity provider and the audit pipeline implementation, which the page treats as platform work.
Text version
An agent identity drawn as a permission tree. The root is one agent identity issued per task and expiring with the run. Four surfaces hang from it. Read covers repositories and is time-boxed, with a gate saying repository content is only ever input and cannot change policy. Write stops at a branch in a sandbox, while production requires a second identity with its own credential and approval. Network is an egress allowlist that alerts on a new destination. Credentials are per task, short-lived and revoked at run end. Two branches are crossed: policy taken from a file, which is refused because content is input, and one broad token that outlives the run. A note says the lockfile diff is reviewed because a dependency executes at install, and another ties commands, network calls and approvals to one run id. Steps walk the identity, read, content, write, production, network, credentials and audit.
- Define the agent's identity: which repositories, environments and data it can reach, and for how long.
- Separate read and write permissions, and require a second identity for production changes.
- Treat repository content, issues and dependency text as untrusted input that cannot change policy.
- Run code in a sandbox with egress allowlists and no ambient credentials.
- Scan generated code for injection sinks, unsafe deserialisation and newly added dependencies.
- Keep an audit log of commands, network calls and approvals tied to a run id.
Trade-offs
| Choice | Good for | Cost | Fails when |
|---|---|---|---|
| Read-only agent producing patches | Low risk, human applies | Slower loop | Task is repetitive and well tested |
| Write access in a sandbox | Autonomy with containment | Sandbox engineering | Task needs production data |
| Broad token with approvals | Fewer blockers | Approval fatigue, over-privilege | Runs are unattended |
| Per-task scoped identity | Least privilege, auditable | Issuance and cleanup work | Task spans many services |
Good for
Low risk, human applies
Cost
Slower loop
Fails when
Task is repetitive and well tested
- Task is repetitive and well tested
- Task needs production data
- Runs are unattended
- Task spans many services
Figure. Each choice with what it buys, what it costs, and the case where it loses.
What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.
Text version
Four trade-offs: Read-only agent producing patches is good for Low risk, human applies, costs Slower loop, and fails when Task is repetitive and well tested. Write access in a sandbox is good for Autonomy with containment, costs Sandbox engineering, and fails when Task needs production data. Broad token with approvals is good for Fewer blockers, costs Approval fatigue, over-privilege, and fails when Runs are unattended. Per-task scoped identity is good for Least privilege, auditable, costs Issuance and cleanup work, and fails when Task spans many services
Failure modes
- Injected instruction. A README tells the agent to disable a check and it complies. Debug: search the trace for policy changes that originated in file content rather than the task.
- Dependency addition. The agent adds a package whose post-install script runs in CI. Debug: diff lockfiles and review every new dependency against an allowlist.
- Credential sprawl. Task tokens outlive the run and accumulate. Debug: list active tokens by run id and revoke anything past its task.
In production
Review agent permissions quarterly, alert on new egress destinations and on lockfile changes, and rehearse revoking a compromised agent identity.
Common misconceptions
People think: Prompt injection is solved by better instructions.
Actually: It is an input-trust problem, and only removing capability reduces the impact.
People think: An agent that only writes code cannot cause a breach.
Actually: Generated code runs in CI and production, and dependencies execute at install time.
Interview angle
Treat the agent as an identity with four permission surfaces. A strong answer separates read, write, network and credentials and explains why content cannot be policy, then mentions dependency and CI risk. Focusing on prompt wording, with no audit or scope, is the weak response.
Sources
- OWASP, Top 10 for LLM Applications — prompt injection and excessive agency as risk classes.
- NIST, Secure Software Development Framework — secure development practices that extend to generated code.
- Google, Secure AI Framework — a control framework for AI systems in production.