सबै पोस्टमा फर्कनुहोस्

Who can break your app? A production gate for agent-written code

Six kinds of attacker, one launch rule, and the CI checks that stop AI agents merging around it.

AI agents now write a lot of the code that reaches production. They write it fast, and they write it confidently. Confidence is not a release criterion.

Most security checklists are sorted by technology: authentication, headers, dependencies. That makes sense to the person building the app. Attackers don't think that way. They think about what they can reach. So this gate is sorted by who could hurt you, and every item has one plain test.

Check only apps you own, on your own accounts, preferably on a staging copy.

The launch rule

Every check gets one of three labels:

  • Stop: don't ship until it's fixed. Someone could reach data, money or admin access with little effort.
  • Fix soon: give it an owner and a date. It needs an account, a trick or bad luck to hurt you.
  • Hardening: backlog it. An extra layer that makes other mistakes cheaper.

Ready to ship = zero open Stop items, and every Fix soon item has an owner and a date. Agent-written or human-written, the rule is the same.

1. The stranger: no account, just your URL

Bots probe every new site within hours.

  • Stop: the database has no public endpoint, and every Supabase or Firebase table has row-level security or rules.
  • Stop: no secret key in anything the browser downloads. Search the built JavaScript.
  • Stop: /.env, /.git/config and /backup.sql on your domain all return 404. Agents sometimes deploy the whole folder.
  • Fix soon: /admin, /swagger and /api-docs need a login. Try them in a private window.
  • Fix soon: errors don't show stack traces, SQL or file paths.
  • Hardening: security headers (HSTS, Content-Security-Policy, X-Content-Type-Options, frame-ancestors, Referrer-Policy), and redirects only to your own pages.

2. The customer: has a normal account

They want to see more, pay less or get more than they should.

  • Stop: every record loaded by ID is checked against the signed-in user. As Alice, open Bob's order URL.
  • Stop: the server decides price, role, plan and "paid". Edit the price in the checkout request and resend it.
  • Stop: orders unlock only after the payment provider's verified webhook. Open the "payment success" page without paying: nothing should unlock.
  • Fix soon: users can't add fields like role or credit to their own update; plan limits are enforced by the API, not by hidden buttons; responses return only what the screen needs.
  • Hardening: coupons and trials can't be redeemed twice by sending two requests at once.

3. The insider: staff, admins and your own laptop

Not always malicious. A stolen password works just as well.

  • Stop: MFA on every admin, cloud, payment, domain, email and code-hosting account.
  • Stop: no demo admin or default password in production.
  • Fix soon: production keys differ from test keys and live only in your host's secret settings; staff have only the access their job needs; logins, role changes, exports and refunds are logged, without secrets.
  • Hardening: anyone who leaves loses access the same day.

4. The supplier: code you didn't write

Packages, third-party scripts, templates and copied repos. With agents, this one is bigger than it looks.

  • Stop: no dependency with a known critical or high vulnerability that has a fix (npm audit, pip-audit or OSV-Scanner).
  • Fix soon: lockfiles are committed; third-party scripts are few and loaded with Subresource Integrity where possible.
  • Fix soon: templates and copied repos hide no instructions for your AI assistant. Read rules files, READMEs and install scripts before your agent does.
  • Hardening: replace unmaintained packages.

5. The robot: bots, scripts and AI agents

They don't get tired, and every call can cost you money.

  • Stop: login, sign-up, reset, OTP and every paid endpoint are rate-limited on the server. Send the request fifty times in a loop.
  • Stop: AI features have per-user quotas and a hard spending cap at the provider.
  • Stop: content your AI reads can't give it orders, and its tools only touch the current user's data.
  • Fix soon: public forms have a bot check; model output is escaped before display and never run as code or SQL.
  • Hardening: features that fetch a URL for the user block internal addresses like 169.254.169.254.

6. The bad day: when something still goes wrong

Not a person, but the moment you'll be judged on.

  • Stop: backups run automatically, and you've restored one in the last 90 days.
  • Fix soon: you can roll back in minutes; someone is alerted on error spikes, login-failure spikes and downtime; /.well-known/security.txt tells researchers how to reach you.
  • Hardening: a short plan for telling affected users, written before you need it.

Make the gate automatic

A checklist you run by hand gets skipped on a busy Friday. The point of a gate is that agents can't merge around it. Here is the minimum I'd wire into CI for any repo where agents commit:

# .github/workflows/gate.yml (core steps)
- uses: gitleaks/gitleaks-action@v2              # secrets never reach the repo
- run: npm audit --audit-level=high              # the supplier: known vulnerable packages
- run: semgrep scan --config auto --error        # risky patterns in new code
- run: npx playwright test tests/security        # Alice/Bob swap, price edit, rate limit: as tests

Then add guardrails around the agent itself:

  • Project rules file (for example CLAUDE.md): your security rules, read before every change.
  • Hooks that block commits containing secrets, and edits to protected files.
  • Read-only first: the agent reports, a human approves, then it fixes one thing at a time.
  • Every bug becomes a test or a rule, so the same hole can't be reopened by the next agent run.

Questions the code can't answer

Ask the owner. Any "no" or "not sure" becomes an action item.

  1. Has a live key ever been pasted into a chat, ticket or AI tool? Rotate it.
  2. Does every paid service (cloud, AI, SMS, email) have a budget alert?
  3. Is the repository private, and was it ever public?
  4. Who gets the alert at 2 a.m., and how?
  5. Are you storing anything you don't need: card numbers, ID scans, plain passwords?
  6. Which privacy law covers your users (for example GDPR, or Nepal's Individual Privacy Act 2075), and does your privacy policy say what you collect and why?

An honest limit: this is a map, not a penetration test. If you take payments at scale or hold health, ID or financial data, get a professional review as well.

Take it with you

↑ ↓ सार्नुहोस् · ↵ छान्नुहोस् · esc बन्द