CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-142595

CVE-2026-142595: NoSQL Query Operator Injection via Incomplete Denylist in Automattic Mongoose sanitizeFilter

Amit Schendel
Amit Schendel
Senior Security Researcher

Dec 4, 2026·12 min read·4 visits

Executive Summary (TL;DR)

An incomplete denylist in Mongoose's sanitizeFilter function permits internal top-level MongoDB operators like $_internalSchemaXor and $_internalSchemaCond to bypass sanitization. Applications passing raw user-supplied objects into Mongoose queries with sanitizeFilter enabled are vulnerable to NoSQL injection, authentication bypass, and blind data exfiltration. Upgrade to Mongoose 6.13.13, 7.8.14, 8.24.10, or 9.12.2.

CVE-2026-142595 is a NoSQL query operator injection vulnerability in Automattic Mongoose caused by an incomplete denylist in the sanitizeFilter query sanitization utility. Prior to the patched versions, sanitizeFilter blocked only four specific top-level operators ($jsonSchema, $where, $expr, and $text), allowing unrecognized or internal MongoDB operators such as $_internalSchemaXor and $_internalSchemaCond to pass through unsanitized. Attackers capable of supplying top-level filter keys can inject arbitrary nested query selectors to bypass authentication, extract sensitive data via boolean inference, or modify database records.

Vulnerability Overview

Automattic Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and translates between objects in code and their representation in MongoDB. Because MongoDB query filters are represented as JavaScript objects rather than raw query strings, web applications that parse JSON input from HTTP requests and pass those objects directly into database query methods expose an attack surface for NoSQL query selector injection.

To address this risk, Mongoose provides a built-in sanitization helper function, sanitizeFilter, as well as a query configuration option (sanitizeFilter: true). This utility is designed to neutralize injected query operators (such as $ne, $gt, or $regex) inside user-supplied filter objects before the query is transmitted to the MongoDB driver. Developers enable this feature when passing unvalidated request payloads into query execution paths like Model.find(), Model.findOne(), Model.updateOne(), or Model.deleteOne().

CVE-2026-142595 (also tracked as GHSA-25v4-hrwm-qj9f) is an improper neutralization vulnerability classified under CWE-943 (Improper Neutralization of Special Elements in Data Query Logic). The flaw resides in how lib/helpers/query/sanitizeFilter.js validates top-level keys in a query filter object. Instead of rejecting all unrecognized top-level keys prefixed with $, the function relied on a static denylist containing only four explicit top-level operators: $jsonSchema, $where, $expr, and $text.

Because of this incomplete denylist, any other top-level MongoDB operator beginning with $—most notably undocumented internal MongoDB evaluation operators such as $_internalSchemaXor and $_internalSchemaCond—bypassed both the rejection check and recursive sanitization. When an application relies on sanitizeFilter to secure user-controlled filter objects, an unauthenticated remote attacker can inject these unhandled top-level operators along with arbitrary nested sub-queries to manipulate query logic, resulting in authentication bypass, unauthorized data extraction, or unintended document updates.

Root Cause Analysis

To understand the root cause of CVE-2026-142595, it is necessary to examine how Mongoose normalizes untrusted filter objects. When sanitizeFilter processes a standard key-value pair where the value is an object containing MongoDB operators—for example, { username: { $ne: null } }—it neutralizes the operator by wrapping the child object inside an explicit $eq selector: { username: { $eq: { $ne: null } } }. When MongoDB evaluates this rewritten query, it searches for a document where the username field is literally an embedded sub-document matching {"$ne": null}, rather than executing $ne as a comparison operator.

However, top-level logical operators in MongoDB cannot be wrapped in $eq without breaking valid query structures. To support complex boolean queries, sanitizeFilter explicitly checks if a top-level key is $and, $or, or $nor. When one of these three logical operators is encountered, sanitizeFilter recursively invokes itself on each element of the operator's array argument, ensuring that all nested field selectors within the logical group are also wrapped in $eq or validated.

