Improper Neutralization of Special Elements in Data Query Logic Affecting mongoose package, versions >=6.0.0 <6.13.12>=7.0.0 <7.8.13>=8.0.0 <8.24.7>=9.0.0 <9.11.4


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.54% (46th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Improper Neutralization of Special Elements in Data Query Logic vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-MONGOOSE-22409027
  • published11 Nov 2026
  • disclosed10 Nov 2026
  • creditYounghun Ko

Introduced: 10 Nov 2026

NewCVE-2026-125119  (opens in a new tab)
CWE-943  (opens in a new tab)

How to fix?

Upgrade mongoose to version 6.13.12, 7.8.13, 8.24.7, 9.11.4 or higher.

Overview

mongoose is a Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

Affected versions of this package are vulnerable to Improper Neutralization of Special Elements in Data Query Logic via Query#_castConditions() in lib/query.js, which checks Connection.options, the global options, and per-query options for the sanitizeFilter flag, but never checks Connection.config. When sanitizeFilter is set at the connection level via mongoose.connect() or createConnection(uri, { sanitizeFilter: true }), NativeConnection#createClient() moves the option from options into Connection.config and deletes it from options, so _castConditions() never finds it and the sanitization step is skipped entirely. An attacker can therefore pass a query selector object such as { $ne: null } as a filter value and bypass authentication or access controls that depend on the connection-level option.

Note: This is only exploitable when sanitizeFilter is configured at the connection level. Applications that set sanitizeFilter globally via mongoose.set('sanitizeFilter') or per-query via .sanitizeFilter() are not affected.

CVSS Base Scores

version 4.0
version 3.1