Is AI-Generated Code Safe? How To Review Code You Did Not Write
Is AI-generated code safe to ship? Not by default. Learn the common vulnerabilities and a simple review routine for code you did not write.

IN THIS POST
AI-generated code is only as safe as the checks around it. Here is what goes wrong most often and a review routine you can run in an hour.
Who checked the code your AI wrote? For many builders the honest answer is nobody. The code ran, the feature worked and the next prompt was already waiting. That is understandable, and it is also how most avoidable security problems get shipped.
So, is AI-generated code safe? Not by default. It is as safe as the checks you put around it. Here is what tends to go wrong, a review routine that works even if you cannot read every line, and how to tell when you need a person.
What The Data Says About AI-Generated Code
The clearest evidence comes from Veracode's 2025 GenAI Code Security Report. It tested more than 100 large language models on 80 coding tasks and found they produced vulnerable code in 45 percent of the cases. When a task offered a secure way and an insecure way to do the same thing, the models chose the insecure one 45 percent of the time. Bigger models did not do noticeably better, and security results had stayed flat over time even as the code became more correct.
Two points are worth taking from that. First, the problem is not one bad tool. It is how these models behave across the board, so switching assistants is not a safety plan. Second, working code and safe code are different things. A feature can pass every click test and still leave a door open.
Six Vulnerabilities That Keep Showing Up
AI-generated code vulnerabilities tend to be ordinary mistakes repeated at speed. Look for these first.
- Secrets in the wrong place. Keys pasted into front-end files or committed to the repository.
- Missing or weak access checks. A route that returns data without asking who is calling, or a check that only hides a button. This is what broken access control looks like in practice.
- Unvalidated input. Form fields and URL parameters passed straight into queries or pages, which invites SQL injection and cross-site scripting. Veracode found the models failed to defend against cross-site scripting in 86 percent of the relevant tests.
- Open databases. Tables with no rules, especially on Supabase.
- Risky dependencies. Outdated packages and names the model invented, a pattern known as hallucinated packages. Our write-up of the September 2025 npm attacks shows the stakes.
- Prompt injection in AI features. If your app passes user text to a model, that text can try to take over the instructions.
Review AI Code In Six Steps
You do not need to read every line to do a useful review. Treat the code as untrusted until it has passed a short routine. This one fits into an hour.
- Look at what the code touches. List every place it handles logins, money, personal data, file uploads or outside services. Review those parts first.
- Search for secrets. Search the project for "key", "secret", "token" and "password". Anything real in browser-facing files needs to move, and the key needs replacing.
- Test the doors from outside. Open the app in a private window and call your API addresses while signed out. Then use a second account to try to reach the first account's data.
- Ask the AI to review itself, with a specific brief. A vague "is this secure?" gets a vague yes. Ask it to list every endpoint and say what login check protects each one, or to find every place user input reaches a database query.
- Run an automated scan. Tools that read the code and tools that read the live site catch different problems. Connecting your repository with read-only GitHub access lets a scan read the code itself.
- Re-check after changes. Every large prompt can undo an earlier fix, so scan again before you push to production. The first scan guide covers the basics.
Know When To Bring In A Developer
Some code deserves a person's eyes no matter how clean the scan looks. Bring one in for anything that moves money, stores health or identity data, controls who is an administrator or serves a regulated business. A reviewer also helps when you hit a finding you do not understand, because a wrong fix can be worse than the original problem.
AI-generated code can absolutely be safe to ship. It just has to earn that status through checks you can repeat, not through the fact that it ran.
References
Does your app have any of these problems?
Paste your website for a free quick check. About a minute, and nothing on your site is changed.


