Skip to content
PKResources
Course outline

The CTO's playbook for AI coding agents · Module 4: Guardrails and governance

Threat-modeling a coding agent

A coding agent reads untrusted text and holds real permissions. Map where those two meet, rank the scenarios by blast radius, and you know where governance money goes first.

Lesson 13 / 20 · ⏱ 8 min

Your security team has a threat model for every service you run. A coding agent deserves one too, because it is an unusual service: it reads text written by strangers and acts with an engineer’s permissions. Every serious agent incident lives where those two facts meet.

This lesson gives you a one-page model you can run with your security lead in an hour.

Draw the boundaries first

Start with a picture, not a list. Put the agent in the middle, then ask which inputs you control, which you don’t, and what the agent can touch on the way out.

UNTRUSTED INPUTSWHAT IT CAN TOUCHRepo files, commentsIssues, tickets, PRsDocs, web pagesDependencies, toolsorg-controlled boundaryPolicy, managed settingsAgentSandbox, scoped secretsShell, files, gitNetwork egressPackage registryModel vendor12345
The agent sits on a trust boundary. Anything on the left can carry instructions that didn't come from you; anything on the right is where those instructions turn into damage.

The five threats that matter

# Threat How it happens First control
1 Prompt injection A README, issue or web page contains text phrased as an order Treat content as data; remove the dangerous capability, not the text
2 Destructive commands An honest mistake: wrong folder, force push, dropped table Sandbox, deny-list for irreversible actions, human gate
3 Supply chain The agent installs a package that doesn’t exist yet, or a lookalike Internal registry proxy, allowlisted sources, lockfile review
4 Secret exfiltration Credentials in env or files end up in a log, commit or outbound request No production secrets in reach, egress allowlist, scanning
5 Data leakage to vendors Proprietary code or customer data sent to a model provider with weak terms Approved vendors only, data classification, retention review

Notice the pattern in the last column. Almost none of the controls are “write a better prompt”. You can’t instruct your way out of injection; you limit what a fooled agent can do. That’s the same reasoning behind the OWASP Top 10 for LLM applications: excessive agency is the multiplier on every other risk.

Rank the scenarios

Not every agent use is equally dangerous. A developer asking for a refactor in a sandboxed branch is not the same as a bot that triages public issues with write access. Sort these the way your security review should.

🎮 High or low risk?

1 / 8 · Score: 0

Apply the three-leg test: untrusted input, something valuable, a way out.

Turn it into a register

Keep the output small enough that people maintain it. One row per agent use case, reviewed when the use case gains a new tool or permission.

  1. 1

    15 min

    List use cases

    Local assistant, CI reviewer, issue bot, migration helper. Name an owner for each.

  2. 2

    15 min

    Score the three legs

    For each use case: untrusted input? valuable access? a way out? Yes or no.

  3. 3

    20 min

    Break one leg

    For every row with three yeses, pick the cheapest leg to remove. Usually egress or the token scope.

  4. 4

    10 min

    Set a review trigger

    Any new tool, scope or data source reopens the row. Put it in the change process, not a calendar.

For the developer-level mechanics (allowlists, sandboxes, test credentials), point your teams to Guardrails: permissions, sandboxes and secrets. The next lesson turns this model into org-wide defaults.

Before you move on

✅ Key takeaways

0 / 5 completed