Repository navigation
fix(deps): update dependency mongoose to v6.13.12 [security] - #1511
renovate-bot wants to merge 1 commit into
Conversation
|
/gcbrun |
There was a problem hiding this comment.
Code Review
This pull request upgrades the mongoose dependency from version 6.11.3 to 6.13.10 in both package.json and package-lock.json. Feedback suggests also upgrading the root mongodb dependency in package.json to version 4.17.2 to align with mongoose's internal dependency and allow npm to deduplicate the package.
| "mongodb": "4.17.1", | ||
| "express": "4.18.2", | ||
| "mongoose": "6.11.3" | ||
| "mongoose": "6.13.10" |
There was a problem hiding this comment.
With the upgrade of mongoose to 6.13.10, its internal dependency on mongodb has been updated to 4.17.2 (as seen in package-lock.json). However, the root package.json still specifies mongodb: 4.17.1 on line 13. To ensure dependency alignment and allow npm to deduplicate the mongodb package in node_modules, consider updating the root mongodb dependency to 4.17.2 as well.
47a850c to
dde5da9
Compare
|
/gcbrun |
Note
This PR body was truncated due to platform limits.
This PR contains the following updates:
6.11.3→6.13.12Mongoose search injection vulnerability
CVE-2025-23061 / GHSA-vg7j-7cwx-8wgw
More information
Details
Mongoose versions prior to 8.9.5, 7.8.4, and 6.13.6 are vulnerable to improper use of the
$whereoperator. This vulnerability arises from the ability of the$whereclause to execute arbitrary JavaScript code in MongoDB queries, potentially leading to code injection attacks and unauthorized access or manipulation of database data.NOTE: this issue exists because of an incomplete fix for CVE-2024-53900.
Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose search injection vulnerability
CVE-2024-53900 / GHSA-m7xq-9374-9rvx
More information
Details
Mongoose versions prior to 8.8.3, 7.8.3, 6.13.5, and 5.13.23 are vulnerable to improper use of the $where operator. This vulnerability arises from the ability of the $where clause to execute arbitrary JavaScript code in MongoDB queries, potentially leading to code injection attacks and unauthorized access or manipulation of database data.
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection
CVE-2026-42334 / GHSA-wpg9-53fq-2r8h
More information
Details
Impact
This vulnerability allows bypassing Mongoose’s sanitizeFilter query sanitization mechanism via the
$noroperator.When sanitizeFilter is enabled, Mongoose wraps query operators in
$eqto neutralize them. However, prior to the fix,$norwas not included in the set of logical operators that are recursively sanitized. Because$noraccepts an array (like$andand$or), and arrays do not triggerhasDollarKeys(), malicious operators such as$ne,$gt, or$regexcould be injected inside a$norclause without being sanitized.This may lead to:
Affected users:
Applications that:
Model.findOne(req.body)) and rely onsanitizeFilterto strip out query selectorsApplications that validate input schemas, whitelist fields, or avoid passing raw request bodies into queries are not affected. For example,
Model.findOne({ user: req.body.user, pwd: req.body.pwd })is not affected.Patches
Patches have been released for all supported Mongoose release lines:
^6.13.9^7.8.9^8.22.1^9.1.6Workarounds
Delete
$norkeys, use an additional schema validation library, or write middleware to strip out$norfrom query filters.Resources
sanitizeFilter documentation: https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.sanitizeFilter()
Original blog post on sanitizeFilter: https://thecodebarbarian.com/whats-new-in-mongoose-6-sanitizefilter.html
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose: Prototype pollution in mongoose update casting via proto-prefixed dotted path (Schema._getSchema/path getter)
CVE-2026-73562 / GHSA-664h-wqgq-64gw
More information
Details
Impact
What kind of vulnerability is it? Who is impacted?
Prototype pollution in update casting: passing a user-controlled update to a Mongoose update, like
MyModel.updateOne(filter, req.body), can cause Mongoose to set$fullPathand$parentSchemaDocArrayonObject.prototype.Example:
Patches
Has the problem been patched? What versions should users upgrade to?
9.7.2, 8.24.1. 7.8.10, 6.13.10
Workarounds
Is there a way for users to fix or remediate the vulnerability without upgrading?
Check user-controlled updates for own
__proto__properties before passing to MongooseReferences
Are there any links users can visit to find out more?
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose: Connection-level sanitizeFilter not applied
CVE-2026-125119 / GHSA-gg4r-jv3p-qx3c
More information
Details
Summary
sanitizeFilter exists to stop query selector injection: it wraps operator objects such as
{ $ne: null }in filter values in$eq, so they are matched literally. Set on a connection withmongoose.connect()orcreateConnection(uri, { sanitizeFilter: true }), the connection reports it as enabled but queries never apply it. An application that relies on the connection-level option and passes an attacker-controlled object into a filter therefore remains open to selector injection, and a password value of{ $ne: null }returns the account record without the password.Details
NativeConnection#createClient()atlib/drivers/node-mongodb-native/connection.js:270-272movesoptions.sanitizeFilterintoConnection.configand deletes the original option.Query#_castConditions()atlib/query.js:2413-2423checksConnection.options, the globaloptions, and the per-query options, but neverConnection.config. The defense therefore does not run even thoughConnection#get('sanitizeFilter')returns true. This storage was introduced in Mongoose 6.0.0 and the same mismatch is present in 9.11.2.Proof of concept
A control query with a literal wrong password returned no document in the same run, confirming the filter is otherwise enforced.
Impact
Connection-level
sanitizeFilteroption is not respected. Any user that relies on connection-level config andsanitizeFilterto defend against query selector injection is affected. Users that setsanitizeFilterglobally usingmongoose.set('sanitizeFilter')or on specific queries usingModel.find().sanitizeFilter()are not affected.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose: sanitizeFilter not applied on countDocuments
CVE-2026-125120 / GHSA-pcrw-h46h-c93h
More information
Details
Impact
sanitizeFilteris Mongoose's mechanism for protecting against query selector injection attacks. In older versions of Mongoose,sanitizeFilterwas not applied forcountDocuments()queries.Patches
Patches have been released for all supported Mongoose major release lines. Please upgrade to the following versions depending on which major version of Mongoose applications are using.
^9.9.2^8.24.3^7.8.12^6.13.11Workarounds
Middleware:
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose: Prototype pollution via Schema.prototype.virtual()
CVE-2026-125118 / GHSA-6972-9mcm-vhwj
More information
Details
Summary
Prototype pollution via Schema.prototype.virtual() — the 2022 fix for CVE-2022-2564 / CVE-2022-24304 protected Schema.path()/add() but never virtual(), so the same class of bug is still exploitable in all maintained release lines.
Details
In lib/schema.js, Schema.prototype.virtual() (defined at line 2643) builds the virtual path via:
Unlike
path()/add(),virtual()never received thespecialPropertiescheck added for CVE-2022-2564/CVE-2022-24304 (lib/schema.jslines 806, 1308, 1331).A path containing
__proto__/constructor/prototypesegments resolves through the prototype chain and writes ontoObject.prototype/Function.prototype.Proof of concept
Impact
Attacker-influenced schema field names (dynamic schemas, CMS form builders, schema-as-code) allow pollution of Object.prototype (own, enumerable keys visible on every object — e.g.
({}).isAdminchecks can be spoofed) and Function.prototype (a known gadget primitive in server-side JS).Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose walks into inherited properties when hydrating, setting, and merging, allowing overwrites of built-in functions (denial of service) and shared schema state
CVE-2026-125117 / GHSA-8332-j7wj-wjw4
More information
Details
Summary
Three Mongoose code paths copy data into objects by property name without checking whether the property is the object's own or inherited from its prototype:
init(), also used byModel.hydrate())$__set, used bynew Model(obj),doc.set()anddoc.$set())utils.mergeClone, used byfindOneAndReplace(), chained update calls andQuery.prototype.merge())When a key names an inherited property, such as
toStringorvalueOf, or a document internal such as$__schema, Mongoose writes into the shared object behind that property. The data comes from the attacker.{ "toString": { "call": 1 } }overwritesObject.prototype.toString.call. Mongoose and most other libraries rely onObject.prototype.toString.call(). After the overwrite, every later query in the process throwsTypeError: _toString.call is not a functionuntil the process restarts. This includes queries on unrelated models.strict: false, a path such asprofile.$__schema.paths.email.validatorsreaches the subdocument's schema, which every document shares. Setting it to[]removes therequiredvalidator for every document in the process.Mongoose already blocked
__proto__,constructorandprototype, so these bugs cannot add properties toObject.prototypeitself. They can still overwrite methods and properties of shared built-in functions and of Mongoose's internal objects.Details
1. Loading documents:
init()For a stored field named
toString,doc[i]is the inheritedObject.prototype.toString. It is truthy, soinit()recurses into that function and copies the stored subfields onto it.This runs for every document Mongoose loads:
find(),findOne(), cursors, populated documents andModel.hydrate(). It runs whatever thestrictsetting, and it applies to top-level and nested paths alike.lean()queries are not affected.A malicious document can get into the collection in several ways:
strict: false, for examplenew Model(req.body).save();2. Setting dotted paths:
$__setWhen it walks a dotted path,
$__setreadobj[parts[i]]and descended into whatever it found. That included inherited functions, such asObject.prototype.toStringon a plain object orDocument.prototype.toObjecton a subdocument. On subdocuments it also included non-function internals that are prototype getters, such as$__schema,schema,$__middlewareand$__schemaTypeOptions. Those point at objects that every document of the model shares.Attacker-controlled input reaches this path through:
Mixedpath on a default, strict schema:new Model({ "mixed.toString.call": 1 }), ordoc.set({ "mixed.toString.call": 1 }). Nothing needs to be saved.strict: false: for exampledoc.set('toString.call', 1).strict: false, when the application passes a user-controlled path todoc.set(path, value): for exampledoc.set('profile.$__schema.paths.email.validators', []).3. Merging updates:
utils.mergeCloneto[key]was read without an own-property check, so a key such astoStringrecursed intoObject.prototype.toString. This affects:Model.findOneAndReplace(filter, replacement). It always merges the replacement into the query's update, so a single call with an untrusted replacement is enough.Model.updateOne(filter, { $set: {...} }).updateOne({}, untrustedUpdate), the same pattern withfindOneAndUpdate(), or middleware that callsthis.updateOne(...).Query.prototype.merge()with a source query whose update came from untrusted input.Proof of concept
Impact
Denial of service (paths 1, 2 and 3). One request overwrites
Object.prototype.toString.call. After that, every query in the process fails, and so does much other code, until the process restarts. Ways in:new Model(req.body)on any schema with aMixedpath;findOneAndReplace()with an untrusted replacement;{ "toString": { "call": 1 } }.In the stored-document case, the attacker does not need any write path through Mongoose at the moment of the attack. Any later read of that document triggers the overwrite. If the document is read on startup or by a scheduled job, the application can be kept down.
Changes to shared state (path 2,
strict: falsesubdocuments). An attacker who controls the path passed todoc.set(path, value)can change a subdocument schema that every document shares. For example, they can remove validators or change schema options for every later document in the process.Properties on built-in functions. More generally, an attacker can attach properties they choose to built-in functions such as
Object.prototype.toString,Object.prototype.valueOfandFunction.prototype.call. Any other code that reads properties of those functions sees the attacker's values.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Mongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collections
CVE-2026-125116 / GHSA-wr5m-5jph-8m96
More information
Details
Summary
Mongoose chooses which discriminator model or schema to use by looking up the discriminator key value (
__tby default) in a plain object of registered discriminators, for exampleModel.discriminators[doc.__t]. That value comes from user documents and query filters. Because the lookup did not check own properties, a value that names a property inherited fromObject.prototyperesolves to that inherited value instead of a discriminator. Examples are'constructor','toString'and'hasOwnProperty'.__t: 'constructor'resolves to the globalObjectfunction. Mongoose then callsnew Object(doc), which returns the raw user object where a Mongoose document is expected.__t: 'toString'and similar names resolve to built-in functions that throw when used as a constructor or schema.The most serious effect: through
bulkWrite()insertOnewithskipValidation: true, the raw user object is stored as-is, without schema casting orstrictfiltering. After that, every query that returns the stored document throws, until the document is removed from the database.Details
The registries that hold discriminators are plain objects:
Model.discriminators,schema.discriminators, and the embedded discriminator registries on document arrays and single nested subdocuments. Several code paths indexed them directly with a value taken from the document or filter:new Model(doc))Model.create(),insertMany(),bulkWrite(),bulkSave()find(),findOne(), etc.) andModel.hydrate()'events.__t'and$elemMatcharrayFilterspush()/create(), document array and single nested castinggetDiscriminatorByValue()already iterated the registry's own keys safely. But most callers tried the direct lookup first and only fell back to it afterwards, so a truthy inherited value took precedence.The lookups only read inherited properties. They do not write to
Object.prototypeor any other shared object, and they do not change in-memory state that affects other requests. This is NOT a prototype pollution vector.Proof of concept
Impact
TypeErroror a non-document object returned to application code. Ways in includeModel.create(req.body),new Model(req.body),Model.find(req.query)-style filters, and pushing user input onto embedded discriminator arrays. The effect is limited to the request carrying the value.bulkWrite({ skipValidation: true }). When an application passes untrusted documents tobulkWrite()insertOnewithskipValidation: true, the raw object is stored without casting orstrictfiltering. Fields the schema would normally strip are persisted, such as anisAdminthat isn't in the schema. Fields with wrong types are also persisted.bulkWrite()path above, the document can get into the collection through another application, the raw MongoDB driver, or any other writer that does not go through Mongoose casting.This issue doesn't let an attacker modify
Object.prototype, built-in functions, schemas or other shared in-memory state. The schema bypass requires the application to opt in toskipValidationwith untrusted input.Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
Automattic/mongoose (mongoose)
v6.13.12Compare Source
v6.13.11Compare Source
6.13.11 / 2026-08-10
v6.13.10Compare Source
v6.13.9Compare Source
6.13.9 / 2026-02-04
v6.13.8Compare Source
===================
v6.13.7Compare Source
===================
v6.13.6Compare Source
===================
v6.13.5Compare Source
===================
v6.13.4Compare Source
===================
v6.13.3Compare Source
===================
v6.13.2Compare Source
===================
v6.13.1Compare Source
===================
v6.13.0Compare Source
===================
v6.12.9Compare Source
===================
v6.12.8Compare Source
===================
valueproperty rather than boolean #14418v6.12.7Compare Source
===================
openUri()#14370 [#13376](https://redirect.github.com/Automattic/mongConfiguration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.