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-125119

CVE-2026-125119: Connection-Level Filter Sanitization Bypass in Mongoose ODM

Amit Schendel
Amit Schendel
Senior Security Researcher

Nov 10, 2026·9 min read·3 visits

Executive Summary (TL;DR)

Mongoose versions 6.0.0 through 9.11.3 ignore the `sanitizeFilter: true` option when passed to `mongoose.connect()` or `mongoose.createConnection()`. Attackers can supply MongoDB query operators (such as `{"$ne": null}`) in user input to bypass authentication and extract or modify database records.

A flaw in Mongoose's query condition casting pipeline causes the `sanitizeFilter` configuration option to be silently ignored when defined at the connection level via `mongoose.connect()` or `mongoose.createConnection()`. Because internal query methods inspect `Connection.options` rather than `Connection.config`, applications relying on connection-scoped filter sanitization remain vulnerable to NoSQL query selector injection (CWE-943), permitting authentication bypass and unauthorized data access across Mongoose versions 6.x through 9.x.

Vulnerability Overview

Mongoose is the standard Object Data Modeling (ODM) library for MongoDB and Node.js. It provides schema validation, type casting, and query building abstractions over the native MongoDB driver. Because MongoDB queries are structured as BSON/JSON documents rather than parameterized strings, web applications that parse JSON request bodies (e.g., via express.json()) or nested query strings directly into Mongoose query methods expose an attack surface for NoSQL query selector injection.

To mitigate this class of vulnerability, Mongoose 6.0.0 introduced the sanitizeFilter option. When enabled, sanitizeFilter recursively inspects query filter objects and neutralizes properties beginning with the $ prefix (such as $ne, $gt, $in, $regex, or $where) by wrapping them in an explicit $eq operator. This forces MongoDB or Mongoose's schema caster to evaluate the injected object as a literal value rather than a query operator.

CVE-2026-125119 (GHSA-gg4r-jv3p-qx3c), classified under CWE-943 (Improper Neutralization of Special Elements in Data Query Logic), occurs because Mongoose fails to propagate or inspect the sanitizeFilter setting when configured at the database connection level. When a developer passes { sanitizeFilter: true } into mongoose.connect() or mongoose.createConnection(), the configuration is stored in Connection.config, whereas the query execution pipeline exclusively checks Connection.options and the global Mongoose instance.

Consequently, any application relying on connection-level configuration to neutralize untrusted query inputs executes queries without sanitization. Even though inspecting the connection state via conn.get('sanitizeFilter') returns true, all read, write, and delete operations bound to that connection remain exposed to operator injection, enabling unauthenticated authentication bypass and arbitrary document disclosure.

Root Cause Analysis

The root cause of CVE-2026-125119 is a state storage discrepancy between how connection options are initialized in NativeConnection and how they are retrieved in Query and cast. In Mongoose, sanitizeFilter can be configured at three distinct hierarchy levels: globally via mongoose.set('sanitizeFilter', true), per-connection via mongoose.connect(uri, { sanitizeFilter: true }), or per-query via .sanitizeFilter(true).

When a connection is instantiated through mongoose.connect(uri, options) or mongoose.createConnection(uri, options), Mongoose invokes NativeConnection.prototype.createClient(). During this initialization routine, Mongoose separates driver-level MongoDB options from Mongoose-specific connection configuration settings. The sanitizeFilter property is extracted and stored inside the connection's this.config object (this.config.sanitizeFilter), leaving this.options.sanitizeFilter undefined.

When a query is executed on a model bound to that connection, Mongoose invokes Query.prototype._castConditions() and Query.prototype.cast() in lib/query.js. Prior to the patch, both methods resolved the active sanitizeFilter setting by checking this.model.db.options.sanitizeFilter (the connection options), this.model.base.options.sanitizeFilter (the global Mongoose options), and this._mongooseOptions.sanitizeFilter (the per-query options). Neither method checked this.model.db.config.sanitizeFilter.

Because this.model.db.options.sanitizeFilter was undefined, the conditional check skipped calling sanitizeFilter(this._conditions). Additionally, a secondary defect existed in lib/cast.js: when casting an array value supplied for a non-array schema path (such as passing password: ['secret'] to a String field), Mongoose implicitly converts the filter into a { $in: ['secret'] } operator query. Because Query.prototype.cast() failed to pass the connection's sanitizeFilter flag down into the opts object consumed by cast(), this implicit $in selector conversion also bypassed sanitization.

