Coding agent

How to security test an app built with Claude Code

Updated

Claude Code's output is strongest on multi-file work, which is also where a security control can be refactored out of three call sites while the tests stay green. Test by diffing the authorization and validation boundaries across the whole change, not by reading the new feature code.

Where this class of bug actually lives in Claude Code output

  • Wide refactors. A change that touches fifteen files can move an authorization check from the handler into a helper that one caller never uses.
  • Interface changes. A widened function signature that starts accepting an id it used to derive from the session.
  • Test rewrites. A changed assertion that makes an authorization test pass by asserting less.
  • Shell and git actions. Broad file and command access in the session itself, which is a separate risk from the code it writes.

What to try first

  1. Read the diff for removed lines in permission, validation and query functions before reading added lines.
  2. Check every call site of a changed function for whether the security-relevant argument still comes from the session.
  3. Look at test changes: a deleted assertion is a removed control with no code smell.
  4. Run the two-account id swap across the whole surface, not just the changed endpoints.

A reproduction you can keep

The diff is the artifact. Grep it for what disappeared:

What the refactor removed
git diff main -- '*.ts' '*.py' '*.go' \
  | grep -E '^-' \
  | grep -iE 'authorize|permission|tenant|org_id|user_id|where|scope' \
  | head -40

# then exercise the endpoints those lines belonged to
curl -sS -i https://staging.example.com/api/invoices/1003 -H 'Authorization: Bearer ***'

# vulnerable: a removed where-clause, and 1003 comes back for the wrong account
# fixed: the constraint moved but still applies — now 404

What "fixed" has to look like

Every removed authorization or scoping line must be accounted for by a replacement that runs on the same path. Verify by exercising the affected endpoints with two accounts, and by confirming the tests that covered them were not weakened rather than deleted.

Where people get this wrong

  • A green suite after a refactor can mean the tests were adjusted to the new behaviour.
  • Helper extraction is where checks vanish: the new helper is called by three of four callers.
  • Granting the agent broad command access is its own risk, separate from the code quality.

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. It does not read your source and it does not patch your code: the finding goes to your coding agent with the reproduction attached. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.

Questions this page answers

What should I review first in a Claude Code change?

Removed lines in authorization, validation and query-scoping functions, and any test assertion that got weaker.

Are passing tests evidence the refactor is safe?

Not for authorization. Tests rarely encode the cross-tenant case, and a refactor can rewrite the test alongside the code.

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