The vulnerability occurs in the conditional branch immediately following the check for $and, $or, and $nor. In unpatched versions of Mongoose, the code checked whether the current key matched one of four known dangerous top-level operators ($jsonSchema, $where, $expr, $text) and threw a MongooseError if a match occurred. Any other key starting with $ fell through to the general field-handling logic.

In the general field-handling logic, sanitizeFilter inspects the value associated with the key. If the value is an array of sub-documents—which is the required syntax for internal MongoDB operators like $_internalSchemaXor ([subQuery1, subQuery2]) and $_internalSchemaCond ([ifExpr, thenExpr, elseExpr])—sanitizeFilter performs no modification on array values that are not recognized as $and, $or, or $nor. Specifically, the helper function hasDollarKeys checks Object.keys(val), which for an array returns numeric indices ("0", "1", etc.) rather than $ keys. Consequently, the entire array of attacker-controlled sub-queries is left intact.

Furthermore, this flaw is reachable both at the root of the filter object and recursively inside valid logical operators. Because $or, $and, and $nor recursively call sanitizeFilter on their child elements, an attacker can place $_internalSchemaXor inside an $or array if the target application constructs a top-level $or query around user input.

Code Analysis

The core vulnerability and its remediation are located in lib/helpers/query/sanitizeFilter.js, with supporting changes in lib/cast.js and lib/query.js. In commits 34e76947cc8a9ceb916c233aec01aea060bc3dba (for 8.x/9.x), 3e5f4c8b30ef42db1ab9f2794dc77c95f21d3835 (for 7.x), and 4627d2fc572a943ee7afe26a1bcebe493dbd2508 (for 6.x), the Mongoose maintainers replaced the four-element operator denylist with a fail-closed prefix check.

Below is the diff for lib/helpers/query/sanitizeFilter.js showing the transition from the explicit denylist to a general prefix check on key[0] === '$'. If a developer legitimately intends to pass a top-level $ operator through sanitizeFilter, they must explicitly mark the sub-object using mongoose.trusted(), which sets the trustedSymbol property on the value and causes sanitizeFilter to skip it at the start of the loop.

