AI-Written Code Changes the Vulnerability Math

If your developers use coding assistants, your pull request queue has likely grown, and the number of people qualified to review it probably has not. The usual security response is to argue about whether AI-written code is worse, then add another scanner. I think both moves miss where the pressure is.
The obvious argument is the weak one
The obvious argument says AI code carries more vulnerabilities per line, so measure that and gate on it. The evidence is older than it looks. The 2021 Copilot study found about 40% of 1,689 generated programs vulnerable, but it used high-risk CWE scenarios and an early model. The Stanford user study used Codex-davinci-002. Both are history, not current rates, and no source I have read gives a controlled comparison of vulnerabilities per line between current models and human developers.
Density is also the wrong fight. Hold it constant, double the code, and you have doubled the bugs. Adding a scanner then adds findings to a remediation queue that is already behind. The number I care about is a ratio: what enters your pipeline, over what your people can check and fix.
The terms in the ratio
What has been measured, and what each number cannot carry.
| Term | What was reported | What it does not show |
|---|---|---|
| Code volume | GitHub Octoverse 2025: 518.7M merged pull requests (up 29%), more than 986M commits (up 25%) | That AI caused it. GitHub calls these signals observational |
| Review discussion | Same data: comments on issues and PRs up 0.35%, comments on commits down 27% | Less review. Comments are a weak proxy for effort |
| Invented dependencies | Spracklen et al.: at least 5.2% of packages for commercial models, 21.7% for open-source models | A breach. The name still has to be registered and installed |
| Human verification | Perry et al.: assisted participants wrote less secure code and were more likely to believe it was secure | Current models |
| Delivery stability | DORA 2024: estimated 7.2% fall in stability with rising AI adoption. DORA 2025 still finds a negative relationship with stability, but now a positive one with throughput, which DORA 2024 had estimated falling 1.5% | Security outcomes. These findings come from survey data |
| Patch capacity | Verizon DBIR 2026, via Help Net Security: 26% of CISA KEV vulnerabilities fully remediated (38% the year before), median time to full patch 43 days (was 32) | AI as the cause. Help Net Security notes the analysed data predates the rise in AI-assisted vulnerability research by threat actors |
Nothing here proves AI wrote your next CVE. It says something narrower: the input side is growing, and the checking side shows little sign of growing with it.
Dependencies changed shape
A hallucinated package is not a flaw in code. It is a name nobody owns yet. Spracklen and colleagues tested 16 models across 576,000 Python and JavaScript samples and counted 205,474 unique invented names. Repetition is what makes that useful to an attacker: publish a package under a name models keep repeating, and later users who trust the generated code download it.
That is a different failure from a vulnerable dependency, and a different problem to solve. A vulnerability scan asks whether a known package has a known flaw. Here the question is whether this package should be in your build at all.
The attack needs a registered name and a person or pipeline that installs it unchecked. The authors report that mitigations reduce hallucination, with RAG and fine-tuning particularly effective, though fine-tuning cost code quality and they still call the problem persistent and systemic. None of the sources behind this post documents a confirmed breach through a registered hallucinated name. The Cloud Security Alliance does report a malicious npm package under one such name, with downloads but no named victim. I treat this as a cheap hole to close, not a crisis.
Review is where the honest uncertainty sits
Stack Overflow's 2025 survey has 80% of developers using AI tools while trust in AI accuracy fell from 40% to 29%. That is a self-selected vendor survey, not a security source. It still fits the Stanford result: participants who trusted the AI less and engaged more with their prompts produced fewer vulnerabilities. Scepticism works as a control, and scepticism costs time.
DORA cuts the other way. In its 2024 report, a 25% rise in adoption was associated with 3.4% higher code quality and 3.1% faster code review. So I do not believe AI makes review worse by default. Its 2025 report reverses the throughput finding but keeps the stability one, and says AI's acceleration can expose weaknesses downstream. My reading: each change can look better and move faster while delivery gets less stable. DORA's own answer is the basics, small batch sizes and robust testing in 2024, strong automated testing and fast feedback loops in 2025, not abandoning the tools.
The queue it lands in
FIRST's February forecast picked 2026 as the year published CVEs cross 50,000, with a median near 59,000, and called 70,000 to 100,000 realistic. Its June 15 update reports cumulative drift of 46.3% above the original forecast, an excess of 6,420 CVEs, and revises the 2026 projection to about 66,000. That still sits inside February's 90% interval of 30,012 to 117,673, so read all of it as direction, not a measurement.
FIRST's update attributes part of the surge to AI-assisted bug finding and part to structural CNA expansion. That is a different mechanism from AI-written bugs. It also reports that the subset it treats as actionable, vulnerabilities in CISA KEV or with an EPSS score above 10%, stayed flat in the first half of 2026. It expects the work of patching live systems to stay steady through at least the end of 2026, while telling software maintainers to prepare to double theirs. So on FIRST's evidence the volume is growing and the part that demands urgent patching is not.
Verizon, as reported by Help Net Security, blames slower patching on a drastic increase in the number of vulnerabilities, including those in the KEV catalog. That reads differently from FIRST's flat line, though the windows differ: Help Net Security gives the DBIR's window as incidents from November 2024 to October 2025, and FIRST's overlay covers the first half of 2026. I am not claiming AI-written code produced any of these numbers. I am saying it lands on the same people. FIRST puts the constraint as "the human capacity to verify, coordinate, and patch", and that is the bottom half of my ratio.
What I would change
Stop trying to review everything harder. Point human attention at the few files where a mistake changes what runs, and let the build refuse what nobody approved.
Start with dependency names. Resolve every new one against an allowlist or internal proxy, and fail the build on a name that was not already in the lockfile and has not been approved. Pin and verify lockfiles in CI. This closes the hallucination path however common the attack turns out to be.
Then require a human reviewer on dependency manifests and CI workflows, regardless of who or what wrote the change. Those diffs are short, and one reviewer buys the most there.
Keep pull requests small, including the ones agents open. A reviewer cannot be sceptical of a diff they cannot read.
Finally, scan the built artifact and rank by KEV and EPSS rather than raw count. If only 26% of known exploited vulnerabilities get fully remediated, a longer list is not what you need, and FIRST's flat KEV and EPSS subset says the new volume is not where the urgent work is. That is the part Dwaar works on: discovering what you ship from source control, registries and cloud accounts, scanning it, and keeping one findings list with EPSS and KEV signals.
Where this stops applying
If your volume is flat and your dependency tree rarely changes, the ratio has not moved, and none of this is urgent. An allowlist has a real cost for teams that add packages often. The figures also age: the hallucination paper was last revised in March 2025, so your tools may do better or worse.
Try this on your own repositories
Take your last 90 days of merged pull requests and list every dependency name added to a manifest. For each, record when it was first published, whether anyone but the author reviewed the change, and whether your build would have refused an unapproved name. Count the names no second person looked at. That count tells you more about your exposure than your vulnerability total does.
References
- Spracklen et al., We Have a Package for You!, arXiv / USENIX Security 2025, June 12, 2024, revised March 2, 2025 (full text)
- Perry et al., Do Users Write More Insecure Code with AI Assistants?, arXiv / ACM CCS 2023, November 7, 2022
- Pearce et al., Asleep at the Keyboard?, arXiv / IEEE S&P 2022, August 20, 2021
- Octoverse 2025, GitHub Blog, October 28, 2025
- Announcing the 2024 DORA report, Google Cloud Blog, October 22, 2024
- Announcing the 2025 DORA Report: State of AI-Assisted Software Development, Google Cloud Blog, September 23, 2025
- 2025 Developer Survey results, Stack Overflow Blog, July 29, 2025 (re-published December 29, 2025)
- Vulnerability forecast 2026: The Year Ahead, FIRST, February 11, 2026 (date from the URL; the page is undated)
- The 2026 Vulnerability Forecast Update: Navigating the AI Epoch, FIRST, June 15, 2026 (the article says about 66K; the teaser on FIRST's blog index says about 68K)
- Verizon DBIR: Vulnerability exploitation is the dominant initial access vector, Help Net Security, May 20, 2026
- Slopsquatting: AI Code Hallucinations Fuel Supply Chain Attacks, Cloud Security Alliance, April 19, 2026
