CVE-2026-42334
Executive Summary
CVE-2026-42334 is a high-severity vulnerability (CVSS 7.5) in Mongoose, a popular MongoDB object modeling tool for Node.js. The flaw allows attackers to bypass the sanitizeFilter query sanitization mechanism by injecting malicious MongoDB operators (e.g., $ne, $gt, $regex) inside a $nor clause. This can lead to unauthorized data access or injection attacks. The vulnerability affects all Mongoose versions prior to 6.13.9, 7.8.9, 8.22.1, and 9.1.6. Patches are available, and immediate upgrade is recommended.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the Mongoose npm package. Organizations using Mongoose in their Node.js applications should verify their dependency versions and update to the patched releases. The npm ecosystem is particularly susceptible to supply chain attacks, and this vulnerability could be exploited in applications that rely on Mongoose for database interactions.
CVSS Breakdown & Threat Level
- CVSS Score: 7.5 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: High
- Integrity Impact: None
- Availability Impact: None
The vulnerability is remotely exploitable without authentication, making it a significant threat to data confidentiality.
Deep Dive & Mechanics
Mongoose's sanitizeFilter is designed to prevent NoSQL injection by wrapping query operators in $eq to neutralize them. However, the $nor operator was not included in the set of logical operators that are recursively sanitized. Since $nor accepts an array (like $and and $or), and arrays do not trigger the hasDollarKeys() check, malicious operators such as $ne, $gt, or $regex can be injected inside a $nor clause without being sanitized.
Example of a malicious query:
{
"$nor": [
{ "username": { "$ne": "admin" } },
{ "password": { "$regex": ".*" } }
]
}
This query would bypass sanitization and potentially return unauthorized data.
Vulnerable vs. Patched Code
Vulnerable Code (before fix):
// In sanitizeFilter, $nor is not included in the recursive sanitization
const logicalOperators = ['$and', '$or'];
// $nor is missing, so it is not sanitized
Patched Code (after fix):
// $nor is now included in the recursive sanitization
const logicalOperators = ['$and', '$or', '$nor'];
// $nor clauses are now properly sanitized
Exploitation & Lab Setup
Red Team
- Setup: Deploy a vulnerable Mongoose application (version < 6.13.9) with
sanitizeFilterenabled. - Exploit: Send a crafted HTTP request with a JSON payload containing a
$norclause with malicious operators.{ "$nor": [ { "username": { "$ne": "admin" } }, { "password": { "$regex": ".*" } } ] } - Result: The query bypasses sanitization and returns unauthorized data.
Blue Team
- Detection: Monitor for unusual query patterns containing
$norwith nested operators. - Mitigation: Immediately upgrade Mongoose to patched versions (6.13.9, 7.8.9, 8.22.1, or 9.1.6).
- Logging: Enable detailed logging of all database queries to detect anomalies.
Indicators of Compromise (IOCs)
- Network: HTTP requests containing JSON payloads with
$norclauses and nested operators like$ne,$gt,$regex. - Logs: Database query logs showing
$norusage with unexpected operators. - Application: Unauthorized data access or injection attempts in application logs.
Detection Engineering
YARA Rule
rule CVE_2026_42334_Mongoose_SanitizeBypass {
meta:
description = "Detects attempts to exploit CVE-2026-42334 in Mongoose"
author = "Valters IT"
date = "2026-01-01"
severity = "high"
strings:
$nor = "$nor"
$ne = "$ne"
$gt = "$gt"
$regex = "$regex"
condition:
$nor and ($ne or $gt or $regex)
}
Sigma Rule
title: Mongoose SanitizeFilter Bypass via $nor
id: 12345678-1234-1234-1234-123456789abc
status: experimental
description: Detects HTTP requests with $nor clauses containing malicious operators
author: Valters IT
date: 2026-01-01
logsource:
category: webserver
product: nginx
detection:
selection:
http.request.body|contains: '$nor'
http.request.body|contains|any:
- '$ne'
- '$gt'
- '$regex'
condition: selection
falsepositives:
- Legitimate use of $nor with safe operators
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2026-42334 Mongoose SanitizeFilter Bypass"; flow:to_server; content:"$nor"; http_client_body; pcre:"/\$nor.*\$(ne|gt|regex)/"; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Upgrade Mongoose to version 6.13.9, 7.8.9, 8.22.1, or 9.1.6.
- Workaround: If immediate upgrade is not possible, disable
sanitizeFilterand implement custom input validation. - Monitoring: Enable logging and monitoring for suspicious query patterns.
- Review: Audit all applications using Mongoose for potential exposure.
Valters IT
Securing Digital Frontiers