--- a/lib/helpers/query/sanitizeFilter.js
+++ b/lib/helpers/query/sanitizeFilter.js
@@ -24,7 +24,7 @@ module.exports = function sanitizeFilter(filter) {
     if (key === '$and' || key === '$or' || key === '$nor') {
       sanitizeFilter(value);
       continue;
-    } else if (key === '$jsonSchema' || key === '$where' || key === '$expr' || key === '$text') {
+    } else if (key[0] === '$') {
       throw new MongooseError(key + ' is not allowed with sanitizeFilter');
     }

In addition to the sanitizeFilter.js change, the patch updated lib/cast.js to properly handle how top-level operators interact with schema path casting and strict query modes. Prior to the fix, cast() only had special-case logic for $and, $or, $nor, $where, and $comment. Other top-level $ operators could be misinterpreted as schema field paths during casting. The patch uses isOperator(path) to recognize any top-level $ key as an operator and skip schema path casting for it:

--- a/lib/cast.js
+++ b/lib/cast.js
@@ -105,6 +105,11 @@ module.exports = function cast(schema, obj, options, context) {
     } else if (path === '$comment' && !schema.paths.hasOwnProperty('$comment')) {
       val = castString(val, path);
       obj[path] = val;
+    } else if (isOperator(path)) {
+      // Pass through other top-level operators, like `$jsonSchema`, without casting.
+      // MongoDB doesn't allow querying top-level `$` fields, so these can't be paths
+      // and `strict` or `strictQuery` shouldn't strip them.
+      continue;
     } else {
       if (!schema) {

Finally, the patch hardened isEmptyFilter() in lib/query.js, which supports Mongoose's requireFilter option (used to prevent accidental mass updates or deletions caused by empty filter objects). The updated isEmptyFilter() function checks whether a filter consists solely of no-op or always-matching operators like $comment or $alwaysTrue, ensuring that a filter such as { $comment: 'test' } or { $alwaysTrue: 1 } is still treated as empty when requireFilter is enabled.

> [!NOTE] > Fix Completeness Assessment: Replacing the explicit operator denylist with key[0] === '$' in sanitizeFilter.js provides a complete fix against top-level operator smuggling. Because MongoDB syntax requires all query operators to begin with the $ character, blocking any key where key[0] === '$' (other than the recursively sanitized $and, $or, and $nor arrays) prevents both currently undocumented internal MongoDB operators and any future operators introduced in subsequent MongoDB server releases from bypassing sanitizeFilter.

Exploitation

Exploiting CVE-2026-142595 requires an application endpoint that accepts structured user input (typically parsed from a JSON HTTP request body or nested URL query parameters via middleware such as express.json() or qs) and passes the resulting object directly as the filter argument to a Mongoose query while relying on sanitizeFilter for protection. No prior authentication is needed if the vulnerable query is exposed on a public route such as an authentication endpoint or password reset handler.

Consider a Node.js and Express login handler that passes req.body directly into User.findOne() with the sanitizeFilter: true option enabled:

app.post('/api/login', async (req, res) => {
  try {
    // Vulnerable pattern: passing raw req.body object and relying on sanitizeFilter
    const user = await User.findOne(req.body).setOptions({ sanitizeFilter: true });
    if (!user) {
      return res.status(401).json({ error: 'Invalid credentials' });
    }
    return res.json({ status: 'authenticated', user: user.username });
  } catch (err) {
    return res.status(500).json({ error: err.message });
  }
});

If an attacker submits a standard NoSQL injection payload such as {"username": "admin", "password": {"$ne": ""}}, sanitizeFilter rewrites the password filter to {"password": {"$eq": {"$ne": ""}}}, causing the authentication attempt to fail. However, by substituting the password key with the undocumented MongoDB top-level operator $_internalSchemaXor, the attacker completely bypasses sanitizeFilter.

$_internalSchemaXor takes an array of query expressions and matches a document if an odd number (exclusive-OR) of the sub-queries evaluate to true. By pairing a targeted condition with { "$alwaysFalse": 1 }, the XOR expression evaluates to true if and only if the first sub-query evaluates to true:

POST /api/login HTTP/1.1
Host: target.example.com
Content-Type: application/json
 
{
  "username": "admin",
  "$_internalSchemaXor": [
    { "password": { "$ne": "invalid_password" } },
    { "$alwaysFalse": 1 }
  ]
}

Beyond authentication bypass, an attacker can perform blind character-by-character data extraction of sensitive fields (such as password hashes, API keys, or session reset tokens) using $regex inside $_internalSchemaXor or $_internalSchemaCond. The official regression test suite in the Mongoose repository demonstrates both payloads:

// Payload 1: Boolean inference via $_internalSchemaXor
const xorPayload = {
  username: 'admin',
  $_internalSchemaXor: [
    { pwd: { $regex: '^s3cr3t' } },
    { $alwaysFalse: 1 }
  ]
};
 
// Payload 2: Conditional evaluation via $_internalSchemaCond
const condPayload = {
  $_internalSchemaCond: [
    { $alwaysTrue: 1 },
    { pwd: { $regex: '^s3cr3t' } },
    { $alwaysFalse: 1 }
  ]
};

When xorPayload or condPayload is evaluated by MongoDB, the server returns the admin user document if the pwd field begins with the prefix s3cr3t, and returns null otherwise. By iterating through character sets and observing the HTTP status code or response differential (e.g., 200 OK vs 401 Unauthorized), the attacker can reconstruct the entire secret value.

Impact Assessment

CVE-2026-142595 is assigned a CVSS v3.1 base score of 6.5 (Medium) with the vector CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N. The Attack Vector is Network (AV:N) and Privileges Required is None (PR:N), reflecting that vulnerable endpoints can be targeted remotely over HTTP/HTTPS without prior authentication. The Attack Complexity is rated High (AC:H) because successful exploitation depends on a specific architectural prerequisite: the target application must pass attacker-controlled object keys directly into a query filter and depend on sanitizeFilter rather than casting individual fields to scalar types.

The primary security impact is High Confidentiality loss (C:H). As demonstrated by the $_internalSchemaXor and $_internalSchemaCond mechanisms, an attacker who controls top-level filter keys can inject $regex, $gt, $lt, or $ne selectors against arbitrary fields on the queried collection. Even when an endpoint returns only a boolean indicator or a limited projection of fields, differential responses allow the attacker to extract unprojected sensitive columns (such as bcrypt hashes, MFA secrets, or email reset tokens) from any document in the collection.

The Integrity impact is rated Low (I:L). When sanitizeFilter is used to sanitize filters passed to write or delete operations—such as Model.updateOne(), Model.findOneAndUpdate(), or Model.deleteOne()—an attacker can broaden the query criteria using $_internalSchemaXor to match and modify or delete records belonging to other users. Furthermore, when a login endpoint relies on Model.findOne(req.body) with sanitizeFilter, the attacker can bypass authentication entirely and assume the identity of any user in the database, including administrative accounts.

According to current threat intelligence, the Exploit Prediction Scoring System (EPSS) score for CVE-2026-142595 is 0.00562 (48.20th percentile), and the vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. While no standalone weaponized exploit modules exist in Metasploit or Exploit-DB, functional proof-of-concept payloads are publicly documented in the official Mongoose commit history and security advisory.

Remediation

The primary remediation is to upgrade the mongoose package to a patched release that enforces fail-closed rejection of unrecognized top-level $ operators in sanitizeFilter. Automattic has backported the fix across all supported major release branches:

  • Mongoose 6.x: Upgrade to version 6.13.13 or later.
  • Mongoose 7.x: Upgrade to version 7.8.14 or later.
  • Mongoose 8.x: Upgrade to version 8.24.10 or later.
  • Mongoose 9.x: Upgrade to version 9.12.2 or later.

> [!NOTE] > After upgrading to a patched version, any application code that intentionally passes top-level operators other than $and, $or, or $nor into sanitizeFilter will throw a MongooseError. If a top-level operator is legitimately required by the application logic, wrap its value in mongoose.trusted() (for example, { $expr: mongoose.trusted({ $gt: ['$a', '$b'] }) }) so that sanitizeFilter recognizes it as developer-defined.

In addition to upgrading Mongoose, development teams should eliminate the anti-pattern of passing raw request objects (req.body, req.query, or req.params) directly into Mongoose query methods. Applications should explicitly destructure expected parameters and coerce them to primitive scalar types (such as String, Number, or Boolean) or validate them against a strict input schema using libraries such as Zod or Joi before constructing the database filter:

// Secure query construction pattern: explicit extraction and type coercion
app.post('/api/login', async (req, res) => {
  if (typeof req.body?.username !== 'string' || typeof req.body?.password !== 'string') {
    return res.status(400).json({ error: 'Invalid input types' });
  }
 
  const user = await User.findOne({
    username: req.body.username,
    password: req.body.password
  });
  // ...
});

For environments where immediate dependency patching is delayed, security teams can deploy two temporary mitigations. First, implement an Express middleware that recursively inspects req.body and req.query and strips or rejects any JSON property key beginning with $. Second, deploy Web Application Firewall (WAF) rules at the reverse proxy layer to inspect inbound HTTP JSON payloads and block requests containing `

Official Patches

AutomatticGitHub Security Advisory GHSA-25v4-hrwm-qj9f for Mongoose sanitizeFilter bypass
AutomatticMongoose 9.12.2 Release Notes
AutomatticMongoose 8.24.10 Release Notes
AutomatticMongoose 7.8.14 Release Notes

Fix Analysis (4)

Technical Appendix

CVSS Score
6.5/ 10
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
EPSS Probability
0.56%
Top 52% most exploited

Affected Systems

Automattic Mongoose (npm package: mongoose) 6.0.0 through 6.13.12Automattic Mongoose (npm package: mongoose) 7.0.0 through 7.8.13Automattic Mongoose (npm package: mongoose) 8.0.0 through 8.24.9Automattic Mongoose (npm package: mongoose) 9.0.0 through 9.12.1

Affected Versions Detail

Product
Affected Versions
Fixed Version
mongoose
Automattic
>= 6.0.0, < 6.13.136.13.13
mongoose
Automattic
>= 7.0.0, < 7.8.147.8.14
mongoose
Automattic
>= 8.0.0, < 8.24.108.24.10
mongoose
Automattic
>= 9.0.0, < 9.12.29.12.2
AttributeDetail
CVE / Advisory IDCVE-2026-142595 / GHSA-25v4-hrwm-qj9f
Weakness ClassCWE-943: Improper Neutralization of Special Elements in Data Query Logic
CVSS v3.1 Score6.5 Medium (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N)
EPSS Score0.56% (48.20th Percentile)
Attack VectorNetwork (NoSQL operator smuggling via $_internalSchemaXor / $_internalSchemaCond)
Primary ImpactAuthentication bypass, blind data extraction via regex/boolean inference, and unauthorized document modification
Exploit StatusProof-of-Concept available in upstream commit test suite; not in CISA KEV
Patched VersionsMongoose 6.13.13, 7.8.14, 8.24.10, and 9.12.2

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
T1059Command and Scripting Interpreter
Execution
T1078Valid Accounts
Privilege Escalation
T1552Unsecured Credentials
Credential Access
T1565Data Manipulation
Impact
CWE-943
Improper Neutralization of Special Elements in Data Query Logic

The application constructs all or part of a data query using externally-influenced input from an upstream component, but fails to neutralize or incorrectly neutralizes special elements that could modify the intended query logic.

Known Exploits & Detection

GitHubOfficial Mongoose fix commit containing reproduction test cases using $_internalSchemaXor and $_internalSchemaCond to smuggle $regex and $alwaysFalse operators past sanitizeFilter.

Vulnerability Timeline

CVE-2026-142595 and GitHub Security Advisory GHSA-25v4-hrwm-qj9f published; patched Mongoose versions 6.13.13, 7.8.14, 8.24.10, and 9.12.2 released.
2026-12-02
NVD and OSV vulnerability records updated with CVSS v3.1 assessment and affected version ranges.
2026-12-03

References & Sources

  • [1]GitHub Security Advisory GHSA-25v4-hrwm-qj9f
  • [2]NVD Vulnerability Detail: CVE-2026-142595
  • [3]CVE.org Record: CVE-2026-142595
  • [4]GitHub Commit 34e76947cc8a9ceb916c233aec01aea060bc3dba (Mongoose 8.x/9.x Fix)
  • [5]GitHub Commit 3e5f4c8b30ef42db1ab9f2794dc77c95f21d3835 (Mongoose 7.x Fix)
  • [6]GitHub Commit 4627d2fc572a943ee7afe26a1bcebe493dbd2508 (Mongoose 6.x Fix)
  • [7]GitHub Commit c6a4c95f9b15d81a352f2934c91b64ece583c2db
  • [8]Mongoose Release 9.12.2
  • [9]Mongoose Release 8.24.10
  • [10]Mongoose Release 7.8.14
  • [11]CVEListV5 JSON Definition for CVE-2026-142595

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•30 minutes ago•CVE-2026-142596
7.5

CVE-2026-142596: Projection Sanitization Bypass and Schema-Level Exclusion Disclosure in Mongoose

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.

Amit Schendel
Amit Schendel
3 views•10 min read
•about 2 hours ago•CVE-2026-142610
7.5

CVE-2026-142610: Resource Exhaustion Denial of Service via Arbitrary-Precision Math in Laravel Framework

CVE-2026-142610 (GHSA-c25c-x5r7-2v5m) is an allocation of resources without limits or throttling vulnerability (CWE-770) in the Laravel Framework (`laravel/framework`). The flaw exists in how Laravel passes user-supplied numeric strings to the `brick/math` arbitrary-precision arithmetic library during specific validation rules (`multiple_of`, `gt`, `gte`, `lt`, `lte`) and Eloquent model decimal casting (`decimal:X`). When an unauthenticated remote attacker supplies a numeric string formatted in scientific notation with a large positive or negative exponent (e.g., `1e-100000000`), `Brick\Math\BigDecimal` and `Brick\Math\BigNumber` attempt to expand the full numeric representation in memory. This operation immediately exhausts the PHP process memory limit and causes high CPU utilization, terminating worker threads and resulting in an application-layer Denial of Service (DoS). The vulnerability is remediated in Laravel versions 12.74.0 and 13.44.1.

Alon Barad
Alon Barad
6 views•11 min read
•about 4 hours ago•CVE-2026-137198
8.3

CVE-2026-137198: Argument Injection in Node.js cross-spawn via Improper Backslash Escaping on Windows

CVE-2026-137198 is a high-severity argument injection vulnerability (CWE-88) affecting the Node.js cross-spawn library in versions 6.0.6 and 7.0.4 through 7.0.6. On Windows systems, when commands are routed through cmd.exe (including batch files and npm cmd-shims in node_modules/.bin), cross-spawn fails to properly double contiguous sequences of two or more backslashes preceding a double quote or at the end of an argument. This parsing failure causes the argument's closing quotation mark to be escaped as a literal character, allowing attacker-controlled input to break out of quotation encapsulation and inject arbitrary command-line arguments or consume subsequent arguments.

Amit Schendel
Amit Schendel
10 views•13 min read
•about 5 hours ago•CVE-2026-144292
7.6

CVE-2026-144292: Client-Side Template Injection and Cross-Site Scripting in DOMPurify via SAFE_FOR_TEMPLATES Bypass

DOMPurify prior to version 3.5.0 contains a sanitization bypass in the SAFE_FOR_TEMPLATES configuration mode. By embedding split template expression delimiters across invalid nested <form> elements, an attacker can evade character data scrubbing during initial sanitization. When the sanitized markup is subsequently re-parsed into the DOM via innerHTML, browser HTML5 parsing rules strip the nested <form> tags and concatenate the split text nodes, reconstructing executable template expressions that trigger Cross-Site Scripting (XSS) in client-side template engines.

Amit Schendel
Amit Schendel
7 views•11 min read
•about 6 hours ago•CVE-2026-74870
3.3

CVE-2026-74870: Cleartext Exposure of Hardware-Derived Cryptographic Peppers in openssl_encrypt

CVE-2026-74870 is an information exposure vulnerability in the Python package openssl_encrypt affecting versions 1.4.7 and earlier. The diagnostic CLI subcommands 'hsm fido2-test' and 'hsm onlykey-test' unconditionally write full derived hardware cryptographic peppers as hexadecimal strings to standard error. Additionally, the FIDO2 hardware pepper plugin logs unredacted pseudo-random function (PRF) output to debug logs and user-facing error messages. While the diagnostic pepper is bound to a random per-invocation test salt and cannot directly decrypt stored files, the behavior exposes raw hardware-derived key material to terminal scrollbacks, session recordings, and CI/CD logs.

Alon Barad
Alon Barad
6 views•10 min read
•about 7 hours ago•CVE-2026-142624
6.5

CVE-2026-142624: Validation Logic Bypass via In-Band Sentinel Value Collision in Laravel Framework

A validation logic bypass vulnerability exists in the Laravel Framework validation subsystem prior to versions 12.72.0 and 13.43.0. When validating nested attributes or wildcard arrays using the 'sometimes' rule, the framework uses the literal string '__missing__' as an in-band sentinel value to detect absent keys. An attacker who submits the literal string '__missing__' as the value for a nested attribute causes the validator to misinterpret the field as omitted, bypassing all subsequent validation rules while still returning the unvalidated string in the validated dataset.

Amit Schendel
Amit Schendel
11 views•11 min read