Draft
Conversation
YurijPaharev
reviewed
Mar 4, 2026
Comment on lines
+123
to
+125
| - Show how interpolating raw user input into SQL (for example, using `.raw()` or `orderByRaw(req.query.sort)`) can open up injection vulnerabilities. | ||
| - Use a Snippets-style example, such as an endpoint that sorts results based on a `sort` query parameter, to demonstrate how a malicious value could modify the query. | ||
| - Contrast this with safe usage of the Knex Query Builder and parameter binding. |
There was a problem hiding this comment.
should we consider adding the SQL Injection snippet for the actual demonstration of how the data would be affected if used incorrectly? It probably could be a nice addition to show what exactly happens if such thing is executed (sorry if it was written somewhere and I missed it). Considering that it is the orderByRaw it is a Blind SQL Injection as far as I know, so it is not the easiest one to reproduce yourself if you do not know where to look at. Maybe something like this could suffice
(CASE WHEN (SELECT COUNT(*) FROM users WHERE email='admin@test.com') > 0 THEN email ELSE password END)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference: #275