Code Analysis

The vulnerability was addressed across four release branches (6.x, 7.x, 8.x, and 9.x) by updating lib/query.js and lib/cast.js to include model.db.config in the option resolution chain and blocking implicit $in array casting when sanitizeFilter is active.

In lib/query.js, Query.prototype._castConditions and Query.prototype.cast were modified to check this.model?.db.config?.sanitizeFilter first using nullish coalescing (??) before falling back to db.options, base.options, and _mongooseOptions:

// File: lib/query.js
Query.prototype._castConditions = function() {
  // BEFORE (Vulnerable): Checked db.options, ignoring db.config
  // let sanitizeFilterOpt = undefined;
  // if (this.model?.db.options?.sanitizeFilter != null) {
  //   sanitizeFilterOpt = this.model.db.options.sanitizeFilter;
  // } else if (this.model?.base.options?.sanitizeFilter != null) {
  //   sanitizeFilterOpt = this.model.base.options.sanitizeFilter;
  // } else {
  //   sanitizeFilterOpt = this._mongooseOptions.sanitizeFilter;
  // }
 
  // AFTER (Patched): Prioritizes model.db.config.sanitizeFilter
  const sanitizeFilterOpt = this.model?.db.config?.sanitizeFilter ??
    this.model?.db.options?.sanitizeFilter ??
    this.model?.base.options.sanitizeFilter ??
    this._mongooseOptions.sanitizeFilter;
 
  if (sanitizeFilterOpt) {
    sanitizeFilter(this._conditions);
  }
  // ...
};

Similarly, Query.prototype.cast in lib/query.js was updated so that the resolved sanitizeFilter boolean is attached to the opts object passed into cast(model.schema, obj, opts, this):

// File: lib/query.js
Query.prototype.cast = function(model, obj) {
  obj || (obj = {});
  model || (model = this.model);
 
  const opts = { strict: this.options.strict };
  if ('strictQuery' in this._mongooseOptions) {
    opts.strictQuery = this._mongooseOptions.strictQuery;
  }
 
  // BEFORE (Vulnerable): Only checked per-query _mongooseOptions
  // if ('sanitizeFilter' in this._mongooseOptions) {
  //   opts.sanitizeFilter = this._mongooseOptions.sanitizeFilter;
  // }
 
  // AFTER (Patched): Resolves from connection config, connection options, global, or query
  opts.sanitizeFilter = model.db.config?.sanitizeFilter ??
    model.db.options?.sanitizeFilter ??
    model.base.options.sanitizeFilter ??
    this._mongooseOptions.sanitizeFilter;
 
  try {
    return cast(model.schema, obj, opts, this);
  } catch (err) {
    // ...
  }
};

In lib/cast.js, the patch prevents Mongoose from implicitly converting an array value into an $in operator when targeting a scalar schema path if options.sanitizeFilter is truthy. Furthermore, in the 6.x branch (commit b8970c25998c23fbccd17f76c0398b902ff4911d), the internal castQuery(query) helper in lib/query.js was updated to call query._castConditions() instead of directly invoking query.cast(query.model), ensuring that condition sanitization executes prior to schema casting across all legacy v6 execution paths.

// File: lib/cast.js
// BEFORE (Vulnerable): Implicitly cast array to $in regardless of sanitizeFilter
// } else if (Array.isArray(val) && ['Buffer', 'Array'].indexOf(schematype.instance) === -1) {
 
