A new report by software security company Veracode shows that while AI models have become very good at writing code that works, they still struggle to write secure code. According to the 2026 GenAI Code Security Report, AI failed basic security tests in nearly half of the cases.
Veracode tested more than 100 AI models in four rounds of testing. The average security pass rate was 56 percent, only slightly better than 55 percent last year. This means that even though AI usually writes code that compiles and runs correctly, it often contains security weaknesses.
The report says this issue is becoming more serious because AI is now responsible for writing about half of all new software code. As more developers rely on AI tools, the risk of insecure code entering software projects also increases.
The researchers also found that AI models built specifically for programming were not safer than general-purpose AI models.
Coding-focused AI models achieved an average security score of 51 percent, while general AI models scored 52 percent. The size of the AI model also made very little difference. Large models averaged 53 percent, while both medium and small models scored around 51 percent.
However, AI models that use reasoning performed slightly better. These models achieved an average score of 56 percent, compared to 51 percent for models without reasoning capabilities. Veracode believes the extra reasoning helps the AI check its own work before generating the final code.
Among all the tested models, OpenAI’s GPT-5.5 achieved the highest score with a 68 percent security pass rate. Even so, it still failed nearly one out of every three security tests.
Most of the remaining models scored between 50 and 53 percent. Alibaba’s Qwen3.7-max ranked last with a score of 50 percent.
The report also showed that AI performs differently depending on the programming language.
Python had the best security results with a 63 percent pass rate, while Java performed the worst with only 30 percent. Although Java had the lowest score, it was also the only language that showed clear improvement compared to last year.
AI also handled some security problems better than others. It performed reasonably well at preventing SQL injection and insecure cryptography issues. However, it struggled with cross-site scripting (XSS) and log injection, which are common security vulnerabilities in web applications.
Veracode explained that these results do not mean half of all AI-generated software is unsafe. The company tested the AI models without any extra security prompts, human review, or security tools.
In real software development, companies usually review code, run security scans, and fix problems before releasing their applications. These extra steps help reduce the risks.
The company recommends that developers treat AI-generated code just like code written by a new programmer. It should always be checked, tested, and scanned for security problems before it is used in real products.
Chris Wysopal, Veracode’s co-founder and Chief Security Evangelist, said the solution is not to stop using AI for coding. Instead, developers should build stronger security checks around AI-generated code.
The report concludes that although AI has become excellent at writing working code, it still cannot be fully trusted to write secure software on its own. Human review and automated security testing remain essential before AI-generated code is deployed.



