Repository navigation
chore(deps): update dependency mongoose to v9.11.4 [security] - #1698
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
renovate
Bot
force-pushed
the
renovate/npm-mongoose-vulnerability
branch
2 times, most recently
from
November 11, 2026 00:32
a4586f8 to
4c864d4
Compare
renovate
Bot
force-pushed
the
renovate/npm-mongoose-vulnerability
branch
from
November 11, 2026 00:40
4c864d4 to
a37e567
Compare
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.
This PR contains the following updates:
9.9.3→9.11.4Mongoose: 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: 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)
v9.11.4Compare Source
===================
toStringwhen hydrating documents, setting dotted paths, and merging updates__proto__as paths in where() and mod()v9.11.3Compare Source
===================
v9.11.2Compare Source
===================
v9.11.1Compare Source
===================
v9.11.0Compare Source
===================
v9.10.4Compare Source
===================
v9.10.3Compare Source
===================
v9.10.2Compare Source
===================
v9.10.1Compare Source
===================
v9.10.0Compare Source
===================
v9.9.5Compare Source
==================
v9.9.4Compare Source
==================
Configuration
📅 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.