// AFTER (Patched): Disables implicit array-to-$in casting when sanitizeFilter is enabled
} else if (Array.isArray(val) && ['Buffer', 'Array'].indexOf(schematype.instance) === -1 && !options.sanitizeFilter) {
  const casted = [];
  const valuesArray = val;
  // ...

The fix completely resolves the disconnect between Connection.config and query casting, including for child connections derived via conn.useDb(), which inherit the parent connection's config object. However, developers should remain aware that sanitizeFilter only sanitizes query filter conditions; it does not sanitize aggregation pipelines (Model.aggregate()) or raw commands passed directly to the underlying MongoDB driver.

Exploitation

Exploiting CVE-2026-125119 requires an application endpoint that accepts structured user input—such as a JSON request body or URL query parameters parsed by qs—and passes properties from that input into a Mongoose query filter on a connection configured with { sanitizeFilter: true }. No authentication or special privileges are required if the vulnerable query resides on a public route such as a login, password reset, or search endpoint.

Consider an Express.js authentication endpoint where the developer configures sanitizeFilter: true inside mongoose.connect() and passes req.body.username and req.body.password directly to User.findOne():

const express = require('express');
const mongoose = require('mongoose');
 
const app = express();
app.use(express.json());
 
mongoose.connect('mongodb://127.0.0.1:27017/app', {
  sanitizeFilter: true
});
 
const User = mongoose.model('User', new mongoose.Schema({
  username: String,
  password: String
}));
 
app.post('/api/login', async (req, res) => {
  const user = await User.findOne({
    username: req.body.username,
    password: req.body.password
  });
  if (!user) return res.status(401).json({ error: 'Unauthorized' });
  return res.json({ authenticatedAs: user.username });
});

To bypass authentication, an attacker sends an HTTP POST request with Content-Type: application/json containing a nested MongoDB operator object ({"$ne": null}) in the password field, or an array of guessed values (["admin", "123456"]) to trigger implicit $in casting:

POST /api/login HTTP/1.1
Host: example.com
Content-Type: application/json
 
{
  "username": "admin",
  "password": {
    "$ne": null
  }
}

On unpatched Mongoose versions, User.findOne() ignores the connection's sanitizeFilter setting and sends { username: "admin", password: { $ne: null } } directly to MongoDB. MongoDB matches the admin user document because its password field is not null, logging the attacker in without knowing the password. On patched versions, sanitizeFilter rewrites the filter to { username: "admin", password: { $eq: { $ne: null } } }, which immediately fails schema casting for the String path and throws a CastError.

Impact Assessment

The security impact of CVE-2026-125119 is rated High with a CVSS v3.1 base score of 7.5 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N). The vulnerability is remotely exploitable over the network (AV:N) with low attack complexity (AC:L), requiring neither privileges (PR:N) nor user interaction (UI:N).

The failure to enforce sanitizeFilter affects the entire suite of Mongoose query operations that process filter conditions. As verified by the regression test suites introduced in the patch commits, the affected operations include:

  • Read Operations: find(), findOne(), count(), countDocuments(), distinct(), and find().cursor()
  • Update Operations: updateOne(), updateMany(), replaceOne(), findOneAndUpdate(), and findOneAndReplace()
  • Delete Operations: deleteOne(), deleteMany(), findOneAndDelete(), and findOneAndRemove()
  • Expression Operators: Queries containing $expr operators, which are supposed to be rejected with an error ($expr is not allowed with sanitizeFilter) when sanitizeFilter is active

In read contexts, attackers can bypass login gates or perform boolean-based and regular-expression-based ($regex) data extraction to enumerate sensitive fields such as password hashes, API keys, or reset tokens. While the baseline CVSS vector reflects Confidentiality Impact as High (C:H) and Integrity Impact as None (I:N), applications that pass user-controlled filter keys into write or delete methods (updateOne, deleteMany, findOneAndDelete) also face unauthorized data modification or destruction, as injected { "$ne": null } selectors can cause single-record updates or deletions to match unintended records.

Remediation

To remediate CVE-2026-125119, upgrade Mongoose to the patched release corresponding to your active major version branch:

  • Mongoose 9.x: Upgrade to 9.11.4 or later
  • Mongoose 8.x: Upgrade to 8.24.7 or later
  • Mongoose 7.x: Upgrade to 7.8.13 or later
  • Mongoose 6.x: Upgrade to 6.13.12 or later

> [!NOTE] > Applications that configure sanitizeFilter globally via mongoose.set('sanitizeFilter', true) or explicitly on individual queries via .sanitizeFilter(true) are not affected by this vulnerability, as those code paths read from model.base.options and query._mongooseOptions respectively.

