Every CVESearch/Get API key

CVE-2026-142595

Mongoose: `sanitizeFilter` bypass via MongoDB internal top-level query operators such as `$_internalSchemaXor`

Explain with AI
ChatGPTClaudeGoogle AI
Severity
6.5Medium
Network attack, no privileges, no user interactionCVSS 3.1, CVE List
Exploitation
Proof of concept
CISA reports one, no source links it
Exploit chance
0.83% in 30 days
Percentile58th
EPSS, scored
Listed fix
6.13.13 for mongoose (npm)
From GitHub Advisories and OSV3 more listed versions, 3 other affected packages

Overview

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.0.0 until 6.13.13, 7.8.14, 8.24.10, and 9.12.2, Mongoose's sanitizeFilter rejects only a small named set of top-level operators and does not recursively inspect undocumented operators such as $_internalSchemaXor and $_internalSchemaCond. Applications that pass attacker-controlled filter keys to queries while relying on sanitizeFilter can therefore accept nested selectors such as $ne or $regex, allowing authentication bypass, disclosure of protected values through boolean queries, or unintended updates and deletions. Applications that construct filters from individual primitive values are not affected by this bypass. This issue is fixed in versions 6.13.13, 7.8.14, 8.24.10, and 9.12.2.

CVSS 3.1 vector

Exploitability

Attack vector
Network
Complexity
High
Privileges needed
None
User interaction
None

Impact

Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
None
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N

Exploit chance over time

Up 0.3 points since Dec 3, 2026
EPSS score, scored every day from Dec 3, 2026 to Dec 4, 2026: lowest 0.56% on Dec 3, 2026, highest 0.83% on Dec 4, 2026, 0.83% on the last day.

Affected

Packages 4

Affected packages
PackageAffectedFixed
mongoose
npm
before 6.13.13
6.13.13
7.0.0 up to 7.8.14
7.8.14
8.0.0 up to 8.24.10
8.24.10
9.0.0 up to 9.12.2
9.12.2
librechat-0
Docker Hardened Images:Alpine:3.23
0.8.8-r0 and later, plus listed versions
0.8.8-r10.8.8-r20.8.8-r30.8.8-r40.8.8-r5
Show 5 more versionsShow less
0.8.8-r60.8.9-r00.8.9-r10.8.9-r20.8.9-r3
None listed
librechat-0
Docker Hardened Images:Alpine:3.24
0.8.8-r0 and later, plus listed versions
0.8.8-r10.8.8-r20.8.8-r30.8.8-r40.8.8-r5
Show 5 more versionsShow less
0.8.8-r60.8.9-r00.8.9-r10.8.9-r20.8.9-r3
None listed
librechat-0
Docker Hardened Images:Debian:13
0.8.8-0 and later, plus listed versions
0.8.8-10.8.8-20.8.8-30.8.8-40.8.8-5
Show 5 more versionsShow less
0.8.9-00.8.9-10.8.9-20.8.9-30.8.9-4
None listed

Only in multi-CVE advisories 1

Each of these advisories covers several CVEs at once, so it doesn’t establish that this one affects the package.

Packages named only by advisories that cover several CVEs
PackageAffectedFixed
mongoose
TuxCare:npm
8.2.0-tuxcare.0 up to 8.2.0-tuxcare.1, plus listed versions
From an advisory covering 10 CVEs
8.2.0
8.2.0-tuxcare.1
8.7.2-tuxcare.0 up to 8.7.2-tuxcare.1, plus listed versions
From an advisory covering 10 CVEs
8.7.2
8.7.2-tuxcare.1
9.10.4-tuxcare.0 up to 9.10.4-tuxcare.3, plus listed versions
From an advisory covering 2 CVEs
9.10.49.10.4-tuxcare.19.10.4-tuxcare.2
9.10.4-tuxcare.3
9.10.1-tuxcare.0 up to 9.10.1-tuxcare.2, plus listed versions
From an advisory covering 2 CVEs
9.10.19.10.1-tuxcare.1
9.10.1-tuxcare.2

Products 1

Sources

CVE List Score usedCVSS 3.16.5

