All database queries use parameterized queries or ORMs
Why it matters
SQL injection (CWE-89) remains one of the most reliably exploitable vulnerabilities in web applications, cited in OWASP API Security Top 10 2023 API10. String-concatenated queries hand attackers a direct channel into the database: they can extract the full schema, dump all rows, bypass authentication, or in some configurations execute OS commands via xp_cmdshell. NoSQL injection (CWE-943) achieves the same ends with operator injection like { $where: ... } or { $gt: '' }. ORMs and parameterized queries separate code from data at the driver level — a string from user input can never become a SQL keyword or a query operator.
Severity rationale
High because SQL and NoSQL injection give attackers direct read/write access to the entire database, potentially bypassing all application-level authorization.
Remediation
Use ORM methods or parameterized placeholders for every database interaction. Never interpolate user-controlled strings into query text, including in ORDER BY clauses, table names, or JSON path expressions.
// Bad — never do this
const user = await pool.query(`SELECT * FROM users WHERE email = '${req.body.email}'`)
// Good — parameterized
const user = await pool.query('SELECT * FROM users WHERE email = $1', [req.body.email])
// Good — ORM (Prisma, Drizzle, Kysely all parameterize under the hood)
const user = await db.user.findUnique({ where: { email: req.body.email } })
// If dynamic column names are unavoidable, use an allowlist:
const SORTABLE = ['name', 'createdAt', 'email'] as const
const col = SORTABLE.includes(req.query.sort) ? req.query.sort : 'createdAt'
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the API Security Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-89 — SQL Injection
- cwe · CWE-943 — Improper Neutralization of Special Elements in Data Query Logic
- owasp:2021 · A03 — Injection
- owasp:2023 · API10 — Unsafe Consumption of APIs
Taxons
History
- 2026-04-18·v1.0.0·Initial import from api-security·automated