If an immediate library upgrade is not feasible, apply one or more of the following workarounds:

  1. Enable sanitizeFilter Globally: Set mongoose.set('sanitizeFilter', true) at application startup. This populates mongoose.base.options.sanitizeFilter, which is properly evaluated by all affected versions.
  2. Enforce Strict Input Schema Validation: Validate all incoming HTTP request bodies and query parameters at the controller or routing layer using a schema validation library (such as Zod, Joi, or Ajv). Ensure that fields expected to be strings, numbers, or booleans are strictly validated as scalar primitives before being passed to Mongoose methods.
  3. Explicitly Cast or Wrap Inputs: Alternatively, wrap untrusted filter values in explicit $eq predicates (e.g., User.findOne({ username: { $eq: req.body.username } })) or cast them to primitives (String(req.body.username)) prior to constructing query objects.

Official Patches

AutomatticOfficial GitHub Security Advisory for GHSA-gg4r-jv3p-qx3c / CVE-2026-125119
AutomatticMongoose 9.11.4 Release
AutomatticMongoose 8.24.7 Release
AutomatticMongoose 7.8.13 Release
AutomatticMongoose 6.13.12 Release

Fix Analysis (4)

Technical Appendix

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

Affected Systems

Mongoose ODM (npm package: mongoose)

Affected Versions Detail

Product
Affected Versions
Fixed Version
Mongoose
Automattic
>= 6.0.0, < 6.13.126.13.12
Mongoose
Automattic
>= 7.0.0, < 7.8.137.8.13
Mongoose
Automattic
>= 8.0.0, < 8.24.78.24.7
Mongoose
Automattic
>= 9.0.0, < 9.11.49.11.4
AttributeDetail
CVE IDCVE-2026-125119 (GHSA-gg4r-jv3p-qx3c)
Weakness ClassCWE-943: Improper Neutralization of Special Elements in Data Query Logic
Attack VectorNetwork (Unauthenticated NoSQL Query Selector Injection)
CVSS v3.1 Score7.5 High (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N)
EPSS Score0.54% (45.82nd Percentile)
ImpactAuthentication bypass, sensitive document disclosure, and filter tampering
Affected Versions6.0.0 - 6.13.11, 7.0.0 - 7.8.12, 8.0.0 - 8.24.6, 9.0.0 - 9.11.3
CISA KEV StatusNot Listed

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
T1078Valid Accounts
Defense Evasion
T1005Data from Local System
Collection
CWE-943
Improper Neutralization of Special Elements in Data Query Logic

The software constructs all or part of a data query logic using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended query logic when it is sent to a downstream database component.

Vulnerability Timeline

Maintainer Valeri Karpov commits fixes across Mongoose 6.x, 7.x, 8.x, and 9.x branches
2026-10-22
GitHub Security Advisory GHSA-gg4r-jv3p-qx3c and CVE-2026-125119 published
2026-11-09
NVD and OSV records updated with affected commit ranges and CVSS v3.1 scoring
2026-11-10

References & Sources

  • [1]GitHub Security Advisory: GHSA-gg4r-jv3p-qx3c
  • [2]CVE-2026-125119 Record on CVE.org
  • [3]NVD Detail for CVE-2026-125119
  • [4]Fix Commit for Mongoose v9.x Branch (4bb659478be2f30655a7bdd78bc251bdf111cd29)
  • [5]Fix Commit for Mongoose v8.x Branch (4f4f9a79f860786a54133bee2c9af967ec691491)
  • [6]Fix Commit for Mongoose v7.x Branch (83eda6af1489e9ef60bb8eee8cf9ee005771b9d5)
  • [7]Fix Commit for Mongoose v6.x Branch (b8970c25998c23fbccd17f76c0398b902ff4911d)

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

•34 minutes ago•CVE-2026-125116
4.8

CVE-2026-125116: Type Confusion in Mongoose Discriminator Resolution

CVE-2026-125116 (GHSA-wr5m-5jph-8m96) is a type confusion vulnerability (CWE-843) in Mongoose, the MongoDB object modeling library for Node.js. When resolving discriminator models or schemas via user-supplied discriminator keys (defaulting to `__t`), Mongoose performs direct property indexing on plain JavaScript registry objects without verifying own-property ownership. Supplying inherited `Object.prototype` property names such as `'constructor'` causes Mongoose to resolve built-in functions rather than valid Mongoose constructors, resulting in unhandled runtime exceptions, schema validation bypasses, and persistent collection query denial of service.

Alon Barad
Alon Barad
2 views•11 min read
•about 3 hours ago•CVE-2026-125110
5.3