Mongoose: `sanitizeFilter` bypass via MongoDB internal top-level query operators such as `$_internalSchemaXor`

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.0.0 until 6.13.13, 7.8.14, 8.24.10, and 9.12.2, Mongoose's sanitizeFilter rejects only a small named set of top-level operators and does not recursively inspect undocumented operators such as $_internalSchemaXor and $_internalSchemaCond. Applications that pass attacker-controlled filter keys to queries while relying on sanitizeFilter can therefore accept nested selectors such as $ne or $regex, allowing authentication bypass, disclosure of protected values through boolean queries, or unintended updates and deletions. Applications that construct filters from individual primitive values are not affected by this bypass. This issue is fixed in versions 6.13.13, 7.8.14, 8.24.10, and 9.12.2.

Record
CVE-2026-142595
CVSS 3.1
6.5 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Weakness
CWE-943
Updated
2026-12-03
EUVDEUVD-2026-141930CVSS 3.16.5

Mongoose: sanitizeFilter bypass via MongoDB internal top-level query operators such as $_internalSchemaXor

Record
EUVD-2026-141930
CVSS 3.1
6.5 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Updated
2026-12-04
GitHub AdvisoriesGHSA-25v4-hrwm-qj9fCVSS 3.16.5

Mongoose: `sanitizeFilter` bypass via MongoDB internal top-level query operators such as `$_internalSchemaXor`

Summary

Mongoose's sanitizeFilter option is meant to block query selector injection. Before this fix, it only refused four top-level operators by name: $jsonSchema, $where, $expr and $text. Any other top-level $ operator was passed to MongoDB unchanged. That includes undocumented internal operators like $_internalSchemaXor and $_internalSchemaCond, which take sub-filters, and sanitizeFilter never inspected those sub-filters. An attacker who controls the keys of a query filter could use them to slip arbitrary query selectors like $ne or $regex past sanitizeFilter.

Details

With sanitizeFilter enabled, Mongoose:

  • wraps any object value containing $ keys in $eq, so { password: { $ne: null } } becomes { password: { $eq: { $ne: null } } };
  • recurses into $and, $or and $nor;
  • throws on $jsonSchema, $where, $expr and $text unless the value is wrapped in mongoose.trusted().

Every other top-level key starting with $ was left alone. MongoDB accepts several internal match expressions at the top level that contain nested filters, for example:

  • $_internalSchemaXor: [filter1, filter2]
  • $_internalSchemaCond: [ifFilter, thenFilter, elseFilter]

Because sanitizeFilter doesn't recurse into these, the nested filters can contain any query selector.

The fix makes sanitizeFilter refuse every top-level key that starts with $, except $and, $or and $nor, which it recurses into, and values wrapped in mongoose.trusted(). Nested $and/$or/$nor filters are checked the same way. This also means sanitizeFilter now refuses:

  • $comment: a user-supplied comment ends up in MongoDB's profiler and logs. Use Query.prototype.comment() instead, which sets the comment outside the filter.
  • $sampleRate, $alwaysTrue, $alwaysFalse, and top-level $ref/$id/$db.

A top-level $-prefixed field name can't be queried with a plain equality filter in the first place: MongoDB rejects { $userId: 42 } with "unknown top level operator". So the fix doesn't prevent any query that previously worked.

Proof of concept

const User = mongoose.model('User', new mongoose.Schema({ username: String, password: String }));
await User.create({ username: 'admin', password: 'hunter2' });

// Attacker controls the filter, e.g. `User.findOne(req.body)`
const login = filter => User.findOne(filter).setOptions({ sanitizeFilter: true });

// Blocked as expected: `$ne` is wrapped in `$eq`, so no match
await login({ username: 'admin', password: { $ne: null } }); // null

// Bypass: login without the password
await login({
  username: 'admin',
  $_internalSchemaXor: [{ password: { $ne: null } }, { $alwaysFalse: 1 }]
}); // { username: 'admin', password: 'hunter2', ... }

// Bypass: extract the password one character at a time
await login({
  username: 'admin',
  $_internalSchemaXor: [{ password: { $regex: '^h' } }, { $alwaysFalse: 1 }]
}); // matches, so password starts with 'h'

Tested against MongoDB 9.0.2. $_internalSchemaCond works the same way, and both operators also work inside $and/$or/$nor.

Impact

Applications are affected if they rely on sanitizeFilter to protect queries whose filter keys come from users. Common patterns are Model.find(req.body) and Model.find({ ...req.query, owner: userId }). An attacker can inject any query selector, which allows:

  • Authentication bypass: match a user record without knowing the password, as in the $ne example above.
  • Data extraction: use $regex as a boolean oracle to recover field values, such as password hashes or tokens, one character at a time.
  • Unintended writes: make updateOne(), deleteMany() and similar operations match documents the attacker shouldn't be able to target.

