AI code review for security: what it finds, what it misses, and how to use it safely

How AI code review tools find security bugs and where they miss them, how to combine them with secure code review by people and testing, and how to keep your source code safe when you use them.

· 7 min read · By RiposteSecurity Research Team

Hong KongSingaporeMalaysia

Key points

  • AI code review tools read code changes and flag likely security bugs, such as injection flaws, missing access checks and exposed secrets. They are fast and never tired.
  • They also miss bugs and report bugs that are not there. Research shows their results on realistic code are much weaker than on easy test sets.
  • Use AI as one layer: alongside static analysis tools, a human reviewer for risky changes, and testing of the running app.
  • AI-written code needs the same or more review than human code. A 2021 study found about 40% of programs written by an AI assistant in security-relevant scenarios had flaws.
  • Source code is confidential. Before sending it to an AI tool, know where the model runs, what is stored and whether it is used for training.

AI code review means using AI tools to read source code and point out problems before the code goes live. For security, that means spotting flaws an attacker could use. Attackers already use AI to find weak spots in public-facing apps, so finding them first in the code is cheaper than finding them in a breach report. This guide covers what AI code review does well, what it misses, how to fit it into secure code review, and how to handle your code safely. For the wider picture of AI on the defending side, see AI in cyber security defence.

How AI code review finds security bugs

Most tools work in one of three ways:

  • Pull request reviewers. The tool reads each code change and leaves comments, like a colleague would.
  • AI added to static analysis. A traditional static analysis tool (one that checks code without running it) finds candidate issues, and AI explains them, filters out likely false alarms and suggests fixes.
  • Chat and agent tools. A developer or reviewer asks the AI to look at a file, trace how data flows, or check a specific concern.

These tools are good at:

  • Common patterns: user input placed straight into a database query or web page (see SQL injection and XSS explained), weak cryptography, unsafe file handling.
  • Secrets in code: passwords, API keys and tokens committed by mistake.
  • Missing checks that are visible in one place, such as an API route with no login check while its neighbours have one.
  • Explaining why something is risky and drafting a fix, which helps developers learn.
  • Reviewing every change, every time, which people rarely manage.

AI tools can also find serious, previously unknown bugs. In November 2024 Google's Project Zero reported that its AI agent, Big Sleep, found an exploitable memory bug in the SQLite database engine before it reached an official release. The team called the results "highly experimental".

What AI code review misses

A study presented at the International Conference on Software Engineering (ICSE 2025) built a more realistic test set of vulnerable code, called PrimeVul. A model that scored 68.26% (F1, a combined accuracy measure) on an older test set scored only 3.09% on PrimeVul. The authors said that larger models, including GPT-3.5 and GPT-4, performed "akin to random guessing in the most stringent settings".

Models have improved since that study, but its main lesson still holds: a tool that looks good in a demo may do much worse on your code. Common gaps:

  • Business logic. Whether a user should be allowed to approve their own refund is a business rule. The code may be "correct" and still wrong.
  • Access control across files. Broken access control often depends on how several services, roles and settings fit together. A reviewer that only sees one change misses it.
  • Configuration and infrastructure. Cloud permissions, storage settings and gateway rules often live outside the code being reviewed.
  • False positives. Tools flag safe code as risky. Too many false alarms and developers start ignoring all of them.
  • Overconfidence. A tool that says "no issues found" has not proven the code is safe.

Combining AI with secure code review by people and testing

Secure code review works best in layers. Each one catches what the others miss.

LayerGood atWeak atWhen
AI code reviewSpeed, common patterns, explaining issues, drafting fixesBusiness logic, cross-system context, consistencyEvery pull request
Static analysis and secret scanningRepeatable rules, known flaw types, leaked keysContext; many false alarms without tuningEvery build
Dependency scanningKnown flaws in third-party librariesYour own codeEvery build, and daily for new advisories
Human source code reviewAccess control, business logic, design flawsScale; reviewer fatigueRisky changes: login, payments, permissions, data export
Penetration testing of the running appProving real impact, finding chained issues and setup mistakesCovering every line of codeBefore launch, after major changes, at least yearly

