Page

What a coding agent needs to know to be useful on security

Updated

A coding agent is useful on security only when it has three things: the rule for how your app authorises access, the threat model of what actually matters here, and read access to the code and data the finding touches. It should never have write access to production, because nothing it does needs it.

Where this class of bug actually lives in an agent working on security

  • The authorisation rule. Not "be secure" — the exact call. "Every query goes through the tenant-scoped repository. Never take a tenant id from the request body." A rule that names the allowed call is enforceable; an adjective is not.
  • The threat model. Which findings matter for this app and which are noise. An agent told that multi-tenant data isolation is the top risk will prioritise correctly; one told "fix vulnerabilities" will not.
  • Read access to the code the finding touches. With the route, the handler, the model and the migration in context, the fix is local. Without them it guesses at the data model.
  • No production write. The fix is a pull request. Any agent holding credentials that can write to production is one prompt injection away from an incident.

What to try first

  1. Write the authorisation rule as a project instruction file, with the call to use and the call to avoid, not a principle.
  2. List the three findings that would actually hurt this business and give the agent those first.
  3. Scope the agent's token to the repo and the CI, never to the production environment.
  4. Test the rule: give the agent a finding in a file it has not read and see whether it asks for context or invents it.

A reproduction you can keep

The test is whether the agent follows the rule under pressure. Remove one thing from its context and watch what it does:

Does the agent ask, or invent?
# give a finding that points at a file the agent has no context for
offense findings list --json | jq '.[0] | {id, path, rule}' 

# ask for the fix with the rule in the project instructions
# GOOD: the agent reads the handler, finds the scoped repository,
#       and changes the query to go through it
# BAD:  the agent adds an if (user.role === 'admin') guard and calls it fixed

# the check afterwards is always the same replay
curl -sS -i https://staging.example.com/api/invoices/1003 -H 'Authorization: Bearer ***'

What "fixed" has to look like

Context is right when the agent's fix goes through the allowed path without being told twice, and the replay after the fix returns the same response as a nonexistent id. If the agent invented an access model, the context was thin, not the model.

Where people get this wrong

  • Project instructions that say "follow security best practices" are noise the agent will ignore under pressure.
  • Giving the agent a broad personal token because scoping is inconvenient.
  • Assuming an agent that read the file understood the authorisation model. Reading is not the same as being told the rule.

What Offense does here

Offense runs an agent swarm against your app in a disposable sandbox, keeps the request, the identity and the vulnerable response as evidence, and replays the same attack after the fix so the retest is a control comparison rather than a green check. The agents then ship the fix as a pull request — including the dependency upgrade when the vulnerability came in that way, and the infrastructure change when it is a configuration finding — and your team reviews and merges it. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.

Questions this page answers

What context does a coding agent need for security fixes?

The exact authorisation rule, the threat model of what matters, and read access to the code the finding touches. Nothing more is needed, and production write access is never needed.

Why does an agent add a role check instead of a scoped query?

Because a role check is a local, plausible fix it can write from the file alone. The scoped query needs the rule stated explicitly.

Written by Offense Research, reviewed December 3, 2026. Correct something? Email imran@offenseresearch.com.