Applications that build filters from individual values, like { username: req.body.username }, are not affected. sanitizeFilter already wraps those values in $eq, so an attacker can't add…

Record
GHSA-25v4-hrwm-qj9f
CVSS 3.1
6.5 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Weakness
CWE-943
Updated
2026-12-04
NVDCVSS 3.16.5

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.0.0 until 6.13.13, 7.8.14, 8.24.10, and 9.12.2, Mongoose's sanitizeFilter rejects only a small named set of top-level operators and does not recursively inspect undocumented operators such as $_internalSchemaXor and $_internalSchemaCond. Applications that pass attacker-controlled filter keys to queries while relying on sanitizeFilter can therefore accept nested selectors such as $ne or $regex, allowing authentication bypass, disclosure of protected values through boolean queries, or unintended updates and deletions. Applications that construct filters from individual primitive values are not affected by this bypass. This issue is fixed in versions 6.13.13, 7.8.14, 8.24.10, and 9.12.2.

Record
CVE-2026-142595
CVSS 3.1
6.5 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Weakness
CWE-943
Updated
2026-12-03
OSVCVSS 3.16.5

Mongoose: `sanitizeFilter` bypass via MongoDB internal top-level query operators such as `$_internalSchemaXor`

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.0.0 until 6.13.13, 7.8.14, 8.24.10, and 9.12.2, Mongoose's sanitizeFilter rejects only a small named set of top-level operators and does not recursively inspect undocumented operators such as $_internalSchemaXor and $_internalSchemaCond. Applications that pass attacker-controlled filter keys to queries while relying on sanitizeFilter can therefore accept nested selectors such as $ne or $regex, allowing authentication bypass, disclosure of protected values through boolean queries, or unintended updates and deletions. Applications that construct filters from individual primitive values are not affected by this bypass. This issue is fixed in versions 6.13.13, 7.8.14, 8.24.10, and 9.12.2.

Record
CVE-2026-142595
CVSS 3.1
6.5 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Weakness
CWE-943
Updated
2026-12-03
OSVDHI-vjs6-ckck-zy2p-odqtCVSS 3.16.5

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.0.0 until 6.13.13…

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.0.0 until 6.13.13, 7.8.14, 8.24.10, and 9.12.2, Mongoose's sanitizeFilter rejects only a small named set of top-level operators and does not recursively inspect undocumented operators such as $_internalSchemaXor and $_internalSchemaCond. Applications that pass attacker-controlled filter keys to queries while relying on sanitizeFilter can therefore accept nested selectors such as $ne or $regex, allowing authentication bypass, disclosure of protected values through boolean queries, or unintended updates and deletions. Applications that construct filters from individual primitive values are not affected by this bypass. This issue is fixed in versions 6.13.13, 7.8.14, 8.24.10, and 9.12.2.

Record
DHI-vjs6-ckck-zy2p-odqt
CVSS 3.1
6.5 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Updated
2026-12-04
Show 5 more recordsShow less
OSVGHSA-25v4-hrwm-qj9fCVSS 3.16.5

Mongoose: `sanitizeFilter` bypass via MongoDB internal top-level query operators such as `$_internalSchemaXor`

Summary

Mongoose's sanitizeFilter option is meant to block query selector injection. Before this fix, it only refused four top-level operators by name: $jsonSchema, $where, $expr and $text. Any other top-level $ operator was passed to MongoDB unchanged. That includes undocumented internal operators like $_internalSchemaXor and $_internalSchemaCond, which take sub-filters, and sanitizeFilter never inspected those sub-filters. An attacker who controls the keys of a query filter could use them to slip arbitrary query selectors like $ne or $regex past sanitizeFilter.

Details

With sanitizeFilter enabled, Mongoose:

  • wraps any object value containing $ keys in $eq, so { password: { $ne: null } } becomes { password: { $eq: { $ne: null } } };
  • recurses into $and, $or and $nor;
  • throws on $jsonSchema, $where, $expr and $text unless the value is wrapped in mongoose.trusted().

Every other top-level key starting with $ was left alone. MongoDB accepts several internal match expressions at the top level that contain nested filters, for example:

  • $_internalSchemaXor: [filter1, filter2]
  • $_internalSchemaCond: [ifFilter, thenFilter, elseFilter]

