Skip to content

fix: upgrade mongoose 4.2.4 -> 5.13.23 (SNYK-JS-MONGOOSE-1086688, Schema.path prototype pollution) - #1124

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/sfind-2c497ed0-mongoose-schema-path-proto-pollution
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/sfind-2c497ed0-mongoose-schema-path-proto-pollution

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Summary

Fixes code-scan finding sfind-2c497ed0c7444d23b3be80bd9f9e4508: SNYK-JS-MONGOOSE-1086688, prototype pollution through Schema.path() (CWE-1321, high).

  • mongoose 4.2.4 -> 5.13.23 (exact pin), the latest 5.x release; the fix landed in 5.12.2. The lockfile now resolves mongodb 3.7.4 and mquery 3.2.5. No app code changes: mongoose.connect(uri), the callback-style find/findById/save/remove in mongoose-db.js and routes/index.js all still work on 5.x.
  • New tests/mongoose-schema-prototype-pollution.test.js (node --test, no new dependencies).
new mongoose.Schema({}).path('__proto__.polluted', String)
// 4.2.4:   no error, and ({}).polluted === String   <- Object.prototype polluted
// 5.13.23: throws "Cannot set special property `__proto__` on a schema"

Verification (Node 22.12, local mongod 7.0, MySQL 5.7 container for the TypeORM side)

main (4.2.4) this branch (5.13.23)
node --test tests/mongoose-schema-prototype-pollution.test.js 0/3 pass 3/3 pass
npm start, then GET / crashes at startup (mongoose-db.js:50 users.length of undefined: the 4.2 driver can't talk to mongod 7) 200
POST /create todo, then it appears on / n/a 302, todo listed
[REDACTED SECRET] seed + POST /login n/a seeded, 302 -> /[REDACTED SECRET]

New startup warnings on 5.x: the driver's useNewUrlParser / useUnifiedTopology deprecation notices. They're harmless and I left them alone to keep this change small.

Notes

Devin-Org: engineering

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/2f9ad392521446b188e35f9fffc583dc
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/2f9ad392521446b188e35f9fffc583dc?variant=devin


Devin Review

Status Commit
⚪ Not started —

Run Devin Review

Enable auto-review to review your pull requests automatically.

Devin Review (Staging)


Devin Review

Schema.path() in mongoose < 5.12.2 lets '__proto__.x' paths write to Object.prototype. 5.13.23 rejects __proto__/constructor paths. Adds a node:test regression test.

Refs: sfind-2c497ed0c7444d23b3be80bd9f9e4508
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedmongoose@​4.2.4 ⏵ 5.13.23982510098100
Updatedmongodb@​2.0.46 ⏵ 3.7.498 -1100 +1610098 +48100

View full report

@socket-security

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Priority Alert  (click "▶" to expand/collapse) Action
Critical priority
Critical CVE: Mongoose search injection vulnerability

CVE: GHSA-vg7j-7cwx-8wgw Mongoose search injection vulnerability (CRITICAL)

Affected versions: >= 8.0.0-rc0 < 8.9.5; >= 7.0.0-rc0 < 7.8.4; < 6.13.6

Patched version: 6.13.6

From: package-lock.json → npm/mongoose@5.13.23

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/mongoose@5.13.23. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn

View full report

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants