CVE-2026-142595: Mongoose: `sanitizeFilter` bypass via MongoDB internal top-level query operators such as `$_internalSchemaXor`
Mongoose’s sanitizeFilter option is meant to block query selector injection. Before this fix, it only refused four top-level operators by name: $jsonSchema, $where, $expr and $text. Any other top-level $ operator was passed to MongoDB unchanged. That includes undocumented internal operators like $_internalSchemaXor and $_internalSchemaCond, which take sub-filters, and sanitizeFilter never inspected those sub-filters. An attacker who controls the keys of a query filter could use them to slip arbitrary query selectors like $ne or $regex past sanitizeFilter.
References
- github.com/Automattic/mongoose/commit/34e76947cc8a9ceb916c233aec01aea060bc3dba
- github.com/Automattic/mongoose/commit/3e5f4c8b30ef42db1ab9f2794dc77c95f21d3835
- github.com/Automattic/mongoose/commit/4627d2fc572a943ee7afe26a1bcebe493dbd2508
- github.com/Automattic/mongoose/commit/c6a4c95f9b15d81a352f2934c91b64ece583c2db
- github.com/Automattic/mongoose/releases/tag/7.8.14
- github.com/Automattic/mongoose/releases/tag/8.24.10
- github.com/Automattic/mongoose/releases/tag/9.12.2
- github.com/Automattic/mongoose/security/advisories/GHSA-25v4-hrwm-qj9f
- github.com/advisories/GHSA-25v4-hrwm-qj9f
- nvd.nist.gov/vuln/detail/CVE-2026-142595
Code Behaviors & Features
Detect and mitigate CVE-2026-142595 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →