Blog
AI code audit: what to check in AI-generated code before you scale, raise or sell
Security & legacy

AI Code Audit: The Complete 2027 Guide (Checklist, Red Flags, Costs and a Sample Report)

An AI code audit is an independent review of software that was written fully or partly by AI coding tools such as Cursor, Claude Code, GitHub Copilot, Lovable, Bolt or v0. It checks whether the code is secure, whether it will hold up as usage grows, and whether another team can safely maintain it. A typical audit takes 5–10 working days and ends with a prioritised fix plan and a fix-or-rebuild verdict for each part of the system.
This guide is written for founders, CTOs and engineering leads who built fast with AI and now need to know what they actually have. It covers when you need an audit and when you don't, a 40-point checklist with clear pass/fail criteria, the red flags we look for first in common stacks, what scanners catch and what they miss, what a good report looks like, how much an audit costs, and what European companies need to add for GDPR.

Short on time? Jump to the 40-point checklist, the 10-minute self-check or costs. If you want us to look at your code, see our AI code audit service.

Two meanings of "AI code audit"

The phrase is used for two different things, and it is worth separating them before you buy anything:
Audit of AI-generated code AI-powered code audit
What is reviewed Code written by AI tools Any code
Who does the review Senior engineers, supported by tools Mainly an AI tool or scanner
Main question "Is what the AI wrote safe and maintainable?" "Can a tool find issues faster?"
Typical output Risk-ranked findings, fix plan, fix-or-rebuild verdict A list of tool findings
This guide is about the first: auditing code that AI wrote. Good audits use AI-powered tools as one input, but they do not stop there.

Why AI-generated code needs a different kind of review

AI coding tools changed which mistakes end up in code, not just how many.
AI fixes the mistakes humans used to make. Typos, syntax errors and small logic slips become rarer. Apiiro, a security vendor that analysed tens of thousands of repositories at Fortune 50 companies between December 2024 and June 2025, reported that syntax errors fell by 76% and logic bugs by 60% among AI-assisted developers, while those developers committed code three to four times faster.
AI adds mistakes that are harder to see. In the same data, privilege escalation paths rose by 322% and architectural design flaws by 153%, and monthly security findings grew from about 1,000 to more than 10,000. The code looks cleaner and is riskier underneath. (Apiiro data as summarised by the Cloud Security Alliance, April 2026; Apiiro sells security products.)
Models write code that runs, not code that is safe. Veracode's 2026 GenAI Code Security Report found that roughly 44% of AI code generation tasks introduced a risky security vulnerability, and the average security pass rate across models was 56%, barely changed from the previous report. Some categories were much worse than others: models passed SQL injection tests 83% of the time, but cross-site scripting only 15% and log injection only 12%.
Some AI-suggested packages don't exist. Research presented at USENIX Security 2025 found that roughly 20% of code samples referenced packages that do not exist. Attackers can register those names and wait ("slopsquatting").
AI-linked vulnerabilities are now being formally recorded. Georgia Tech's Vibe Security Radar counted 74 confirmed CVEs linked to AI-generated code by the end of March 2026, rising from 6 in January to 35 in March. (As reported by the Cloud Security Alliance.)
Teams understand less of their own code. In a study described in the State of AI Report 2026, developers who learned a new library with AI scored 50% on a comprehension quiz afterwards, compared with 67% for those who learned without AI.
Even AI fixing AI is not reliable yet. On the CyberGym-E2E benchmark (920 real vulnerabilities in 139 C/C++ projects), the best agent produced a functional patch from source code 65.9% of the time, but only 22.2% of patches fixed the intended historical bug. (State of AI Report 2026, slide 208.)
AI-assisted code: syntax errors down 76%, privilege escalation paths up 322% (Apiiro data)
The pattern behind all of these numbers is simple: AI is fast and confident. It does not say "I'm not sure". The resulting mistakes look finished, which is exactly why they survive until a customer, an attacker or an investor finds them.

When you need an AI code audit, and when you don't

You need one if

  • Your product handles payments, personal data or health, financial or legal information.
  • You are about to raise money, sell the company or sign an enterprise customer who will run a security review on you.
  • The person who built most of the product with AI has left or is leaving, and someone new is taking over.
  • You are moving from prototype to real users (hundreds or thousands of accounts).
  • Your cloud or AI API bills are growing faster than your usage.
  • An enterprise client sent you a vendor security questionnaire you cannot answer with confidence.

You can probably wait if

  • It is an internal tool with a handful of users and no customer or personal data.
  • It is a throwaway prototype you will rebuild anyway.
  • An experienced engineer already reviewed every change that touches authentication, payments and data, and you have tests on those paths.
If you are unsure, run the 10-minute self-check below first.

The AI code audit checklist: 40 checks with pass/fail criteria

Use this as a working checklist. "Fail" means the issue is present or you cannot show evidence that it isn't.

1. Secrets and configuration

# Check Fail if
1 Secrets in the current code Any API key, password, token or private key is hard-coded in source files
2 Secrets in git history A secret was committed once, even if deleted later, and was not rotated
3 Client-side exposure Server-only keys are bundled into frontend code or public environment variables
4 Environment separation Development, staging and production share the same keys or database
5 Debug settings Debug mode, verbose errors or stack traces are enabled in production

2. Authentication and authorisation

# Check Fail if
6 Object-level access A user can read or change another user's record by changing an ID in a URL or request
7 Database access rules Tables with customer data have no access rules (for example row-level security is off)
8 Server-side checks Permissions are only enforced in the user interface, not on the server
9 Admin and internal routes Admin pages or internal APIs are reachable without strong authentication
10 Session and tokens Tokens never expire, are stored insecurely, or are not invalidated on logout or password change

3. Money and critical business paths

# Check Fail if
11 Payment webhooks Incoming payment events are accepted without verifying their signature
12 Idempotency A retried request can charge, refund or create an order twice
13 Price and quantity checks Prices, discounts or quantities are trusted from the browser
14 Sign-up and verification Accounts can be created or upgraded without the intended checks
15 Data export and deletion A user can export or delete data that is not theirs, or cannot delete their own

4. Dependencies and supply chain

# Check Fail if
16 Known vulnerabilities Dependencies have known high or critical CVEs with available fixes
17 Package existence A package name does not exist on the official registry or was registered very recently by an unknown author
18 Unnecessary packages Packages are installed that the code does not use
19 Licences Dependencies carry licences that conflict with how you sell the product
20 Lock files There is no lock file, so builds can silently pull different versions

5. Tests and change safety

# Check Fail if
21 Tests on revenue paths Sign-up, payment and core workflows have no automated tests
22 Meaningful tests Tests only check that functions run, not that results are correct
23 CI checks Changes reach production without automated tests and checks running
24 Database migrations Schema changes are run by hand or cannot be rolled back
25 Change test A small change in one area breaks unrelated features

6. Architecture, errors and cost

# Check Fail if
26 Duplicated logic The same business rule is implemented differently in several places
27 Error handling Errors are swallowed silently or shown to users with internal details
28 Performance traps Obvious scaling issues exist, such as one database query per item in a list
29 Cost limits There is no limit or alert on cloud and AI API spend
30 Logging and monitoring You cannot tell what happened when something fails in production

7. AI features inside the product

# Check Fail if
31 Prompt injection Instructions hidden in user input or uploaded documents can change what the model does
32 Tool permissions An AI feature can call tools or APIs with more access than it needs
33 Data in prompts Personal or confidential data is sent to an AI provider without need or agreement
34 Output handling Model output is executed, rendered as HTML or written to the database without validation
35 Abuse and cost One user can trigger unlimited AI calls

8. Data protection and maintainability

