Source: https://arara.code.app.br/en/articles/ai-generated-code-security
Language: en-US
Published: 2026-10-31T20:25:00-03:00

Guides and comparisons

# AI-generated code security: data and a checklist

Do not assume AI-generated code is secure. In Veracode's 2025 report, 45% of the code samples failed security tests and introduced OWASP Top 10 flaws. The risks include injection, exposed secrets and packages the AI invents. To protect yourself, validate input, use parameterized queries, keep secrets out of code, check dependencies, review every diff and run tests.

Arara Code

Published and sources checked on October 31, 2026.

Published by the Arara Code project based on the official documentation cited.

## What the data shows about AI-generated code

Veracode's 2025 GenAI Code Security Report tested more than 100 large language models in Java, Python, C# and JavaScript. In 45% of the samples, the generated code failed security tests and introduced OWASP Top 10 vulnerabilities. Java was the riskiest language, with a 72% security failure rate. One of the most frequent issues was cross-site scripting: the AI tools failed to defend against it in 86% of the relevant samples.

Veracode kept the same test, with 80 coding tasks. By its Spring 2026 update, published in March 2026, it had evaluated more than 150 models. Syntax correctness exceeded 95%, but the security pass rate stayed at about 55%, virtually the same as two years earlier. The pass rate was 82% against SQL injection, but only 15% against cross-site scripting and 13% against log injection, flaws that require following data through the code.

[Veracode: 2025 GenAI Code Security Report](https://www.veracode.com/blog/genai-code-security-report)

## Leaked secrets and packages the AI makes up

Secrets such as passwords and API keys are another risk. According to GitGuardian's State of Secrets Sprawl 2025 report, 23,770,171 new hardcoded secrets were added to public GitHub repositories in 2024, a 25% increase over the previous year. Of the secrets leaked in 2022, 70% were still valid. Public repositories that use GitHub Copilot had a 6.4% secret leakage rate, 40% higher than the average across all public repositories. For GitGuardian, this suggests AI may also introduce security risks.

Dependencies bring a newer risk. The study “We Have a Package for You!”, accepted for the 2025 USENIX Security Symposium, generated 576,000 code samples in Python and JavaScript with 16 models. On average, at least 5.2% of the packages suggested by commercial models and 21.7% of those from open-source models did not exist. This opens the door to slopsquatting: an attacker publishes a malicious package under a name the AI tends to invent and waits for someone to install it.

[GitGuardian: State of Secrets Sprawl 2025](https://www.gitguardian.com/state-of-secrets-sprawl-report-2025)

Related

[Vibe coding: what it is, the risks and how to start safelyLearn what vibe coding is, what 2025 data shows about trust and security, and how to start safely with a branch, tests and diff review.](https://arara.code.app.br/en/articles/vibe-coding)

## A security checklist based on the OWASP Top 10

The OWASP Top 10:2025 lists the most critical security risks to web applications, and it works as a map for reviewing what the AI writes. Validate all input on the server and keep data separate from commands, with parameterized queries (A05:2025 Injection). Enforce access control in server-side code and deny by default anything that is not public (A01:2025 Broken Access Control). Keep passwords and keys out of code, where they become hard-coded credentials (A07:2025 Authentication Failures), and never paste them into prompts.

Before you install a package the AI suggests, check its exact name, its publisher and its repository. Use only official sources and choose each version deliberately (A03:2025 Software Supply Chain Failures). Since an attacker may have already published the invented package, seeing that it exists is not enough. Then read every diff before you commit and run the tests, including access-denied cases. OWASP points to code review combined with automated testing to find injection flaws.

[OWASP Top 10:2025: web application risks](https://top10.owasp.org/2025/)

## How to apply the checklist in Arara Code

Veracode concludes that workflows should not assume AI-generated code is secure and that responsibility for security stays with people. In Arara Code, the side chat asks your permission before it edits files or runs commands, and you approve or refuse each one. Refuse an install command until you have checked the package. Changed files appear in a card with their diffs: read each one before you commit.

Create a branch for each task, so you can discard what goes wrong without touching the rest. When you finish, ask the assistant to run the security-audit skill, which the IDE installs by default, on the changes in your branch. Read the findings and ask for small fixes, one at a time. Never paste passwords, tokens or API keys into the chat: keep them in environment variables or a secrets manager. Finally, run the tests before you commit.

[Veracode: Spring 2026 GenAI Code Security Update](https://www.veracode.com/blog/spring-2026-genai-code-security)

## Sources and further reading

- [Veracode: 2025 GenAI Code Security Report](https://www.veracode.com/blog/genai-code-security-report)
- [GitGuardian: State of Secrets Sprawl 2025](https://www.gitguardian.com/state-of-secrets-sprawl-report-2025)
- [arXiv: study of package hallucinations by LLMs](https://arxiv.org/abs/2406.10279)
- [OWASP Top 10:2025: web application risks](https://top10.owasp.org/2025/)
- [Veracode: Spring 2026 GenAI Code Security Update](https://www.veracode.com/blog/spring-2026-genai-code-security)

[Read as Markdown](https://arara.code.app.br/en/articles/ai-generated-code-security.md)

## Keep exploring

### [Coding with AI for beginners: a step-by-step guide](https://arara.code.app.br/en/articles/coding-with-ai-for-beginners)

Coding with AI for beginners: what 2025 data says to expect, a first project, basic Git, a safe routine and your first steps in Arara Code.

[Read the guide](https://arara.code.app.br/en/articles/coding-with-ai-for-beginners)

### [Prompts for coding with AI: rules and examples](https://arara.code.app.br/en/articles/prompts-for-coding-with-ai)

How to write prompts for coding with AI: goal, files and checks, a plan before code, AGENTS.md and CLAUDE.md, with examples from the official guides.

[Read the guide](https://arara.code.app.br/en/articles/prompts-for-coding-with-ai)

## Make room for your next idea.

Get to know Arara Code in your own project. Start with the installer and review the changes your assistant makes.

Download Arara Code
