HIGH · CVSS 3.1 7.5 EPSS 0.7% · 47th percentile CWE-943

CVE-2026-125119: Mongoose: Connection-level sanitizeFilter not applied

Published 2026-11-10 · Updated 2026-11-27 · Also known as BIT-mongoose-2026-125119, GHSA-gg4r-jv3p-qx3c

Summary

Mongoose fails to apply the sanitizeFilter security option when configured at the connection level, leaving applications vulnerable to query selector injection. Engineering teams relying on this connection-level setting must update to the specified patched versions to ensure proper input sanitization.

Who is affected

Applications using Mongoose 6.0.0 through 9.11.3 are affected if they enable sanitizeFilter via mongoose.connect() or createConnection(). When active, this flaw allows attackers to inject MongoDB operators like $ne into filter values, potentially bypassing authentication or unauthorized data retrieval. Global configurations and query-level settings remain unaffected.

Exploitability

The vulnerability carries a high CVSS base score of 7.5, indicating it can be exploited remotely with low complexity and no required privileges. With an EPSS score of 0.007, the likelihood of exploitation is currently low, and it is not listed in the CISA Known Exploited Vulnerabilities catalog.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-27. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
npm mongoose >= 6.0.0, < 6.13.12 6.13.12 npm install [email protected]
npm mongoose >= 7.0.0, < 7.8.13 7.8.13 npm install [email protected]
npm mongoose >= 8.0.0, < 8.24.7 8.24.7 npm install [email protected]
npm mongoose >= 9.0.0, < 9.11.4 9.11.4 npm install [email protected]

CVSS 3.1 vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Attack vectorNetwork
Attack complexityLow
Privileges requiredNone
User interactionNone
ScopeUnchanged
ConfidentialityHigh
IntegrityNone
AvailabilityNone

FAQ

Are global configurations or query-level filters affected?

No. Users that set sanitizeFilter globally using mongoose.set('sanitizeFilter') or on individual queries using Model.find().sanitizeFilter() are not affected.

Is this vulnerability actively being exploited?

No, it is not currently listed in the CISA Known Exploited Vulnerabilities catalog.

What is the technical root cause of this failure?

The connection-level option is stored in Connection.config, but the Query#_castConditions logic only checks Connection.options, resulting in the security filter never being invoked.

Original advisory description
### 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 with `mongoose.connect()` or `createConnection(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()` at `lib/drivers/node-mongodb-native/connection.js:270-272` moves `options.sanitizeFilter` into `Connection.config` and deletes the original option. `Query#_castConditions()` at `lib/query.js:2413-2423` checks `Connection.options`, the global `options`, and the per-query options, but never `Connection.config`. The defense therefore does not run even though `Connection#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 ```javascript import mongoose from 'mongoose' const conn = await mongoose.createConnection('<MONGODB_URI>', { sanitizeFilter: true }).asPromise() const User = conn.model('User', new mongoose.Schema({ username: String, password: String, marker: String })) await User.create({ username: 'victim', password: 'correct-password', marker: 'PROTECTED_RECORD' }) const filter = { username: 'victim', password: { $ne: null } } console.log(conn.get('sanitizeFilter')) console.log((await User.findOne(filter).lean()).marker) ``` A control query with a literal wrong password returned no document in the same run, confirming the filter is otherwise enforced. ### Impact Connection-level `sanitizeFilter` option is not respected. Any user that relies on connection-level config and `sanitizeFilter` to defend against query selector injection is affected. Users that set `sanitizeFilter` globally using `mongoose.set('sanitizeFilter')` or on specific queries using `Model.find().sanitizeFilter()` are not affected.

References

Source records: GHSA-gg4r-jv3p-qx3c (OSV.dev) · EPSS by FIRST, 2026-11-27.