What is the fix?
db.query(`SELECT * FROM users WHERE id = ${req.query.id}`)
- Use a parameterised query
- Escape the quote characters
- Validate the length first
- Cast the value to a number
Binding sends data separately from SQL, so no input can change the statement's shape.
Play Cybersecurity ▸