{"slug": "ai-code-fails-security-checks-44-of-the-time-fix-it", "title": "AI Code Fails Security Checks 44% of the Time — Fix It", "summary": "Veracode's 2026 GenAI Code Security Report, released July 28, found that AI-generated code passes security checks only 56% of the time across more than 100 models tested over two years, up just one percentage point from 55% in the previous report. The report, which tested SQL injection, cross-site scripting, log injection, and insecure cryptographic algorithms, found pass rates of 83% for SQL injection, 87% for insecure crypto, but only 15% for cross-site scripting and 12% for log injection. With GitHub reporting that 51% of commits are now AI-assisted, Veracode estimates that roughly one in five commits carries a security flaw at baseline.", "body_md": "GitHub confirmed it in April: AI-assisted code crossed [51% of all commits](https://gloss.run/post/half-of-all-code-on-github-is-now-ai-generated) on the platform. The majority of committed code is now written, or at least drafted, by a machine. Veracode has been tracking what that means for security since 2024, and their [2026 GenAI Code Security Report](https://www.veracode.com/resources/analyst-reports/2026-genai-code-security-report/) released July 28 puts a number on the problem: 56%. That is the average security pass rate across more than 100 AI models tested over two years. It has barely moved since the first report — up one percentage point from 55%.\n\nThe models are not the same models. GPT-4 is long gone. The current crop includes GPT-5.5, Claude Opus 5, Gemini 3.7, and a dozen others that consistently beat the previous generation on every benchmark that matters for functional code quality. None of that translated into meaningfully better security. Developers who have been waiting for a smarter model to solve this problem should stop waiting.\n\n## The failures are not random\n\nVeracode tested four vulnerability categories: SQL injection, cross-site scripting, log injection, and insecure cryptographic algorithms. The results reveal a pattern that is more useful than the 56% headline number.\n\n| Vulnerability Category | CWE | AI Security Pass Rate |\n|---|---|---|\n| Insecure Crypto (algorithms) | CWE-327 | 87% |\n| SQL Injection | CWE-89 | 83% |\n| Cross-Site Scripting | CWE-80 | 15% |\n| Log Injection | CWE-117 | 12% |\n\nModels handle SQL injection at an 83% pass rate and cryptographic algorithms at 87%. These are pattern-recognition wins — parameterized queries and standard crypto library calls are common enough in training data that models reproduce them reliably. Cross-site scripting comes in at 15%. Log injection at 12%. Those are not slightly worse; they are a different class of failure entirely.\n\nThe explanation is architectural. SQL injection and bad crypto are detectable at the point where the vulnerable line is written. XSS and log injection require tracking where user input enters the system and how it moves through multiple functions before it reaches an output surface. That kind of dataflow reasoning is exactly where current language models fall apart. They read code more like a lookup table than a runtime.\n\nJava compounds this. Veracode’s mean security pass rate for Java-generated code is 30%. If your team is using AI to generate Java backend code, you are running a 70% miss rate on security tasks — before the vulnerability makes it past code review.\n\n## Why better models will not fix this\n\nThe best model in the Summer 2026 dataset is GPT-5.5 at a 68% pass rate. Qwen3.7-max brings up the rear at 50%. Six of the eleven models tested cluster between 50% and 53%. The spread across all models is 18 percentage points.\n\nThe core problem is not model intelligence — it is training incentives. Models are rewarded for producing code that runs and satisfies the functional description in a prompt. Security is not part of that reward signal unless a developer explicitly makes it so. Bigger models, trained on more data with better reasoning capabilities, still optimize for the same target. The benchmark suites that track model progress — HumanEval, SWE-bench, LiveCodeBench — measure task completion, not CWE coverage.\n\nGPT-5.5 is roughly seven times more capable than GPT-3.5 on coding benchmarks. Its security pass rate is 12 percentage points higher. That is not a trend line headed toward safety.\n\n## The scale math is uncomfortable\n\nIf 51% of commits are AI-generated and 44% of AI code generation tasks introduce a known vulnerability under default prompting conditions, roughly one in five commits now carries a security flaw at baseline. Veracode’s [State of Software Security report](https://www.businesswire.com/news/home/20260224526703/en/Veracode-2026-State-of-Software-Security-Report-Reveals-Four-Out-of-Five-Organizations-Are-Drowning-in-Security-Debt) puts the human-written baseline at around 12% vulnerability rate. The AI-assisted pipeline has not made that better.\n\n## Three things to change now\n\nVeracode’s core recommendation is blunt: treat AI-generated code as untrusted until it has been through security testing. That is the right framing, but it needs operational specificity.\n\n**Prompt for security explicitly.** The 56% is measured without security-specific prompting. Adding explicit constraints — “write a Python function that queries the database using parameterized queries to prevent SQL injection” rather than “write a Python function that queries the database” — improves pass rates meaningfully. This is one of the few levers you have at the prompt layer.\n\n**Apply SAST to AI output, not a sample of it.** AI-generated code needs the same static analysis coverage as any other code entering your codebase. XSS and log injection are the failure modes most likely to slip through — they are also the ones most reliably caught by a properly configured SAST tool.\n\n**Flag Java and output-handling code for manual review.** Not all AI-generated code carries equal risk. Java code and any code handling user-controlled input to an output surface — templates, logs, database queries — should get explicit review. That is where the data shows the failures cluster.\n\nThe model selection question is largely a distraction. The [gap between the best and worst models](https://www.veracode.com/blog/spring-2026-genai-code-security/) in Veracode’s dataset is 18 percentage points on security, against a ceiling of 68%. Switching from the worst model to the best model will not get you to safe. It will get you from one coin-flip to a slightly better coin-flip. The fix is in the workflow, not the model picker.", "url": "https://wpnews.pro/news/ai-code-fails-security-checks-44-of-the-time-fix-it", "canonical_source": "https://byteiota.com/ai-code-fails-security-checks-44-of-the-time-fix-it/", "published_at": "2026-08-21 01:18:20+00:00", "updated_at": "2026-08-21 01:42:33.155271+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-safety", "ai-research"], "entities": ["Veracode", "GitHub", "GPT-5.5", "Claude Opus 5", "Gemini 3.7", "Qwen3.7-max"], "alternates": {"html": "https://wpnews.pro/news/ai-code-fails-security-checks-44-of-the-time-fix-it", "markdown": "https://wpnews.pro/news/ai-code-fails-security-checks-44-of-the-time-fix-it.md", "text": "https://wpnews.pro/news/ai-code-fails-security-checks-44-of-the-time-fix-it.txt", "jsonld": "https://wpnews.pro/news/ai-code-fails-security-checks-44-of-the-time-fix-it.jsonld"}}