flawopen.com/SQL Injection in JavaScript/Knex.js
Its query builder methods are safe by default. Its knex.raw() escape hatch is safe only when values are passed as bindings, not interpolated into the string.
knex.raw(
`SELECT * FROM users WHERE id = ${userId}`
)knex('users').where(
'id', userId
)
// or with raw + bindings:
knex.raw(
'SELECT * FROM users WHERE id = ?',
[userId]
)Knex's fluent query builder (.where(), .insert(), .select()) parameterizes every value automatically. knex.raw() exists for queries the builder can't express — it stays safe only when the second argument is a bindings array, never when the SQL string itself is built with template-literal interpolation.
grep -rn "knex.raw(\`" --include="*.js" --include="*.ts" . | grep '\${'No — those affect naming conventions, not parameterization. Safety comes entirely from using bindings, independent of any plugin.