# Check Fail if
36 Personal data in logs Logs, error messages or analytics contain personal data
37 Data retention There is no way to delete a user's data across the system
38 Data location You do not know which countries and providers store or process your data
39 Documentation There is no up-to-date description of how to run, deploy and change the system
40 Knowledge concentration Only one person, or no one, understands the critical paths
AI code audit checklist: 40 checks in 8 areas from secrets to GDPR

Red flags by stack: what we check first

AI app builders and coding assistants tend to repeat the same patterns. These are the first places we look.

Supabase

  • Row-level security switched off on tables with customer data, or policies that allow every authenticated user to read every row.
  • The service role key used in frontend code.
  • Storage buckets set to public when they hold private files.

Firebase

  • Security rules left open ("allow read, write") after development.
  • Admin SDK credentials committed to the repository.

Next.js and other full-stack JavaScript frameworks

  • API routes and server actions that perform changes without checking who the user is.
  • Secrets placed in variables that are exposed to the browser (for example the NEXT_PUBLIC_ prefix in Next.js).
  • Authorisation done in middleware or the UI only, not where the data is actually read or written.

Apps generated with Lovable, Bolt, v0 or similar builders

  • Business logic and access checks living in the browser.
  • Default database settings never reviewed.
  • Several slightly different copies of the same feature after many prompt iterations.

Python (Flask, Django, FastAPI)

  • Debug mode enabled in production.
  • Requests to URLs supplied by users without restriction (server-side request forgery).
  • File paths built from user input (path traversal).

Payments (Stripe and others)

  • Webhooks processed without signature verification.
  • Prices or plan IDs accepted from the client.
  • No protection against the same event being processed twice.

LLM features

  • System prompts treated as a security boundary.
  • Retrieval over documents that users can upload, with no defence against hidden instructions.
  • No per-user rate limits or spending caps.

Automated tools vs human audit

Automated tools are fast and cheap and should always be part of an audit. They are not enough on their own.
Area Tools that help What tools usually catch What still needs a person
Code patterns Static analysis such as Semgrep/OpenGrep, CodeQL, language linters Injection patterns, unsafe functions, debug settings Whether a "safe-looking" query still exposes the wrong data
Secrets Gitleaks, TruffleHog Keys and tokens in code and history Whether exposed keys were rotated and what they could access
Dependencies npm audit, pip-audit, OSV-Scanner, Dependabot Known CVEs, outdated packages Whether a package should be there at all
Infrastructure Checkov and similar IaC scanners Open storage, missing encryption flags Whether the architecture fits the business
Authorisation Limited Missing decorators or middleware in some frameworks Whether user A can reach user B's data in real flows
Business logic Very limited Almost nothing Double charges, broken refunds, wrong prices
AI features Emerging Some prompt-injection patterns Real-world abuse paths and cost exposure
There is also a practical problem with relying on a single tool. In an independent study by AppSec Santa, AI-generated code was run through five security scanners and every finding was validated by hand. 59.5% of the confirmed vulnerabilities were found by only one of the five tools. Choosing one scanner means missing most issues; running five means sorting through many false positives (772 of 926 raw findings in that study were false).
The most expensive problems in AI-built products are usually authorisation and business-logic issues. Those are exactly the ones tools are worst at.

What a good AI code audit report looks like

A useful report is short at the top and specific underneath. It should have four parts:
  1. A one-page summary for founders, boards and investors: overall risk level, the top issues in plain language, and the estimated cost and time to fix.
  2. Findings with evidence: each one with severity, location, how to reproduce it and how to fix it.
  3. A fix plan in order of risk: what to fix this week, this month and before scaling.
  4. A verdict per module: fix, refactor or rebuild.
