Home/Research/Post

GHSA-xfcm-rmv3-crmq: Mongoose: sanitizeProjection can be bypassed to include fields deselected with `select: false`

  • Severity: HIGH
  • CVE: CVE-2026-142596
  • Ecosystems: npm, npm
  • Packages: mongoose, mongoose

### Summary

Since 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.

Mongoose 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.

### Details

Given:

“`javascript
const User = mongoose.model(‘User’, new Schema({
name: String,
password: { type: String, select: false },
profile: { bio: String, ssn: { type: String, select: false } },
secrets: { type: Map, of: String, select: false },
recoveryCodes: { type: [String], select: false },
tags: [String],
comments: [{ text: String, secret: { type: String, select: false } }]
}));
“`

each of the following returned `select: false` data with `sanitizeProjection` enabled:

| Projection | Why it got through |
| — | — |
| `select(‘-name +password’)` | `+path` was only blocked in inclusive projections |
| `select(‘-+password’)` | Collapsing `-` paths turned it into `+password` |
| `select(‘+secrets’)` | `+path` was not blocked for map paths |
| `select({ name: { $concat: [‘$password’] } })`, `select({ name: [‘$password’] })` | Object and array values are aggregation expressions; only string values were sanitized…

Source: GitHub Security Advisories · 2026-12-04