Securing AI-Generated Code: Review Controls, Supply Chain Checks and Clear Ownership
AI coding tools are making software creation accessible to more people and increasing the amount of code professional teams produce. That shift changes the security workload: organizations need a way to check code at scale while keeping people accountable for decisions involving sensitive data, access and infrastructure.
The risk shows up in an account shared by an IT manager whose company had hired a recent graduate. The employee built an application that handled customer data and private contracts, hosted it under a domain he controlled, stored information on Supabase’s free plan, and deployed from a private GitHub repository to Cloudflare’s serverless infrastructure. When asked about security precautions, he pointed to the repository’s privacy. The CEO’s response to the IT manager’s concerns was: “Let it go.”
A private repository says little about whether an application is secure, who controls its hosting, or how its data is handled. The example also highlights a growing organizational challenge: software can now be built and put into use outside established engineering and security processes, including by employees whose primary roles aren’t software development.
Working code can still be unsafe
Evidence from the SusVibes benchmark illustrates the gap between functionality and security. Researchers evaluated AI agents against 186 feature requests drawn from open-source projects. Without security guidance, the agents produced working code in as many as 57% of cases, but just 11.8% of their solutions were secure.
Danqing Wang of Carnegie Mellon University’s Language Technologies Institute, who authored the paper describing SusVibes, said the failures weren’t simply careless mistakes. Identifying them requires reasoning about what an attacker could do, not just whether the requested feature works.
That distinction matters as tools such as Claude Code, Cursor, GitHub Copilot and Amazon Q Developer become routine in software work, while business users also build their own applications. AI systems can help identify flaws in existing code, but they can still introduce vulnerabilities when asked to write or modify it. Katie Paxton-Fear, staff security advocate at Semgrep, says developers can become less critical of generated code as its ability to produce working results improves.
The practical response is to treat generated code as untrusted until it passes the organization’s normal checks. Bianca Lankford, Datadog’s vice president of engineering, says it should have to “earn its way into the codebase.” That means placing security checks close to the work: in developers’ editors where practical, and on every pull request.
Make accountability visible in review
Automated checks can handle repeatable tasks such as static analysis, secrets detection, dependency review and scans for standard vulnerability patterns. But they don’t replace judgment about what a change exposes or how an attacker might use it. At Mimecast, CISO Leslie Nielson says every AI-assisted change that ships has a named human owner recorded in its pull request. “AI can propose. Only people can approve.”
That ownership should shape review requirements. Changes involving authentication, cryptography, payments, personal data or infrastructure warrant specialist attention, regardless of whether a person or an AI wrote the code. Code ownership rules can route those changes automatically. Reviewers can also look at signals such as the size of a change, added dependencies, permission changes and new network exposure.
Risk-based routing helps protect specialist time. Nielson recommends using automation for well-understood checks while sending changes involving access, authentication or sensitive data to a specialist even when scans report no problems. As he puts it, a reviewer buried in low-risk changes may be approving work without truly reviewing it.
Teams also need to retain the knowledge that makes code understandable after it has been generated. Security expert and tech activist Alex Ștefănescu argues that documentation, a solid test suite and written records of significant architecture decisions can save time during incidents and complex debugging. Generative systems may produce software, but they don’t provide an organization with shared understanding of its design.
Check dependencies, models and data flows
AI-generated code can introduce third-party libraries that aren’t declared in a project’s dependency manifest. These “phantom dependencies” may escape scans that rely on declared packages, leaving teams unaware of code included in their applications. Software composition analysis and supply chain security tools can help identify packages in use and surface vulnerabilities and potential compliance concerns.
Package suggestions present a related risk. A coding model may produce a plausible package name that doesn’t correspond to a legitimate, established library. Attackers can register names on package platforms such as npm or PyPI and add functionality designed to look convincing. If a developer imports one of those packages into an application, it can become a route for malicious code.
Organizations should also account for the models and datasets developers bring into their work. Platforms such as Hugging Face provide access to machine learning resources, but a model may contain a backdoor that activates after integration, potentially exposing company data. Controls can include automated scans for malicious code or backdoors, restricting use to verified publishers, and testing in isolated environments before adoption.
Rules for approved models and datasets should be clear to the people building with them. Where AI coding agents support instruction files, teams can include relevant requirements there. Security leaders also need to consider whether prompts and coding tools might expose sensitive information that employees enter while working.
Bring nontraditional developers into the process
Some of the new code is coming from data analysts, marketing teams and researchers rather than software engineering groups. Darren Meyer, staff research engineer at Endor Labs, says these teams increasingly build small tools that use AI libraries and models, often without much application security experience. Pairing that limited experience with development outside established oversight can create avoidable risks.
Security teams can reduce that gap by engaging these groups early and providing training suited to their work. The aim is to make it clear which tools are approved, what data employees may share, and when code needs a specialist review. Guidance has to be usable at the point of work; otherwise, teams under pressure to deliver may find an unapproved route.
For organizations with little time or budget, a short policy written in plain language can establish those basics. It should name permitted AI tools, set boundaries on the code and data employees can provide, identify changes requiring specialist review, and give staff a clear contact for questions. Banning AI tools outright can push their use out of sight, reducing security teams’ visibility into both generated code and shared data.
Put controls where code is created
Security work can be distributed across the development process: during design, in agent instruction files such as CLAUDE.md, while the agent is generating code, during pull request review, and in AI-assisted penetration testing. The particular checks will vary, but each stage offers a chance to address a different part of the risk.
One limitation is that coding agents don’t reliably infer the threat model, trust boundaries or which inputs an attacker controls. Wang says agents optimize for the signal they’re given: satisfying the described function. Teams therefore need to provide security context and review the assumptions behind a change, rather than relying on a feature description to capture them.
Security leaders also need enough people and tools to keep pace as software output grows. Endor Labs’ Meyer says security budgets often don’t rise as quickly as development activity. Tools can help close that gap, but application and product security staff still need to work with both traditional developers and newer teams building software.
That balance depends on trust as much as enforcement. Employees need to feel safe reporting which tools they used and what information they shared when something goes wrong. If they expect punishment, disclosure may come late and leave responders without the facts needed to contain the issue. Nielson recommends offering amnesty so staff will speak openly about unapproved tools.
AI can increase development capacity, but it doesn’t take responsibility for what reaches production. Organizations that make ownership explicit, focus expert review on high-impact changes, and give every team a workable path to approved tools are better placed to gain speed without losing sight of what their software can expose.