Here is what individual findings should look like. (Illustrative example, not a real client.)
ID Severity Area Location Evidence Risk Fix Retest
F-01 Critical Secrets config/payments.ts, git history Live payment key committed and still valid Anyone with repo access can issue refunds Rotate key, move to secret manager, purge history Key rotated, scan clean
F-02 Critical Authorisation /api/invoices/[id] Changing the ID returns another customer's invoice Customer data leak, GDPR breach Check ownership on the server for every read Test added and passing
F-03 High Payments Webhook handler Signature not verified Forged "payment succeeded" events Verify signature, reject unsigned events Test added and passing
F-04 Medium Cost AI summary feature No per-user limit One user can run up the AI bill Add rate limit and daily cap Limit confirmed in staging
Sample AI code audit report with findings, severity, evidence, fix and retest
If a provider cannot show you a sample like this before you buy, ask for one.

How an AI code audit works, step by step

This is how we run it at Bonsay. Most good audits follow a similar shape.
  1. Access and NDA (day 1). Read-only access to the repository, and to a staging environment if possible. Either side's NDA. Nothing is changed without written consent.
  2. Review (days 2–6). Automated scans for secrets, dependencies, code patterns and infrastructure, followed by a senior engineer reading the critical paths by hand: authentication, authorisation, payments, data flows, AI features and deployment.
  3. Report and readout (days 7–10). Findings by severity with evidence, a fix plan in order of risk, a fix-or-rebuild verdict for each module, and a one-hour session with your team.
  4. Fix (optional). We fix the issues at a fixed price, a senior engineer joins your team, or your developers fix them and we check again.
How an AI code audit works: access and NDA on day 1, review on days 2–6, report on days 7–10, optional fixed-price fix; from €3,000 for a single app
How to verify that a fix is real: for every serious finding, ask for a test that fails before the fix and passes after it. That turns "we fixed it" into evidence you can keep.

How much does an AI code audit cost?

Prices on the market vary widely because "audit" can mean anything from an automated scan to weeks of manual review. What drives the price:
  • Size and number of services: lines of code, repositories, mobile and web clients.
  • Risk level: payments, personal or regulated data, AI features with tool access.
  • Depth: tool scan only, or manual review of critical paths.
  • Deliverables: findings list only, or summary, fix plan, verdict and retest.
Our published prices (fixed before we start):
Scope Price Time
Single application, up to about 30,000 lines of code from €3,000 5–10 working days
Larger or multi-service systems €5,000–8,000 5–10 working days
Fixes after the audit fixed price, agreed from the report depends on findings
To compare providers fairly, ask every vendor the same five questions: what exactly is reviewed by a person, how many days of senior engineering time are included, what the report looks like, whether retesting is included, and what happens to your code and data during and after the audit.
See all prices on our pricing page.

AI code audits for European companies: GDPR and EU rules

If you build or sell software in the EU, an AI code audit should also cover:
  • Personal data in logs, prompts and error messages. AI-generated code often logs whole requests by default.
  • Data sent to AI providers. If your product or your developers send personal data to AI services, those services act as processors or sub-processors and need the right agreements and documentation.
  • Data location. Know which providers and regions store and process your data.
  • Deletion. You must be able to delete a person's data across databases, backups, logs and third-party tools within your policy.
  • Incident reporting for software vendors. Since 11 September 2026, manufacturers of products with digital elements have to report actively exploited vulnerabilities under the EU Cyber Resilience Act, with an early warning within 24 hours. Knowing what is inside your code, including dependencies, is now a legal need, not just good practice.
  • AI features and the EU AI Act. If your product uses AI to interact with people, transparency obligations apply, so users should know when they are dealing with AI.
This section is a practical summary, not legal advice.

After the audit: fix, refactor or rebuild?

An honest audit sometimes says "rebuild this part". That is not a failure; it saves money compared with patching a fragile module forever. A simple rule we use:
  • Fix when the structure is sound and problems are local (keys, missing checks, missing tests).
  • Refactor when the logic is right but tangled, duplicated or impossible to test.
  • Rebuild when the module's design is the problem (for example, access control that lives in the browser), or when fixing costs more than rewriting.
If the people who built the product with AI are gone, the next step is often a structured takeover: documenting the system, adding tests around critical paths, and then modernising one module at a time. See our software takeover service.

How to keep AI-written code safe after the audit

