AI coding assistants are everywhere. Cursor, Copilot, Lovable, and Bolt are transforming how we write code. Developers who could not build a full-stack app three years ago are shipping products in days.
But there is a cost. A hidden one.
AI learned from public repositories. And public repositories are full of security mistakes. The AI does not know that an API key should be in an environment variable. It does not know that CORS should not be set to *. It does not know that a dependency should be pinned.
It writes what you ask for. It does not write what you need for security.
Here is what we found scanning AI-generated code with 9 security engines.
The 5 Patterns We Found in Every AI-Generated Project
1. Hardcoded Secrets
API keys, tokens, and passwords in source files. Every AI generated project we scanned had at least one.
Why it happens: The AI does not know that keys should be stored in environment variables. It provides a working example, and the developer commits it.
The fix: Never commit API keys. Use environment variables. Every platform (Vercel, Render, DigitalOcean, AWS) provides secure environment variable storage.
How to catch it: Gitleaks and TruffleHog scan for secret patterns. Debuggix includes both engines and filters false positives by reading your documentation.
2. Exposed Firebase Configurations
Firebase config objects containing apiKey, authDomain, and databaseURL committed directly to source files.
Why it happens: Firebase is popular because it provides a complete backend without additional code. The AI generates the config, and the developer has a working database.
The fix: Review Firebase security rules before deploying. Ensure reads and writes require authentication unless you specifically intend public access.
How to catch it: ESLint with security plugins flags Firebase config objects. The AI filter checks whether your documentation indicates intentional public access.
3. Missing Input Validation
Forms that accept anything. Email fields that accept non-email strings. Number fields that accept letters. No validation unless you explicitly ask.
Why it happens: The AI does not add validation unless explicitly asked. It builds a working form. Validation is a separate concern.
The fix: Add validation to every form. Use both client-side and server-side validation. Never rely on client-side validation alone.
How to catch it: Semgrep rules flag input handlers that lack validation logic. The AI filter understands context and ignores validation that appears in client-side code if server-side validation is present.
4. Wildcard CORS
Access-Control-Allow-Origin: * in production APIs.
Why it happens: The AI sets CORS to * because it works for local testing. The developer deploys without changing it.
The fix: Set CORS to specific domains your frontend uses. Never use * in production.
How to catch it: ESLint and Semgrep flag CORS headers set to *. The AI filter checks whether the project is explicitly documented as a public API.
5. Unpinned Dependency Versions
Version ranges like ^1.2.3 or >=2.0.0 in package.json and requirements.txt.
Why it happens: The AI generates version ranges because they are common in public repositories. The developer does not change them.
The fix: Pin dependency versions. Use exact version numbers. Commit your lock files.
How to catch it: OSV-Scanner and Trivy check for unpinned dependencies. The AI filter prioritizes findings in production dependencies over development dependencies.
The Common Thread
The AI is not malicious. It is not careless. It is a pattern matcher trained on millions of public repositories. The problem is that most public repositories contain these security gaps. The AI learned from them. Now it reproduces them. The solution is not to stop using AI coding tools. The solution is to add automated security review to the workflow.
The workflow should be:
- AI writes the code
- A scanner checks the code
- You review only what matters
What We Built to Solve This
I built Debuggix to catch these issues before they reach production.
How it works:
- Runs 9 security engines in parallel (Semgrep, Gitleaks, Trivy, TruffleHog, Bandit, ESLint, Hadolint, Checkov, OSV-Scanner)
- Uses AI to read your README and SECURITY.md to understand what is intentional
- Filters out false positives from test files, build artifacts, and documented patterns
- Surfaces only real issues — a scan that produces 134 raw findings might surface only 6 real issues
Pricing: Free for 10 public scans per month. Pro is $29/month for 100 private scans. Pro+ is $50/month with team seats and API access.
Try it: Debuggix
The Bottom Line
AI is a tool, not a security expert. It writes code. You are responsible for securing it.
Scan before you ship. Your future self will thank you.
Disclosure: I build Debuggix, a security scanner that runs 9 engines in parallel and uses AI to filter false positives. It is free for open source. Scan your repo at debuggix.space.
Discussion Question
What is the worst security issue you have found in AI-generated code? Let me know in the comments.
답글 남기기