Fix NoSQL injection in threshold parameter (allocations-dao.js) - #121
Open
legit-app-ci[bot] wants to merge 1 commit into
Open
Fix NoSQL injection in threshold parameter (allocations-dao.js)#121legit-app-ci[bot] wants to merge 1 commit into
legit-app-ci[bot] wants to merge 1 commit into
Conversation
|
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
Fixed a NoSQL injection vulnerability in
app/data/allocations-dao.js(lines 56-114) where thethresholdparameter was directly interpolated into a MongoDB$whereclause without sanitization.What changed
Replaced the vulnerable
$whereoperator with native MongoDB comparison operators. Thethresholdparameter is now:parseInt(threshold, 10)){userId: parsedUserId, stocks: {$gt: parsedThreshold}}The original code allowed attackers to inject arbitrary JavaScript (e.g.,
0';while(true){}'or1'; return 1 == '1) that would execute server-side in MongoDB. The fix eliminates JavaScript execution entirely by using MongoDB's native$gtoperator, which treats the threshold as data rather than executable code.Review notes
The commented fix block in the original code has been uncommented and applied. The
$whereclause with string interpolation has been removed.