An audit is a snapshot. If your team keeps shipping AI-generated code, add a few habits:
  • Label AI-assisted changes. Use pull-request labels or commit trailers so reviewers know what to look at more carefully.
  • Make critical paths "human-reviewed only". Authentication, payments and data deletion should always get a senior review.
  • Run the same scanners on every pull request, not once a year.
  • Keep secrets out of reach of AI tools and rotate any key that has been pasted into a prompt.
  • Re-audit before big moments: fundraising, acquisition, a large enterprise customer or a major release.

A 10-minute self-check for founders

Answer these with your lead developer. Three or more "no" or "not sure" answers mean you should get a closer look.
  1. Are there no secrets in the repository or its history?
  2. Can a customer not access another customer's data by changing an ID?
  3. Are database access rules switched on for every table with customer data?
  4. Do sign-up, payment and data export have automated tests?
  5. Do you know every package in your dependency list and why it is there?
  6. Are admin pages and internal APIs protected by strong authentication?
  7. Are AI features protected against instructions hidden in user input?
  8. Is there a cap on daily cloud and AI spending?
  9. Is personal data kept out of logs and prompts?
  10. Could a new developer safely change the payment flow within a week?
AI code audit 10-point self-check for founders: secrets, data access, tests, dependencies, AI features, spend caps

Frequently asked questions

What is an AI code audit?

An independent review of software written fully or partly by AI coding tools. It checks security, reliability, maintainability and cost, and ends with a prioritised fix plan and a fix-or-rebuild verdict for each part of the system.

How long does an AI code audit take?

Usually 5–10 working days from access to a written report for a single application. Larger or multi-service systems can take longer.

How much does an AI code audit cost?

At Bonsay, from €3,000 for a single application of up to about 30,000 lines of code, and €5,000–8,000 for larger or multi-service systems. The price is fixed before the audit starts.

Are automated AI code review tools enough?

They are a necessary first step but not enough. Tools disagree with each other and are weak at authorisation and business-logic issues, which are often the most expensive problems in AI-built products.

What access do you need?

Read-only access to the repository, and ideally to a staging environment. No production access is required, and nothing is changed without written consent.

Is AI-generated code a red flag for investors or buyers?

Not by itself. What worries investors is code nobody has reviewed. An audit report with a fix plan turns an unknown risk into a known, costed one.

Can you fix the problems you find?

Yes, at a fixed price agreed from the report. Alternatively, a senior engineer can join your team, or your developers can fix the issues and we check the fixes.

Will our code be used to train AI models?

It should not be, and you should ask every provider this question. Agree in writing how your code is handled, where it is stored and when it is deleted.

Is an AI code audit the same as a penetration test?

No. A penetration test attacks a running system from the outside. A code audit reads the code and configuration from the inside. They complement each other.

Do you audit apps built with Lovable, Bolt, v0, Cursor or Claude Code?

Yes. The tool matters less than the patterns it produces, and we know where each type of tool tends to leave gaps.

Get your AI-built code reviewed

If your product was built fast with AI and is about to meet real customers, investors or auditors, find out what you have before someone else does.
Fixed price agreed before we start. A report you can read in ten minutes. And if your code is in good shape, we will tell you that too.

Sources

  • Veracode, 2026 GenAI Code Security Report (blog post, 28 July 2026)
  • Cloud Security Alliance AI Safety Initiative, Vibe Coding's Security Debt: The AI-Generated CVE Surge (April 2026), summarising Apiiro, Georgia Tech Vibe Security Radar and other research
  • Cloud Security Alliance AI Safety Initiative, Vibe Coding Security Debt: AI-Generated Vulnerabilities at Scale (April 2026)
  • AppSec Santa, AI-Generated Code Security Study 2026 (updated May 2026)
  • State of AI Report 2026, Nathan Benaich and Air Street Capital (slides 104 and 208)
  • EU Cyber Resilience Act reporting obligations (applicable from 11 September 2026)