CVE-2026-125110: Path Canonicalization Mismatch and Security Header Bypass in Rack::Static

CVE-2026-125110 is a path canonicalization mismatch vulnerability in Rack (specifically within the Rack::Static middleware component). When serving static files, Rack normalizes the requested URL path to resolve the physical file on disk, but evaluates configured path-specific header rules against an unnormalized, raw path that has only undergone URL percent-decoding. Unauthenticated remote attackers can exploit this discrepancy by injecting raw or percent-encoded dot-segments into HTTP requests, causing Rack to serve restricted static assets without their intended security headers.

Amit Schendel
Amit Schendel
5 views•10 min read
•about 4 hours ago•CVE-2026-118776
3.7

CVE-2026-118776: Improper PKCS#7 Padding Validation in node-forge CBC and ECB Cipher Modes

CVE-2026-118776 (also tracked as GHSA-2vgq-wchc-25w7) is an improper input and integrity check validation vulnerability affecting the node-forge cryptographic library prior to version 1.4.1. In vulnerable versions, the PKCS#7 unpadding implementations for Cipher Block Chaining (CBC) and Electronic Codebook (ECB) modes only examined the final byte of the decrypted buffer and permitted padding counts up to four times the cipher block size. This defect allowed malformed ciphertexts containing zero-length padding, oversized padding values, or mismatched preceding padding bytes to pass validation, resulting in silent plaintext truncation of up to four blocks and integrity verification bypass in applications relying on unpadding success.

Amit Schendel
Amit Schendel
2 views•10 min read
•about 5 hours ago•CVE-2026-118774
3.7

CVE-2026-118774: Improper Verification of Cryptographic Signature in node-forge X.509 Certificate Validation

CVE-2026-118774 (GHSA-9wg5-mj3p-v49q) is an improper cryptographic signature verification vulnerability (CWE-347) in node-forge versions prior to 1.4.1. When verifying an X.509 subordinate certificate via certificate.verify(child) or verifyCertificateChain(), the library erroneously selects the RSA padding scheme (e.g., PKCS#1 v1.5 vs. RSASSA-PSS) and RSASSA-PSS parameters from the issuer certificate rather than from the child certificate being verified. This enables an attacker to relabel a PKCS#1 v1.5-signed certificate as an RSASSA-PSS certificate without invalidating the signature check, bypassing downstream security policies that mandate RSASSA-PSS.

Amit Schendel
Amit Schendel
3 views•12 min read
•about 6 hours ago•CVE-2026-118670
8.8

CVE-2026-118670: DOM-Based Cross-Site Scripting in OHIF Viewers dicom-pdf Extension

CVE-2026-118670 (GHSA-xwgp-w3pj-q5h3) is a high-severity DOM-based Cross-Site Scripting (XSS) vulnerability in OHIF Viewers affecting the dicom-pdf extension module. When processing DICOM Encapsulated Document objects, the viewer extracts the untrusted MIMETypeOfEncapsulatedDocument attribute (tag 0042,0012) and uses it directly to instantiate an in-memory Blob. This Blob is then converted to a same-origin Object URL and embedded into the document via an HTML <object> element. Because browsers prioritize the resource's underlying MIME type over the <object> element's type attribute, an attacker who supplies a crafted DICOM file with a MIME type such as text/html can execute arbitrary JavaScript within the application's origin, compromising session tokens, local storage, and Patient Health Information (PHI).

Alon Barad
Alon Barad
3 views•9 min read
•about 7 hours ago•CVE-2026-103022
5.3

CVE-2026-103022: Denial of Service via Unhandled Unicode Exception and File Descriptor Leak in Urwid Web Display

A Denial of Service (DoS) vulnerability exists in the web display module (urwid/display/web.py) of the Urwid console user interface library for Python in versions prior to 4.0.7. The handle_short_request() function unconditionally encodes HTTP POST input as ASCII without exception handling and opens a FIFO pipe file descriptor without a guaranteed cleanup block. Submitting non-ASCII characters triggers an unhandled UnicodeEncodeError that terminates CGI request processing and leaks the open file descriptor. Additionally, the screen update polling routine decodes Unix domain socket streams iteratively as UTF-8 without exception handling or deterministic socket closure, enabling uncaught UnicodeDecodeError exceptions and socket leaks.

Alon Barad
Alon Barad
3 views•10 min read