cd /news/ai-agents/a-threat-model-for-ai-coding-agents-… · home › topics › ai-agents › article
[ARTICLE · art-174371] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

A threat model for AI coding agents: what can go wrong, and where to put the controls

A developer published a reusable threat model for AI coding agents, arguing that teams adopt them like better autocomplete while quietly granting them GitHub tokens, shell access, and repository read permissions. The model identifies prompt injection as the core risk, citing OWASP's LLM Top 10 and Simon Willison's "lethal trifecta" of private data access, untrusted content, and external communication, and recommends controls including throwaway per-run sandboxes, egress allowlists, narrowly scoped short-lived credentials, and human approval for irreversible actions.

recommendation

Cut arbitrary outbound network access from agent sandboxes to a short host allowlist and run each task in a throwaway environment with no SSH keys or cloud credentials mounted.

more in playbook: Securing agents and AI tools
by read5 min views2 publishedNov 22, 2026

Most teams adopt a coding agent the same way: someone installs it, it does something useful on day one, and by the end of the month it has a GitHub token, a shell on a laptop or CI runner, and read access to half the company's repositories. Nobody wrote down what could go wrong, because it never felt like a new system. It felt like a better autocomplete.

It is a new system. It reads text from many sources, decides what to do, and then runs code with whatever access it was given. This post is a threat model you can copy and adapt: what you are protecting, how untrusted input gets in, what an attacker wants, and which control belongs where.

Write down what the agent can touch, not what you intend it to touch. For a typical coding agent the list looks like this:

~/.aws, ~/.ssh, .env files, the CI runner's secrets.

If the list makes you uncomfortable, good. That discomfort is the threat model doing its job. The core problem is simple to state. A language model does not reliably separate instructions from data. Anything the agent reads can steer what it does next. OWASP lists this first in its Top 10 for LLM applications as prompt injection, and it is not solved by better prompts.

For a coding agent, the entry points are everywhere: Assume every one of these can contain instructions written for the agent, not for you.

Simon Willison describes the dangerous combination as the lethal trifecta: an agent with access to private data, exposure to untrusted content, and a way to communicate externally. If all three are present, an injected instruction can read something private and send it out. Coding agents usually have all three by default.

Concretely, the goals fall into four groups:

There is also a non-malicious version of every item: the agent misreads the task and does the damage on its own. Your controls should not care which one it was.

The mistake we see most often is trying to solve everything in the prompt. A system prompt that says "never read .env files" is a suggestion. Here is where each kind of control can actually hold.

Run the code the agent writes somewhere that does not have your assets in it. That means not your laptop and not a CI runner that holds deploy keys. A throwaway environment per run, with nothing mounted from your machine, removes most of the asset list in one move: no home directory, no SSH keys, no cloud credentials unless you put them there.

How strong the boundary needs to be depends on whose code it is. For code from a model that read untrusted text, treat it as untrusted code. A shared-kernel container is a weaker boundary than a virtual machine with its own kernel; our isolation comparison goes through the trade-offs.

Exfiltration needs a way out. If the run has no network, or only a short allowlist of hosts it needs, most exfiltration paths close. This is the single control that breaks the trifecta most cheaply, because you rarely need to cut the private data or the untrusted input to get the task done, but you often can cut arbitrary outbound access. We cover how to build an allowlist in designing an egress allowlist for agent sandboxes.

A secret that is not in the environment cannot leak from it. Give each run only the credentials its task needs, scoped as narrowly as the provider allows, and make them expire when the run ends. Be honest about the limit: code inside the run can read whatever credentials you hand it. Short lifetimes and narrow scopes limit what a leaked value is worth.

Some actions are cheap to undo and some are not. Running tests is cheap. Merging to main, pushing to a release branch, changing CI configuration, or touching production data is not. Put a human approval in front of the second group, enforced outside the agent, so a confused or hijacked agent cannot approve itself.

When something goes wrong, you need to know what the agent read, what it ran and what it touched. That means an audit trail written by the platform, not by the agent, and ideally one that shows if entries were edited or removed. Our post on what an audit log for coding agents should record lists the fields.

Every run should have a wall-clock limit, every command a timeout, and every project a spend ceiling. Loops are the most common failure mode for agents, and they are boring rather than malicious. See timeouts for agent sandboxes for how the clocks interact.

Take an agent asked to fix a failing test. It opens the issue, which was filed by someone outside the company. Hidden in the issue text is an instruction: run a script that reads environment variables and posts them to a URL.

Walk it through the layers:

None of these steps required the model to resist the injection. That is the point. Assume it will not.

Sandscale covers several of these layers for the code your agent runs. Each run gets its own Firecracker microVM with its own kernel, and a sandbox reaches only what your organization's egress allowlist allows. Vault hands a run its secrets in memory as environment variables for as long as the run lasts, and keeps them out of prompts, logs and API answers. Human approvals and a hash-chained audit log come with every plan, and DLP checks prompts and MCP tool calls for credentials before they leave. The security page has the full list by plan.

It does not decide whether your agent's change is correct, and it does not stop an agent from doing something harmful with access you deliberately gave it. The threat model above is still yours to write. Start with the asset list, and be honest about it.

Originally published on the Sandscale blog.

── more in #ai-agents 4 stories · sorted by recency
── more on @owasp 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/a-threat-model-for-a…] indexed:0 read:5min 2026-11-22 · —