What a code security audit is (and isn't)
An audit reads the source. That is the whole distinction. A penetration test probes the running app from outside; a vulnerability scan matches dependencies against advisories; a checklist verifies configuration you already know to check. The audit sits underneath all of them: a person reads the code, traces how data and identity move through it, and asks at each point “what happens if the caller is hostile?” OWASP's Code Review Guide is an OWASP project written for exactly this job: people reading source code for security flaws. Scanners have improved since it started; AI-generated code has made the human read more necessary, not less.
This page is the methodology. If what you want instead is a point-by-point list of configuration checks, use our 25-point AI app security checklist. If you want the broader go/no-go review before shipping — payments, email, deploy, observability, not just security — that's the launch-readiness audit. This guide covers the layer those two assume: reading the code itself.
What a code security audit covers
The scope maps cleanly onto the OWASP Top 10 (2025 edition), the standard consensus list of the most critical web application risks. Below is each area an audit examines, what a reviewer checks in the code, and the finding we see most often in AI-generated codebases. The third column is the reason generic audit guides underserve AI-built apps: the failure distribution is different.
| Category | What's checked | Common finding in AI-generated code |
|---|---|---|
| Access control (A01) | Every endpoint and query enforces ownership, not just login | Routes that check the session exists but never check the resource belongs to the caller; database row-level policies missing or set to allow-all |
| Configuration (A02) | Env var exposure, framework defaults, CORS, debug flags | Secrets shipped to the browser via public-prefixed env vars; permissive CORS added to “fix” an error |
| Supply chain (A03) | Dependency list, lockfile integrity, install scripts | Packages the AI added that nothing imports; stale versions with known advisories nobody ever audited |
| Cryptography (A04) | Password hashing, token generation, transport security | Homegrown tokens built on non-cryptographic randomness instead of the platform's crypto APIs |
| Injection (A05) | Parameterized queries, output encoding, template safety | User input interpolated into raw SQL inside custom functions, next to perfectly parameterized ORM calls |
| Authentication (A07) | Session lifecycle, reset flows, brute-force protection | Route protection that lives only in the UI; no rate limiting on custom login or reset handlers |
| Logging & alerting (A09) | What gets logged, what gets alerted, what leaks into logs | Tokens and full request bodies dumped to logs during debugging and never removed; no alerting at all |
The remaining Top 10 categories — insecure design (A06), software and data integrity failures (A08), mishandling of exceptional conditions (A10) — show up in audits as judgment calls rather than table rows: does the architecture make the safe path the easy path, does the deploy pipeline verify what it ships, does the app fail closed when something unexpected happens. A reviewer holds them in mind through every step below rather than checking them in one place.
How to run a code security audit yourself
Tool-agnostic, in order. The sequence matters: automated first because it's cheap, manual second because it's where the real findings are, verification last because an unconfirmed finding is a guess.
- Inventory every entry point. List all routes, API handlers, webhooks, scheduled jobs, and file-upload paths. AI builders generate endpoints liberally; the ones you forgot exist are the ones nobody secured. The list is your audit scope — if it's not on the list, it doesn't get reviewed, so make the list honest.
- Map the trust boundaries. For each entry point, note who can reach it (anonymous, authenticated, admin, another service) and what it can touch. Everything crossing from less-trusted to more-trusted is where the manual review concentrates.
- Run the automated pass. Three scans, whatever your stack: a dependency audit against known advisories (your package manager ships one), a secret scan over the repo and its full git history, and a static analyzer if a mature one exists for your language. Triage the output — automated findings are leads, not conclusions.
- Read every authentication and authorization path by hand. For each entry point from step 1: where is identity established, and where is ownership checked? “Logged in” and “allowed to touch this row” are different questions, and AI-generated handlers routinely answer only the first.
- Trace user input to its sinks. Follow every piece of caller-supplied data to where it lands: database queries, rendered HTML, file paths, shell commands, outbound requests. At each sink, confirm the value is parameterized or encoded for that context — not “validated” somewhere upstream and trusted thereafter.
- Review secrets and configuration. Every credential lives in server-side env vars, none in the client bundle, none in git history. Check framework config for debug modes, open CORS, and defaults the AI accepted without anyone deciding to.
- Verify what you found. For each suspected issue, demonstrate it: call the endpoint as a second user, replay the request without the session, send the payload that breaks the query. The two-user test — create data as user A, try to read it as user B — confirms more access-control findings than any other single technique.
- Write it up, fix, re-test. One line per finding: location, severity, how you proved it, the fix. Fix in severity order. Then — this is the AI-code-specific step — grep the codebase for every other instance of the same pattern before you close the finding. AI mistakes are systematic; a fixed instance with unfixed siblings is an open vulnerability with better paperwork.
Code audit checklist: what to check beyond security
A security audit is one slice of a full code audit. When the question is “can we build on this codebase?” rather than “can someone break in?”, add these checks after the eight steps above. Automated code audit tools cover parts of the dependency and test rows; the rest is reading.
Architecture and maintainability
- Business rules live in one place, not copied into each page or handler.
- Data access goes through one layer, so an ownership check can be added once.
- No dead files, duplicate components, or abandoned experiments left by earlier prompts.
- Types are strict enough that the compiler catches a renamed field.
Tests and CI
- Tests exist for the money paths: sign-up, payment, and anything that deletes data.
- At least one test logs in as user B and tries to read user A's data.
- CI runs the type check, lint, and tests on every pull request, and a failure blocks the merge.
Dependencies and licenses
- Every package in the manifest is imported somewhere; unused ones come out.
- The lockfile is committed and matches the manifest.
- Licenses are compatible with how you ship (copyleft packages in a closed-source product need a decision).
Performance
- No query inside a loop over rows (the N+1 pattern) on list pages.
- Columns used in filters and joins are indexed.
- Large lists paginate on the server instead of loading every row into the browser.
Deploy and ops readiness
- Production, preview, and local environments use separate keys and databases.
- Errors reach a log or alert someone reads, without tokens or full request bodies in them.
- Database backups exist and someone has restored one at least once.
- A failed deploy can be rolled back without a code change.
Extra checks for AI-generated code
- Search for the pattern, not the instance. Every confirmed finding gets a repo-wide search for its siblings before it is closed.
- Compare the UI guard with the server guard. A hidden button is not access control; the handler behind it must check the caller too.
- Check what the builder configured for you. Database policies, storage buckets, and environment variables set up by the tool are part of the audit scope.
- Look for half-finished fixes. Prompted repairs often patch the one file that threw the error and leave the same code elsewhere untouched.
The configuration side of this, point by point, is in our guide to securing AI-generated code before launch.
Severity scoring guide
Score each finding by what an attacker or a failure could do, then fix in that order. A four-level scale is enough for most codebases.
| Severity | Meaning | Example |
|---|---|---|
| Critical | Anyone can read, change, or delete other users' data, or reach a secret key | A service key in the client bundle; a table with no row-level policy |
| High | A logged-in user can act outside their own account | An update endpoint that checks the session but not ownership |
| Medium | Exploitable with effort, or a likely outage or data-quality failure | No rate limit on password reset; an unverified webhook |
| Low | Hardening or maintainability, no direct exploit | Missing security headers; unused packages |
DIY or professional audit?
Both are legitimate. The honest split is about what's at stake and whether you can read the code with a hostile eye — not about effort or intelligence.
| Your situation | What fits |
|---|---|
| Pre-launch, no real users, you can read the code | DIY the full eight steps. Worst case you learn your own codebase. |
| You can't confidently read the code the AI wrote | Steps 1–3 and 6 are still yours to do. Hand steps 4, 5, and 7 to a professional — that's where reading skill decides the outcome. |
| Handling payments, health data, or anything regulated | Professional, before launch. The cost of an audit is not comparable to the cost of a disclosure in these domains. |
| Your DIY pass already confirmed one real vulnerability | Professional. In AI-generated code, one confirmed finding predicts siblings — you've proven the generator made the mistake, not that it made it once. |
| Live app, real users, and you've never audited it | Professional, now. Every day unaudited in production is exposure you can't retroactively remove. |
On our side that ladder has two rungs. The $49 repo audit is a senior engineer reading your repository and returning a written PDF report within 48 hours — the cheapest way to learn whether your DIY pass missed anything material. The $499 security audit is the full three-day engagement: every step above, run against your app, with verified findings and severity-ordered fixes. Both are done by senior engineers — that's the only kind we staff. If you are comparing outside quotes, see what code audit services cost, or read how a code audit specialist approaches an AI-built repo.
Start with the cheapest honest step
Run steps 1 through 3 yourself this week; they need no security expertise and they shrink any professional engagement you buy later. If the automated pass comes back loud, or the manual steps are past your comfort line, the $49 audit exists precisely for that moment: a fixed price, a written report, and a clear answer on whether you need more.
Related reading
- The 25-point security checklist for AI-built apps — the configuration checks, point by point
- The pre-launch audit: 40 checks before you ship — the full go/no-go review beyond security
- Is AI-built code safe for production?
- The professional AI app security audit
Sources
- OWASP Top 10:2025 — category names and IDs A01 to A10
- OWASP Code Review Guide
Sources checked 4 November 2026.