Using an ORM does not make SQL injection impossible. AI tools often mix safe ORM calls with a raw query "just this once", and that one query is where it goes wrong. Here are the patterns to look for.
1. String-built raw queries
Unsafe:
const rows = await db.query(`SELECT * FROM users WHERE email = '${email}'`)
Safe:
const rows = await db.query('SELECT * FROM users WHERE email = $1', [email])
Search your code for backticks and + inside query(, $queryRawUnsafe, sequelize.query, knex.raw, and .execute(.
2. ORM raw helpers used the wrong way
In Prisma, $queryRaw with a tagged template is parameterized. $queryRawUnsafe with a built string is not. In Drizzle, use the sql template with values, not string concatenation. In Knex, pass bindings: knex.raw('... ?', [value]).
3. Dynamic column and sort names
Parameters protect values, not identifiers. ORDER BY ${req.query.sort} can still be injected. Check the value against an allow-list of column names.
4. Filters passed straight from the request
where: req.body.filter lets a caller choose fields and operators. Build the filter from named fields you expect.
5. Supabase and PostgREST filters
.or(\name.eq.${input}) builds a filter string from user input. Escape it or use the typed filter methods.
6. Admin or search endpoints
Search boxes and admin reports are where raw SQL tends to hide. Read those routes first.
A quick test
On your own app, in a test environment, send a single quote ' in a search field or URL parameter. A server error or a changed result is a reason to read that code path. Do not test apps you do not own.
What an outside scan can and cannot see
A passive outside check does not send injection payloads. Use code review and the grep patterns above for this class, and keep the outside check for exposed keys, open data and headers.
Check your own app from the outside, free. Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see. One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.
Top comments (0)