Fix Mongoose NoSQL Injection Vulnerability (SNYK-JS-MONGOOSE-8446504) #2
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.
Fix Mongoose NoSQL Injection Vulnerability (SNYK-JS-MONGOOSE-8446504)
Vulnerability Details
Changes Made
1. Dependency Upgrade
mongoosefrom version4.2.4to6.13.6inpackage.jsonpackage-lock.jsonwith new dependency tree2. API Compatibility Updates
mongoose.connect()inmongoose-db.jsto use modern connection options:useNewUrlParser: trueuseUnifiedTopology: trueUser.find()callback to prevent crashes from undefined results3. Breaking Changes Addressed
The major version upgrade from mongoose 4.x to 6.x required handling several breaking changes:
Testing Results
Security Impact
This upgrade resolves the high-severity NoSQL injection vulnerability that could allow attackers to bypass authentication by manipulating query parameters. The vulnerable authentication logic in
routes/index.js(line 39) is now protected by the security fixes in mongoose 6.13.6.Files Modified
package.json- Updated mongoose dependency versionpackage-lock.json- Updated dependency treemongoose-db.js- Added connection options and improved error handlingLink to Devin Run
https://app.devin.ai/sessions/97153d0cdb584960a1753c518b16a64d
Requested by: Shawn Azman ([email protected])