Decide in advance which changes always get a human security reviewer. A simple rule: any change that touches login, sessions, permissions, payments, personal data or file uploads. For testing the running app, see AI penetration testing explained. Flaws found by any layer feed into your vulnerability management and patching process.

How to review AI-written code

A study published at the IEEE Symposium on Security and Privacy in 2022, asked GitHub Copilot to complete code in security-relevant scenarios. Of 1,689 programs it produced, about 40% had security flaws.

Tools have changed since then, but the point stands: AI-written code needs review. In Singapore, the Personal Data Protection Commission found in 2026 that an AI-written email script at Bee Cheng Hiang exposed 95,364 members' email addresses, and said the problem was how the tool was used and tested, not the tool itself. See the Bee Cheng Hiang case.

  • Treat AI-written code like code from a new contractor: check it line by line where it touches security.
  • Check that every library it adds really exists, is maintained and is the one you meant. AI tools sometimes suggest packages that do not exist or have similar names to real ones.
  • Ask for tests that prove the security-relevant behaviour, such as "a normal user cannot see another user's records".
  • Do not let the same AI tool write and approve the same change.

For building these steps into your development process, see secure coding and DevSecOps for AI-written code.

Keeping your source code safe when you use AI tools

Source code is valuable and often holds more than code: connection strings, internal hostnames, sample customer data in tests. Sending it to an AI tool is sending it to a supplier.

Hong Kong's Privacy Commissioner published a checklist on employee use of generative AI on 31 March 2025. It recommends that organisations name the AI tools staff may use, set clear rules on what information can be put into them, and set rules on storing output, data retention, which devices may be used and which staff may use the tools. The same approach works for code. Ask each AI code review vendor:

  • Where does the model run: the vendor's cloud, your own cloud account, or your own servers? In which country?
  • Is your code, or anything derived from it, stored after the review? For how long?
  • Is your code used to train or improve any model? Is that off by default, and in the contract?
  • Which of the vendor's staff and sub-suppliers can see your code? Is access logged?
  • Can you limit the tool to certain repositories and exclude files with secrets or personal data?

Approve tools centrally. Code pasted into a personal chatbot account is outside every one of these controls. See is ChatGPT safe for work and our supplier security checklist.

AI code review checklist

  • Approved AI code review tool, with a written answer on where code goes, retention and training.
  • Secrets removed from repositories, and secret scanning on every build.
  • AI review plus static analysis and dependency scanning on every pull request.
  • Human security review required for login, permissions, payments, personal data and file upload changes.
  • AI-written code labelled in the pull request and reviewed by a person.
  • Each AI finding confirmed by a developer before it is fixed or dismissed; dismissed findings noted with a reason.
  • Penetration test of the running app before launch and after major changes.
  • Regular check of how many real issues the AI tool found and missed, so you know how far to trust it.

Our penetration testing service includes source code review. Engineers confirm each finding, and client data is never used to train AI models.

Sources

  1. Ding and others, Vulnerability Detection with Code Language Models: How Far Are We?, ICSE 2025, arXiv 2403.18624: arxiv.org
  2. Pearce and others, Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributions, IEEE Symposium on Security and Privacy 2022, arXiv 2108.09293: arxiv.org
  3. Google Project Zero, From Naptime to Big Sleep: Using Large Language Models To Catch Vulnerabilities In Real-World Code, 1 Nov 2024: projectzero.google
  4. PCPD, Privacy Commissioner's Office Publishes Checklist on Guidelines for the Use of Generative AI by Employees, 31 Mar 2025: pcpd.org.hk
  5. PDPC, Voluntary undertaking by Bee Cheng Hiang Marketing Pte Ltd, 21 Sep 2026: pdpc.gov.sg
  6. OWASP, Code Review Guide: owasp.org

Based on public research and guidance available on 26 November 2026.