Because sanitizeFilter doesn't recurse into these, the nested filters can contain any query selector.

The fix makes sanitizeFilter refuse every top-level key that starts with $, except $and, $or and $nor, which it recurses into, and values wrapped in mongoose.trusted(). Nested $and/$or/$nor filters are checked the same way. This also means sanitizeFilter now refuses:

  • $comment: a user-supplied comment ends up in MongoDB's profiler and logs. Use Query.prototype.comment() instead, which sets the comment outside the filter.
  • $sampleRate, $alwaysTrue, $alwaysFalse, and top-level $ref/$id/$db.

A top-level $-prefixed field name can't be queried with a plain equality filter in the first place: MongoDB rejects { $userId: 42 } with "unknown top level operator". So the fix doesn't prevent any query that previously worked.

Proof of concept

const User = mongoose.model('User', new mongoose.Schema({ username: String, password: String }));
await User.create({ username: 'admin', password: 'hunter2' });

// Attacker controls the filter, e.g. `User.findOne(req.body)`
const login = filter => User.findOne(filter).setOptions({ sanitizeFilter: true });

// Blocked as expected: `$ne` is wrapped in `$eq`, so no match
await login({ username: 'admin', password: { $ne: null } }); // null

// Bypass: login without the password
await login({
  username: 'admin',
  $_internalSchemaXor: [{ password: { $ne: null } }, { $alwaysFalse: 1 }]
}); // { username: 'admin', password: 'hunter2', ... }

// Bypass: extract the password one character at a time
await login({
  username: 'admin',
  $_internalSchemaXor: [{ password: { $regex: '^h' } }, { $alwaysFalse: 1 }]
}); // matches, so password starts with 'h'

Tested against MongoDB 9.0.2. $_internalSchemaCond works the same way, and both operators also work inside $and/$or/$nor.

Impact

Applications are affected if they rely on sanitizeFilter to protect queries whose filter keys come from users. Common patterns are Model.find(req.body) and Model.find({ ...req.query, owner: userId }). An attacker can inject any query selector, which allows:

  • Authentication bypass: match a user record without knowing the password, as in the $ne example above.
  • Data extraction: use $regex as a boolean oracle to recover field values, such as password hashes or tokens, one character at a time.
  • Unintended writes: make updateOne(), deleteMany() and similar operations match documents the attacker shouldn't be able to target.

Applications that build filters from individual values, like { username: req.body.username }, are not affected. sanitizeFilter already wraps those values in $eq, so an attacker can't add…

Record
GHSA-25v4-hrwm-qj9f
CVSS 3.1
6.5 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Weakness
CWE-943
Updated
2026-12-04
OSVCLSA-2026-1795862425No score

TuxCare security update for mongoose (10 CVEs)

TuxCare rebuilt mongoose to address 10 CVEs. Fixed in 8.2.0-tuxcare.1.

Record
CLSA-2026-1795862425
Updated
2026-12-05
OSVCLSA-2026-1796054226No score

TuxCare security update for mongoose (10 CVEs)

TuxCare rebuilt mongoose to address 10 CVEs. Fixed in 8.7.2-tuxcare.1.

Record
CLSA-2026-1796054226
Updated
2026-12-05
OSVCLSA-2026-1796376974No score

TuxCare security update for mongoose (2 CVEs)

TuxCare rebuilt mongoose to address 2 CVEs. Fixed in 9.10.4-tuxcare.3.

Record
CLSA-2026-1796376974
Updated
2026-12-05
OSVCLSA-2026-1796426791No score

TuxCare security update for mongoose (2 CVEs)

TuxCare rebuilt mongoose to address 2 CVEs. Fixed in 9.10.1-tuxcare.2.

Record
CLSA-2026-1796426791
Updated
2026-12-05

The JSON record also has the rest of 2 source descriptions.

History

Recorded by Every CVE

Changes recorded by Every CVE
DayChangedSources
Affected packages, other IDs, published dateOSV
Affected packagesNot recorded
Affected packages, other IDsOSV
Affected packages, other IDsOSV
Affected packages, other IDs, referencesOSV
Published dateEUVD
Affected packages, referencesOSV
Affected packages, key facts, referencesGitHub Advisories, NVD, OSV
Key facts, referencesCVE List
Other IDs, referencesOSV
Other IDs, published dateEUVD, NVD
First indexedCVE List

Upstream dates may differ.

References

Show 5 more referencesShow less
MoveEnter Open