How to fix: SQL String Concatenation Pattern Detected
The response body contains code patterns that construct SQL queries through string concatenation or template literals. This is one of the most common AI-generated vulnerabilities, enabling SQL injection.
Why it matters
SQL injection via string concatenation allows attackers to read arbitrary database contents, bypass authentication, modify or delete data, and potentially execute OS commands depending on the database configuration.
AI code generators very commonly produce SQL queries as template literals: `SELECT * FROM users WHERE id = ${userId}`. This works immediately and looks correct but is fundamentally broken: any user-controlled input in the query enables full SQL injection.
How to fix it
- 1Use parameterized queries exclusively: pool.query('SELECT * FROM users WHERE id = $1', [userId]).
- 2Use an ORM (Prisma, Drizzle, TypeORM) with parameterized queries by default.
- 3If you must use raw SQL, validate and sanitize all inputs before interpolation (whitelist IDs as integers, etc.).
- 4Enable static analysis tools (sqlfluff, eslint-plugin-security) to catch string-concatenated queries.
Code examples
Parameterized query (pg)
// Bad (AI-generated SQL injection)
const query = `SELECT * FROM users WHERE email = '${email}'`;
await pool.query(query);
// Good
await pool.query('SELECT * FROM users WHERE email = $1', [email]);References
Detected automatically by VulnRadar. The check id is vibe-sql-string-concat, stable across every scan so you can filter or diff on it.
More ai code checks
- LowGeneric Error Messages Leak No Context
- MediumTODO/FIXME Security Note in Response
- Higheval() Usage in Page Scripts
- HighSSL Certificate Verification Disabled
- HighMath.random() Used for Security Tokens
- CriticalHardcoded Credential in Authentication Logic
- CriticalJWT 'none' Algorithm Accepted
- MediumStack Trace Exposed in Response
Questions
- How severe is SQL String Concatenation Pattern Detected?
- VulnRadar rates this critical severity in the ai code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id vibe-sql-string-concat, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does SQL String Concatenation Pattern Detected map to?
- It maps to CWE-89. In the OWASP Top 10 it falls under A03:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.