Check Your Coding Agent's Security Work: "I Added Auth" Is a Claim, Not a Result
When a coding agent reports "added authentication to all routes" or "fixed the RLS policies", it is describing what it meant to do. The summary is often accurate about what was changed and wrong about what was covered. You verify security work the same way for agents as for people: with a test that would fail if the fix were missing, a second reviewer with no stake in the first answer, and tools that do not take anyone's word for it.
On this page
You do not need to read every line to do this. You need a few checks that produce evidence.
Why the summary is not enough
Agents are good at making a visible problem go away. Security problems are mostly invisible, so the same skill can work against you:
- Partial coverage. Auth added to the five routes it looked at. The sixth, in another folder, is untouched. The summary says "all routes".
- The error was the security. An RLS policy blocked a query, so the agent switched to the service key, or added
using (true), or marked a functionsecurity definer. The feature works now. - Tests bent to pass. A failing access test was "fixed" by changing the assertion or mocking the auth helper.
- Checks in the wrong layer. The button is hidden; the endpoint is open. See auth checked only in the UI.
- New surface. A debug route, a new dependency, a wider CORS setting added along the way and never mentioned.
None of this is bad faith. It is what optimising for "the task appears done" looks like.
Check 1: ask for proof, not a description
Change the request. Instead of "secure the orders API", write:
Write tests that prove:
- GET /api/orders/:id returns 401 without a session
- user A gets 404 for an order that belongs to user B
- PATCH and DELETE behave the same way
Run them against the current code and show me the failures first.
Then fix the code until they pass. Do not modify the tests after
I approve them.
Seeing the test fail before the fix is the important part. A test that never failed proves nothing. It may be testing a mock.
Check 2: read the diff with four questions
You can review a security change without understanding every line:
- Which files changed?
git diff --stat. Anything outside the expected area (config, CI, env files, package.json) needs a reason. - Was anything loosened? Search the diff for the usual suspects:
git diff main | grep -nE "^\+.*(service_role|sb_secret|using \(true\)|security definer|Access-Control-Allow-Origin|\*['\"]|NEXT_PUBLIC_|eslint-disable|@ts-ignore|\.skip\(|--no-verify|verify: *false)"
- Did tests change?
git diff main --stat -- '*.test.*' '*.spec.*'. Removed or weakened assertions in a "fix" commit are a red flag. - Were dependencies added? See our post on hallucinated and malicious npm packages.
Check 3: a fresh reviewer
Open a new session with no memory of the first one, give it the diff, and assign it the opposite role:
You are reviewing this diff as an attacker. List every way a
logged-out visitor or a logged-in user of another account could
still read or change data. For each one, give the exact request
you would send. Do not suggest improvements, only findings.
The agent that wrote the code tends to confirm its own work. A separate session, or a different model, has no such attachment and regularly finds what the first missed. Treat its findings as leads and confirm each with a real request.
Check 4: test it from outside
Evidence beats both agents. The checks we use most, each with its own post:
- Two accounts, swap the IDs: IDOR.
- Replay requests without a session: middleware that skips API routes.
- Query tables, views and functions with the public key: Supabase RLS mistakes.
- Search the build output for keys: secret keys in the frontend.
- Request
/.envand debug paths: exposed .env files and debug endpoints.
An hour with curl and two test users tells you more than any summary.
Check 5: automation that does not get tired
Put the boring checks in CI so they run on every change, whoever wrote it:
# .github/workflows/security.yml
name: security
on: [pull_request]
permissions:
contents: read
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: gitleaks/gitleaks-action@v2
env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }
- run: npm ci --ignore-scripts
- run: npm audit --audit-level=high
- run: pip install semgrep && semgrep scan --config auto --error
- run: npm test
Secret scanning, dependency audit, static analysis, and your access tests. GitHub's own code scanning (CodeQL) is free for public repositories and worth switching on. Scanners find known patterns. They do not find a missing ownership check, which is why the tests from check 1 matter most.
Write the rules down once
Agents follow standing instructions better than they guess intentions. A short section in CLAUDE.md, AGENTS.md or your editor's rules file:
## Security rules
- Every route handler and server action checks the session first.
- Every query on user data is scoped to the current user or org.
- Never use the Supabase secret/service key in client code.
- New tables: enable RLS, add policies, add explicit grants.
- Never weaken or delete a test to make it pass. Ask instead.
- Never add a dependency without naming it and the reason.
- Never write secrets to files. Use environment variables.
Then verify anyway. The rules lower the error rate. The checks catch what is left.
When to bring in a person
Before the first paying customers, before handling health, financial or children's data, and after any incident. A human audit covers what tests and scanners cannot judge: whether the access model itself makes sense.
Our security checklist for vibe-coded apps is the list we work from. If you would like us to run it against your app and fix what it finds, that is our app rescue and security audit.
