fix: remediate SQL Injection and add rate limiting in src/routes/auth.js - #108
Closed
devin-ai-integration[bot] wants to merge 2 commits into
Closed
devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Convert string interpolation to parameterized queries using ? placeholders for better-sqlite3 prepared statements: - Alert #25 (line 16): login query now uses .get(username, password) - Alert #26 (line 43): reset-password UPDATE now uses .run(resetToken, expiry, email) - Alert #28 (line 57): register INSERT now uses .run(username, password, email) This prevents user-provided values from being interpreted as SQL code. Co-Authored-By: yubinkjee <yubinkjee@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Adds express-rate-limit middleware to prevent brute-force and abuse: - /login: 10 requests per 15 minutes per IP - /reset-password: 5 requests per 15 minutes per IP - /register: 10 requests per hour per IP Addresses CodeQL missing rate limiting alerts on lines 13, 38, 55. Co-Authored-By: yubinkjee <yubinkjee@gmail.com>
Contributor
Author
|
Closing due to inactivity for more than 7 days. Configure here. |
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.
Summary
Fixes 3 high-severity SQL injection vulnerabilities (CodeQL alerts #25, #26, #28) in
src/routes/auth.jsby replacing string interpolation with parameterized queries using better-sqlite3's?placeholder syntax.POST /loginPOST /reset-passwordPOST /registerUser-supplied values (
username,password,email) are now passed as bound parameters to.get()/.run()instead of being interpolated directly into the SQL string.Updates since last revision
Added
express-rate-limitmiddleware to address 3 additional CodeQL "missing rate limiting" alerts on the same routes:POST /loginPOST /reset-passwordPOST /registerThis adds
express-rate-limit(^8.2.1) as a new dependency. Rate limiters use the default in-memory store, which is sufficient for single-instance deployments.Review & Testing Checklist for Human
?placeholder binding order matches the intended columns in each of the 3 queries (login SELECT, reset-password UPDATE, register INSERT)express-rate-limitmiddleware is correctly placed as the second argument (before the handler) in eachrouter.post()callPOST /login,POST /reset-password, andPOST /registerendpoints to confirm they still function correctly with valid inputs, and that rate-limited requests receive a 429 responsedebug: \Query executed: ${query}`` — it now safely shows the parameterized template rather than interpolated user values, but still leaks query structure. This is a separate issue (CWE-209) not addressed here.rate-limit-redis)Notes