Fix SSJS/NoSQL code injection vulnerabilities#2
Conversation
…d fix NoSQL injection Agent-Logs-Url: https://github.com/Good-Stuff-Inc/codeql-actions-test1/sessions/e159d99d-4081-4501-b92e-172f2e39504d Co-authored-by: marcosbergami <56553101+marcosbergami@users.noreply.github.com>
|
@copilot modify this resolution and propose another possible alternative to fix this vulnerability. |
…r for allocations Agent-Logs-Url: https://github.com/Good-Stuff-Inc/codeql-actions-test1/sessions/08fc4d3c-8280-45df-a40d-814e84ccfc10 Co-authored-by: marcosbergami <56553101+marcosbergami@users.noreply.github.com>
Here's the alternative approach implemented in commit
|
Replaces insecure
eval()usage in contribution parsing and eliminates NoSQL$whereinjection in allocation threshold queries by removing the JavaScript-in-query approach entirely.Changes
app/routes/contributions.jseval(req.body.*)with strict regex validation (/^\d+$/) to reject any non-numeric input upfront, then convert withNumber()forpreTax,afterTax, androth/*jslint evil: true */directive and stale commented-outparseIntblockapp/data/allocations-dao.jsthresholdviaparseInt(threshold, 10)and validate it falls within[0, 99]$whereJavaScript-in-query clause entirely with native MongoDB query operators ({ userId: parsedUserId, stocks: { $gt: parsedThreshold } }), eliminating the JavaScript execution attack surface at the query levelErroron out-of-range values instead of passing raw user input to the queryPotential fix for alerts