Vibe coding security risks: six flaws that ship when nobody reads the code

The security risks of vibe coding are the familiar ones: injection, hardcoded secrets, weak cryptography, vulnerable or invented dependencies, missing authorization checks and insecure defaults. The difference is that nobody reads the code before it runs, so nothing stops them. Each one below comes with an example and the check that catches it.

Last reviewed: November 2026

Why unread code is riskier

Vibe coding means describing what you want, letting a coding agent write it and accepting the result because it runs. The flaws that follow are not new. What is new is that the usual first filter, a person reading the code, is gone.

Published measurements show how often generated code needs that filter:

The last result matters most for vibe coding. The risk is the flaw combined with the confidence that there is none.

Flaws in the code itself: injection, hardcoded secrets, weak cryptography

1. Injection

The agent builds a query or a shell command by gluing user input into a string. It works in the demo, so it is accepted. This is CWE-89 for SQL, and Injection is category A05 in the OWASP Top 10:2025.

How it appears
@app.get("/orders")
def search_orders(q: str):
    sql = f"SELECT * FROM orders WHERE customer = '{q}'"
    return db.execute(sql).fetchall()
The fix
    sql = "SELECT * FROM orders WHERE customer = %s"
    return db.execute(sql, (q,)).fetchall()

How it is caught: static analysis follows the value of q from the request to the query and reports the exact line. A dynamic scan of the running application finds the same flaw from the outside.

2. Hardcoded secrets

To make the code run on the first try, the agent pastes a key, a password or a token into the source. The file is committed, and the secret is now in the repository history. This is CWE-798, Use of Hard-coded Credentials.

How it appears
const payments = new PaymentClient("sk_live_...")   // key in source
const DB_URL = "postgres://admin:Passw0rd@db.internal/prod"

How it is caught: a secret check before commit, and static analysis rules for hardcoded credentials. If a real secret reached the repository, rotate it. Deleting the line is not enough.

3. Weak cryptography

The agent reaches for what it has seen most often: MD5 or SHA-1 for passwords, a fixed initialisation vector, a non-cryptographic random generator for tokens. The code looks tidy and passes every functional test. This is CWE-327, Use of a Broken or Risky Cryptographic Algorithm, and Cryptographic Failures is category A04 in the OWASP Top 10:2025.

How it appears
import hashlib, random

password_hash = hashlib.md5(password.encode()).hexdigest()
reset_token = str(random.randint(100000, 999999))
The fix
import bcrypt, secrets

password_hash = bcrypt.hashpw(password.encode(), bcrypt.gensalt())
reset_token = secrets.token_urlsafe(32)

How it is caught: static analysis rules for weak algorithms and insecure randomness. This class is almost invisible in a demo, so a tool has to look for it.

Flaws in what the code pulls in: vulnerable and invented dependencies

4. Vulnerable or hallucinated dependencies

An agent adds packages freely. Two things go wrong. It may pin an old version with known vulnerabilities. Or it may name a package that does not exist.

The second case is measured. In a study by Spracklen and co-authors of 16 code-generating models, which generated 576,000 code samples, the average share of hallucinated packages was at least 5.2% for commercial models and 21.7% for open-source models, with 205,474 unique invented package names. An attacker can register such a name and wait for someone to install it. The OWASP Top 10 for LLM Applications (LLM09:2025) describes this scenario, and Software Supply Chain Failures is category A03 in the OWASP Top 10:2025.

How it appears
# requirements.txt written by the agent (illustrative names)
acme-http==1.4.0             # pinned to an old release: any known vulnerabilities?
acme-session-helpers==1.2    # does this package exist? who owns it?

How it is caught: software composition analysis (SCA) checks every dependency and version against known vulnerabilities. For names you do not recognise, look at the registry page before installing: age, owner, download history. Commit a lockfile so that a later install cannot pull something different.

Flaws in what is missing: authorization checks and insecure defaults

5. Missing authorization checks

You ask for an endpoint that returns an invoice. You get one. It checks that the user is logged in, and not that the invoice belongs to that user. Nothing in the code looks wrong, because the flaw is a line that is not there. This is CWE-862, Missing Authorization, and Broken Access Control is category A01, the first in the OWASP Top 10:2025.

How it appears
app.get("/api/invoices/:id", requireLogin, async (req, res) => {
  const invoice = await Invoice.findById(req.params.id)
  res.json(invoice)          // any logged-in user can read any invoice
})
The fix
  const invoice = await Invoice.findOne({ _id: req.params.id, owner: req.user.id })
  if (!invoice) return res.sendStatus(404)

How it is caught: this is the hardest class for pattern matching, because the rule depends on your business logic. Use three checks together. Write the rule down for the agent ("every query for a user-owned record filters by owner"). Run a model-based review, which can reason about intent: Anthropic's security guidance plugin documentation lists authorization bypass and insecure direct object references among the issues its review looks for. And test the running application with two accounts, by hand or with a dynamic scan.

6. Insecure defaults

Generated configuration is tuned to work at once: debug mode on, cross-origin requests allowed from anywhere, TLS verification switched off to get past an error, a storage bucket made public. Security Misconfiguration is category A02 in the OWASP Top 10:2025.

How it appears
app.run(host="0.0.0.0", debug=True)
CORS(app, origins="*", supports_credentials=True)
requests.get(url, verify=False)

How it is caught: static analysis rules for configuration, and a dynamic scan of the deployed application, which sees the settings that are really in effect.

Which check catches which risk

RiskFirst line of detectionSecond line
InjectionStatic analysis (SAST)Dynamic scan (DAST)
Hardcoded secretsSecret check before commitSAST
Weak cryptographySASTCode review
Vulnerable or invented dependenciesSoftware composition analysis (SCA)Lockfile and registry check
Missing authorization checksWritten rules and model-based reviewDAST and tests with two accounts
Insecure defaultsSASTDAST

No single check covers the table. A model-based review is strong where intent matters and can miss issues. A rule-based scanner is systematic and repeatable and does not know your business rules. Use both. The trade-off is explained in the guide to Claude Code security review.

A minimum safety net for vibe coding

You can keep the speed and still put a filter back. The smallest setup that works:

  1. Give the agent a scanner. If nobody reads the code, something must. An agent that can call a scanner's API scans its own work, reads the findings, fixes them and scans again. This is how to connect a coding agent to DerScanner; it takes three minutes and covers static analysis, composition analysis and dynamic analysis.
  2. Block secrets before commit. A pre-commit check costs seconds.
  3. Keep one gate the agent does not control. Run SAST and SCA in CI, and fail the build on new high-severity findings.
  4. Read the parts that decide who can do what. Login, permissions, payments, anything that touches personal data. It is a small share of the code, and the part where a mistake costs most.

The full process, with what each stage catches, is in how to secure AI-generated code.

Frequently Asked Questions

Try DerScanner on your own code, free

If nobody reads the code, let a scanner read it: connect your coding agent to DerScanner, and it scans, fixes and scans again.

Request a free pilot. We give you access and help with the first scan. It works in the cloud and on-premise.

Want to describe your project first? Take the 2-minute PoC survey