Calidad Infotech
    Insights

    AI Code Review Security: Catches & Misses

    AI code reviewers spot injection and hard-coded secrets but miss authorization logic and fake packages. Here's how to layer them with deterministic scanners and senior review.

    · 8 min read · Calidad Infotech

    AI code review tools are good at spotting known vulnerability patterns in a diff: injection, hard-coded secrets, unsafe functions and missing input validation. They are weak at authorization logic, business rules and checking whether a new dependency is real. Treat them as one layer beside SAST, dependency scanning and secrets detection, with a senior engineer gating risky changes.

    This post covers security review only. For the wider process of tests, review and release sign-off, see our guide on how to verify AI-generated code before production.

    What does an AI security code review actually check?#

    An AI security review reads a pull request, flags code that matches a known weakness and explains the risk in plain language.

    Most AI reviewers look for:

    • Untrusted input reaching a database query, shell command, file path or HTML output without validation or encoding
    • Credentials, tokens and keys written into code or config
    • Risky APIs: weak hashing, disabled TLS verification, unsafe deserialization
    • Error handling that leaks stack traces or internal data
    • Obvious authorization gaps, such as a new endpoint with no auth check at all

    Their value is the explanation: the comment says why something is risky and suggests a fix in the same thread. Their limit is scope. They usually work from the diff and nearby files, not from your threat model, your tenancy rules or how the service is deployed.

    Which security issues do AI-written changes introduce most often?#

    The research points to four recurring problems: insecure coding choices, invented dependencies, leaked secrets and weak access control.

    • Insecure choices. Veracode's 2025 GenAI Code Security Report tested more than 100 LLMs on 80 coding tasks in Java, JavaScript, Python and C#. The generated code introduced a security flaw in 45% of cases. Veracode also reported that models got better at writing code that compiles without getting more secure, and that AI missed 86% of cross-site scripting threats.
    • Packages that don't exist. A USENIX Security 2025 study of 576,000 code samples found that at least 5.2% of packages suggested by commercial models, and 21.7% from open-source models, were hallucinated. An attacker can register a hallucinated name, so a routine install command becomes a supply-chain attack.
    • Secrets in code. GitGuardian's State of Secrets Sprawl 2025 found that 6.4% of public repositories using GitHub Copilot leaked at least one secret, against 4.6% across all public repositories.
    • Access control and configuration. Broken access control is still #1 in the OWASP Top 10:2025, with security misconfiguration at #2 and software supply chain failures at #3. A model writing an endpoint doesn't know which tenant may read which record unless someone tells it.
    Share of public repositories leaking at least one secret, GitGuardian 2025
    Share of public repositories leaking at least one secret, GitGuardian 2025

    What do AI code review tools catch, and what do they miss?#

    They catch patterns visible in the changed lines. They miss problems that depend on intent, on other systems or on facts that live outside the code.

    Usually caught

    • SQL, command and path injection in the changed code
    • Hard-coded credentials and obvious secrets
    • Known-dangerous functions and insecure crypto settings
    • Missing validation on new inputs

    Often missed

    • Authorization logic. User A reads user B's invoice through a valid, authenticated call. Nothing in the diff looks wrong.
    • Business-rule abuse. Refunds above the order value, negative quantities, a workflow step that can be skipped.
    • Cross-service trust. A change that is safe on its own but trusts a header another service no longer sets.
    • Dependency facts. Whether a package exists, who maintains it and whether its version has a known CVE. Answering that takes a registry and database lookup, not a read of the code.
    • Infrastructure blast radius. An IAM policy with a wildcard that looks tidy in YAML.
    • Their own errors. An AI reviewer can be confidently wrong. If a similar model wrote the code, the two may share blind spots. A clean AI review does not prove a flaw is absent.

    How do AI review, SAST, dependency scanning and secrets detection fit together?#

    Each layer covers a different failure, so you need all of them: AI review explains, SAST enforces rules, dependency scanning checks what you import and secrets detection checks what you leak.

    Layer Best at Weak at Blocks merge?
    AI code review Explaining risk in context, suggesting fixes Consistent results; proving absence No, advisory unless a human confirms
    SAST Repeatable, rule-based detection of known weakness classes Business logic; noise on unusual code Yes, on high and critical findings in new code
    Dependency scanning Known CVEs, licences, unknown or brand-new packages Flaws in your own code Yes, on critical CVEs and unverified packages
    Secrets detection Keys, tokens, connection strings Generic credentials with no recognisable format Yes, always
    Senior engineer review Intent, authorization, design Scale; large diffs Yes, on sensitive paths

    The generic-credential gap is real: GitGuardian found that 58% of the leaks it detected in 2024 were generic credentials rather than keys with a known pattern.

    That leads to one design rule. AI review is the only non-deterministic layer, so it should never be the only thing between a change and production. Deterministic tools give the same result on the same code, and that repeatability is what makes their output usable as evidence.

    Where should each security gate sit in the CI/CD pipeline?#

    Put each check at the earliest point where it is fast and reliable: secrets before commit, code and dependency checks on the pull request, artifact checks at build and runtime checks in staging.

    1. Pre-commit. Scan for secrets on the developer's machine. Once a secret is pushed, rotating it is the only fix, and GitGuardian found that 70% of secrets leaked in 2022 were still valid.
    2. Pull request. Run AI review, SAST on changed files, a dependency scan on lockfile changes and a check that every new package exists and has a real history. Block on secrets, critical CVEs and high-severity findings.
    3. Merge. Require approvals, with code owners on sensitive paths.
    4. Build. Run the full SAST and dependency scans on the built artifact, generate an SBOM and sign the artifact.
    5. Staging. Run dynamic testing against the running service before promotion.
    6. Production. Re-check the SBOM when new CVEs are published.
    How a change passes through security gates from commit to staging
    How a change passes through security gates from commit to staging

    The gates around these, such as small changes, fast tests and safe rollbacks, are covered in our continuous delivery pipeline practices.

    When must a senior engineer review the change anyway?#

    A senior engineer must review any change that can widen who can do what, what the system trusts or what reaches production, no matter how clean the automated results look.

    Route changes by risk instead of reviewing everything at the same depth. Three levels work for most teams:

    • Senior security review for authentication, authorization, sessions and tenancy; payments, personal data, encryption and key management; IAM, network rules and infrastructure as code; CI/CD config and the security tools themselves; and permissions for AI agents that act on production.
    • Package verification, then peer review for a new direct dependency: confirm the package exists, check its maintainers and age, and pin the version.
    • Peer review with AI comments for everything else.

    Two cases always go to a senior engineer: any dismissed or downgraded security finding, and any AI-generated diff too large to read carefully. Split that diff first.

    Routing a change to the right depth of security review
    Routing a change to the right depth of security review

    This is how we work at Calidad: every release passes three gates (tested, secured and reviewed by a senior engineer), whether a person or an AI wrote the change. Our Quality Engineering work builds those review gates, and the release evidence behind them, into client pipelines.

    What security evidence should every release keep?#

    Keep enough to show, months later, what was checked, by which tool, what was found, what happened to each finding and who approved the release.

    NIST's Secure Software Development Framework (SP 800-218) asks producers to review or analyse code for vulnerabilities (practice PW.7). It also asks them to archive and protect each release, including provenance data such as an SBOM (practice PS.3). A practical per-release record:

    • Commit SHA, build ID and the signed artifact's hash
    • Results from each scanner, with tool version and ruleset
    • Every finding and its outcome: fixed, false positive with a reason, or accepted risk with an owner and expiry date
    • The SBOM for the artifact that shipped
    • Approvals, including the named senior reviewer on sensitive paths
    • Which changes were AI-assisted, if your team tags them

    Finding outcomes matter most. A report saying "0 critical" that leaves out the dismissed findings and their reasons tells an auditor very little.

    Lifecycle of one security finding from detection to the release record
    Lifecycle of one security finding from detection to the release record

    Conclusion#

    AI code review is worth running on every pull request. It catches common flaws early and explains them well. It cannot prove a change is safe, and AI-written code needs that proof: the research shows insecure choices, invented packages and leaked secrets at measurable rates. Run AI review alongside deterministic scanners at the right pipeline stages, send sensitive changes to a senior engineer and keep a record of what happened to every finding.

    If you aren't sure where your pipeline's gaps are, our Security & DevSecOps team finds them, ranks them by risk and builds the checks into your pipeline, starting with a paid pilot.

    Talk to an engineering lead →

    Frequently asked questions

    Can an AI code reviewer replace SAST?

    No. An AI reviewer can give different answers on the same code, and it can't show that a type of flaw is absent. SAST applies the same rules every time, so its results hold up as release evidence. Use the AI reviewer to explain findings and suggest fixes, and let SAST and the other scanners decide whether a merge is blocked.

    How do we protect against hallucinated or malicious packages from AI suggestions?

    On every pull request that adds a dependency, check that the package exists in the registry, how old it is and who maintains it. Pin versions in a lockfile and run dependency scanning on lockfile changes. Treat every new direct dependency as a change that needs a person to review it, not just an automated pass.

    Should we label AI-generated code in commits or pull requests?

    It helps if your tools support it. Tags let you send large AI-generated diffs to closer review, and you can record them in the release evidence. The security gates themselves should not change depending on who or what wrote the code. Every change still goes through the same tests, scans and review rules.

    Which changes should block a merge automatically?

    Most teams block on any detected secret, critical known CVEs in dependencies, high-severity SAST findings in new code and packages that can't be verified. Sensitive paths such as auth, payments, infrastructure and pipeline config should also need a named senior reviewer's approval before merge. AI review comments usually stay advisory unless a human confirms them.

    Can Calidad add these gates to our existing pipeline?

    Yes. Our Security & DevSecOps work finds the gaps, ranks them by risk and builds the checks into your pipeline. Our Quality Engineering work adds review gates and release evidence for AI-written code. Engagements start with a paid pilot, with success criteria agreed up front.

    • AI code review
    • DevSecOps
    • SAST
    • Software supply chain
    • Secrets detection
    • CI/CD security

    Newsletter

    Get new articles by email

    A short monthly round-up of what we've written on engineering pods, quality and AI. No spam.

    Keep reading

    Start with proof

    Skip the pitch.
    See it work.

    A paid pilot: one pod, one outcome, judged on working software — results in days. No long-term contracts.