Skip to content
AI & Security

Source Code Review in the Age of AI-Generated Code

AI assistants write code that compiles, passes tests and still carries insecure patterns. Why independent source code review matters more now, and how the OWASP Top 10 for LLM Applications and PCI DSS Requirement 6.2.3 apply.

Cyber Guard Africa Team5 min read

Hands typing on a laptop with lines of code on a dark terminal screen, in red duotone
On this page

AI coding assistants have changed how software gets written in Nairobi, Lagos and everywhere else. A developer can describe a feature in a sentence and receive a working function in seconds. Teams ship faster, backlogs shrink and prototypes become production systems before anyone has asked whether the code is safe. That last question is the one that matters, and it is why source code review has become more important, not less, in the age of AI-generated code.

Code that works is not the same as code that is secure

Functional testing confirms that software does what it should. Security is about what it should not do. A login form can accept every genuine user and still let an attacker bypass it. A payments API can process every transaction correctly and still let one customer read another customer's statement by changing a number in the request. These flaws are invisible during normal use. They only appear when someone deliberately looks for them.

AI assistants make this gap wider. They learn from enormous amounts of public code, and public code contains plenty of insecure patterns. The output looks idiomatic and confident, compiles cleanly and passes the happy-path tests. It can also carry string-built SQL queries, missing authorisation checks, weak hashing, hardcoded secrets or a library version with a known vulnerability. Because the code looks finished, it often gets less scrutiny than a junior developer's first pull request would.

What goes wrong with AI-assisted code

Most of the issues in AI-assisted code are familiar classes of vulnerability, arriving faster and in greater volume. A few patterns deserve special attention:

  • Missing server-side authorisation. Generated endpoints often check that a user is logged in but not that they own the record they are requesting. This is the classic Insecure Direct Object Reference, and in financial and health systems it means one customer seeing another customer's data.
  • Injection through convenience. Concatenating user input into queries, shell commands or file paths is the shortest way to make something work, so it appears often in generated snippets.
  • Outdated or invented dependencies. Assistants suggest libraries from their training data, which may be years out of date. They can also suggest package names that do not exist, which attackers can register and fill with malicious code. Every new dependency should be verified before it is installed.
  • Secrets in the wrong place. API keys pasted into configuration files, mobile apps or JavaScript bundles to "get it working" tend to stay there and end up in version control history.
  • Weak cryptography and randomness. MD5 or SHA-1 for passwords, ECB mode for encryption and Math.random() for security tokens still appear in suggestions.
  • Business logic that trusts the client. A checkout that accepts the price sent by the browser, or a loan workflow where an approval step can be skipped, will not be caught by a scanner. It takes a reviewer who understands what the application is supposed to do.

When your application talks to an LLM

A second shift is happening at the same time: applications are integrating large language models directly, as chatbots, document summarisers, customer service agents and internal copilots. This creates an attack surface that traditional secure coding guidance does not fully cover. The OWASP Top 10 for LLM Applications is the most widely used reference. Its 2025 edition covers risks including:

  • Prompt injection: instructions hidden in user input, documents or web pages that override the developer's intent.
  • Sensitive information disclosure: models revealing personal data, internal documents or configuration they should not.
  • Improper output handling: treating model output as trusted and passing it to a browser, database or shell without validation.
  • Excessive agency: giving an AI agent more tools, permissions or autonomy than the task requires.
  • Unbounded consumption: no limits on usage, which turns into runaway costs or denial of service.

In code review terms, this means checking how prompts are constructed, whether retrieved content is kept separate from instructions, whether model output is encoded before it is rendered, which functions an agent can call and with whose privileges, and how AI service keys are stored. A leaked model API key is a direct financial liability, because whoever holds it can run up usage on your account.

What regulators and partners expect

Independent code review is not only good practice. For organisations that handle card data, PCI DSS v4.0.1 Requirement 6.2.3 requires bespoke and custom software to be reviewed before it is released into production or to customers, to identify and correct potential coding vulnerabilities. Where manual review is used, Requirement 6.2.3.1 expects it to be performed by someone other than the original author who is knowledgeable in code review and secure coding, with the changes approved by management before release. Code written with an AI assistant is still custom software, and the requirement applies in full.

Kenya's Data Protection Act 2019 requires data controllers and processors to implement appropriate technical and organisational measures to protect personal data. Banks, telcos, payment providers and enterprise buyers increasingly ask suppliers for evidence of independent security review before they integrate or procure. A review report is often the fastest way to answer that question.

How to keep the speed and lose the risk

Banning AI assistants rarely works, and it throws away real productivity. A better approach is to treat AI output the way you would treat code from a new contractor: useful, fast and always reviewed.

  1. Set a policy. Decide which assistants are approved, what code and data may be shared with them, and how AI-generated code is flagged in pull requests.
  2. Automate the basics. Run static analysis, secret scanning and dependency checks in your pipeline so obvious issues are caught as code is written.
  3. Review what automation misses. Authentication, authorisation, cryptography, payment flows and LLM integrations need a human reviewer who reads the code with an attacker's mindset.
  4. Gate releases. Make a security review part of the definition of done before major releases, new payment flows or new authentication systems go live.
  5. Verify vendor code. If a third party builds your mobile app, USSD service or core banking customisation, ask for the code or an independent review before it reaches your customers.
  6. Train developers. Secure coding habits make every suggestion easier to judge. Developers who know the OWASP Top 10 spot a bad suggestion before they accept it.

Where Cyber Guard Africa fits

Our Source Code Review service combines automated analysis with manual review by experienced security engineers across twelve areas, from authentication and access control to business logic, supply chain and frontend security. Where applications integrate LLMs, we review prompt injection exposure, output handling and the protection of AI service keys, using the OWASP Top 10 for LLM Applications as guidance. Findings point to the exact file and line, with a clear explanation and a fix your developers can apply.

For teams that want to build the skills in-house, our Cybersecurity Technical Training Program covers web, mobile and API security with hands-on labs. If you run a financial platform, our banking and fintech page explains how code review fits alongside penetration testing and monitoring.

AI can write the code. Someone still has to ask whether an attacker could abuse the way it was written.
  • Source code review
  • AI-generated code
  • OWASP
  • PCI DSS
  • Secure SDLC
Share
All insights