CVE-2026-142596: CVE-2026-142596: Projection Sanitization Bypass and Schema-Level Exclusion Disclosure in Mongoose
CVE-2026-142596: Projection Sanitization Bypass and Schema-Level Exclusion Disclosure in Mongoose Vulnerability ID: CVE-2026-142596 CVSS Score: 7.5 Published: 2026-12-04 A projection sanitization and schema path exc
CVE-2026-142596: Projection Sanitization Bypass and Schema-Level Exclusion Disclosure in Mongoose
Vulnerability ID: CVE-2026-142596
CVSS Score: 7.5
Published: 2026-12-04
A projection sanitization and schema path exclusion bypass vulnerability exists in Mongoose versions 8.5.0 through 8.24.9 and 9.0.0 through 9.12.1. Due to insufficient validation of MongoDB projection syntax in sanitizeProjection and applyPaths, attackers supplying untrusted projection inputs to queries can force the retrieval of sensitive schema fields configured with select: false, such as password hashes, reset tokens, and multi-factor authentication secrets.
TL;DR
Mongoose versions 8.5.0β8.24.9 and 9.0.0β9.12.1 allow remote attackers to bypass sanitizeProjection and schema-level select: false field exclusions via crafted projection operators, nested exclusions, parent path selections, and prototype overrides, resulting in unauthorized disclosure of sensitive database fields.
β οΈ Exploit Status: POC
Technical Details
- CVE / GHSA ID: CVE-2026-142596 / GHSA-xfcm-rmv3-crmq
- Weakness Class: CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
- CVSS v3.1 Score: 7.5 High (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N)
- Attack Vector: Network (Crafted MongoDB Query Projections)
- Primary Impact: Disclosure of schema fields marked select: false (passwords, tokens, PII)
- EPSS Score: 0.69% (54th Percentile)
- Exploit Status: Proof-of-Concept (Regression tests in official commit)
- Patched Versions: Mongoose 8.24.10 and 9.12.2
Affected Systems
- Mongoose ODM (npm package: mongoose) versions 8.5.0 through 8.24.9
- Mongoose ODM (npm package: mongoose) versions 9.0.0 through 9.12.1
-
mongoose: >= 8.5.0, < 8.24.10 (Fixed in:
8.24.10) -
mongoose: >= 9.0.0, < 9.12.2 (Fixed in:
9.12.2)
Code Analysis
Commit: c369da4
Hardens sanitizeProjection and applyPaths against expression, parent path, positional, prototype, and discriminator bypasses in Mongoose 8.x.
Commit: c5483b7
Hardens sanitizeProjection and applyPaths against expression, parent path, positional, prototype, and discriminator bypasses in Mongoose 9.x.
Exploit Details
- GitHub (Official Mongoose Fix Commit 8.x Test Suite): Contains comprehensive proof-of-concept test cases in test/query.sanitizeProjection.test.js demonstrating expression, slice, parent path, positional, and prototype bypasses.
- GitHub (Official Mongoose Fix Commit 9.x Test Suite): Fix commit and reproduction test suite for the Mongoose 9.x branch.
Mitigation Strategies
- Upgrade Mongoose to the patched release (8.24.10 or 9.12.2) to enforce strict operator allowlisting in sanitizeProjection and proper path stripping in applyPaths.
- Enforce strict application-level field allowlisting for any API endpoints that allow clients to specify returned fields.
- Reject object-based or JSON-parsed projections from untrusted requests; restrict client field selection to simple comma- or space-separated leaf field strings validated against an explicit allowlist.
- Avoid storing high-value secrets (such as password hashes, MFA keys, and reset tokens) in the same MongoDB collection/schema as publicly queryable user profile documents when possible.
Remediation Steps:
- Audit package.json and lockfiles (package-lock.json, yarn.lock, pnpm-lock.yaml) to identify Mongoose versions within >= 8.5.0, < 8.24.10 or >= 9.0.0, < 9.12.2.
- Run
npm install [email protected](for 8.x) ornpm install [email protected](for 9.x) to apply the security patch. - Search the application codebase for uses of
.select(),.find(filter, projection),.findOne(filter, projection), andsanitizeProjectionwhere user input (such asreq.queryorreq.body) is passed. - Verify that queries on base models with discriminators properly enforce schema-level exclusions after upgrading.
References
- GitHub Security Advisory: GHSA-xfcm-rmv3-crmq
- Mongoose 8.x Patch Commit (c369da407ee8bea907bb5af7bb94ce5deeb3e0e4)
- Mongoose 9.x Patch Commit (c5483b71438ececde3a272feef65e14666614093)
- Mongoose Release v8.24.10
- Mongoose Release v9.12.2
- CVE.org Record: CVE-2026-142596
- NIST NVD Vulnerability Detail: CVE-2026-142596
- CVE JSON v5 Record: CVE-2026-142596
Read the full report for CVE-2026-142596 on our website for more details including interactive diagrams and full exploit analysis.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.