CVE-2026-103965
Executive Summary
CVE-2026-103965 is a logic vulnerability in the MongoDB Server aggregation framework that allows certain constant values to be mishandled during internal query rewriting. An authenticated user with read access can receive field values in aggregation output that the query did not intend to return. While the CVSS score of 5.4 indicates a moderate severity impact, the vulnerability affects data confidentiality and integrity assumptions for MongoDB deployments.
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
Technical Analysis
The vulnerability resides in the aggregation framework's internal query rewriting logic. During query optimization, MongoDB may rewrite aggregation pipelines to improve performance. CVE-2026-103965 causes certain constant values to be handled incorrectly during this rewriting process. The core flaw is classified as CWE-94 (Improper Control of Generation of Code, 'Code Injection'), which in this context likely refers to the improper handling of constant values that are incorporated into rewritten query structures.
The attack surface is the MongoDB aggregation framework, accessible through standard database query interfaces such as the aggregate command. An attacker must be authenticated and possess read access to the database. The vulnerability does not require user interaction and is network-accessible, as reflected in the CVSS vector (AV:N/AC:L/PR:L/UI:N). The impact is limited to confidentiality and integrity (C:L/I:L), with no direct impact on availability.
No specific version information, function names, or patch details are provided in the available intelligence. The exact conditions under which the incorrect handling occurs are not described beyond "certain constant values" and "certain conditions." Therefore, the analysis must remain at the vulnerability class level: a query rewriting defect that can cause unintended data exposure in aggregation results.
Exploitation Scenarios
Reconnaissance/target identification: An attacker identifies a MongoDB Server instance accessible over the network (default port 27017) and obtains valid credentials with read access. This could be achieved through credential stuffing, default credentials, or prior compromise of a low-privileged account.
Triggering the flaw: The attacker constructs an aggregation pipeline that includes constant values in a way that triggers the internal query rewriting logic. The specific structure required to trigger the mishandling is not publicly documented. Based on the vulnerability class, the attacker would likely use operators or expressions within the aggregation framework that cause the query optimizer to rewrite the pipeline, leading to incorrect handling of the constant values.
Payload/execution method: The attacker executes the crafted aggregation query against the target database. The query is submitted through the standard MongoDB wire protocol or a database driver. The vulnerability is triggered during the server-side query rewriting phase.
Post-exploitation impact: The attacker may receive field values in the aggregation output that the query was not intended to return. This could expose sensitive data that the attacker's read privileges were not supposed to grant access to, or it could return incorrect values that mislead the attacker. The impact is primarily information disclosure and potential data integrity issues in the query results. No public PoC is available; the attack chain is inferred from the vulnerability class.
Impact Assessment
The CVSS score of 5.4 (Medium) reflects a vulnerability that requires authentication (PR:L) and has limited confidentiality and integrity impact (C:L/I:L). There is no impact on availability (A:N). The attack vector is network-based (AV:N) with low attack complexity (AC:L) and no user interaction (UI:N). The scope is unchanged (S:U), meaning the vulnerable component and the impacted component are the same.
Business impact includes potential unauthorized access to data that should not be returned by a given aggregation query. In environments where MongoDB is used for multi-tenant applications or where read access is granted to users with restricted data visibility, this could lead to horizontal privilege escalation or data leakage. The blast radius is limited to the data accessible by the authenticated user, but the incorrect rewriting could bypass intended data filtering logic. Affected systems are MongoDB Server deployments that expose the aggregation framework to authenticated users. The lack of a patch increases the risk of exploitation, though no active exploitation has been observed.
Detection Guidance
Sigma Rule
title: MongoDB Aggregation Query Rewriting Anomaly
id: 8f4a2b1c-3d5e-4f6a-9b7c-1e2d3f4a5b6c
status: experimental
description: Detects aggregation queries that may trigger CVE-2026-103965 constant handling issue
author: valtersit.com
date: 2026-01-01
logsource:
product: mongodb
service: audit
detection:
selection:
type: "aggregate"
param.pipeline|contains: "$const"
condition: selection
falsepositives:
- Legitimate use of constants in aggregation pipelines
level: low
YARA Rule
rule CVE_2026_103965_MongoDB_Aggregation_Rewrite
{
meta:
description = "Detects potential exploitation of CVE-2026-103965 in MongoDB aggregation queries"
author = "valtersit.com"
date = "2026-01-01"
reference = "CVE-2026-103965"
severity = "medium"
strings:
$agg = "aggregate"
$const = "$const"
$pipeline = "pipeline"
$rewrite = "rewrite"
condition:
any of them
}
Suricata IDS Rule
alert tcp $EXTERNAL_NET any -> $HOME_NET 27017 (msg:"Possible CVE-2026-103965 MongoDB Aggregation Query Rewriting Exploit"; flow:to_server,established; content:"aggregate"; content:"$const"; distance:0; within:100; classtype:attempted-recon; sid:10000001; rev:1;)
Elastic Detection
process where event.type == "start" and process.name == "mongod" and
process.args : "*aggregate*" and process.args : "*$const*"
Splunk SPL Query
index=mongodb_audit type=aggregate
| search pipeline="*$const*"
| stats count by user, client_ip, pipeline
| where count > 0
Wazuh OSSEC Rule
<group name="mongodb,">
<rule id="100001" level="5">
<decoded_as>json</decoded_as>
<field name="type">aggregate</field>
<field name="pipeline">\.*\$const\.*</field>
<description>MongoDB aggregation query with constant may indicate CVE-2026-103965 exploitation attempt</description>
</rule>
</group>
Mitigation & Patch Guidance
Immediate mitigations:
- Restrict network access to MongoDB instances to trusted networks only.
- Enforce strong authentication and least-privilege read access.
- Monitor audit logs for unusual aggregation queries, especially those involving constant values.
- Consider disabling the aggregation framework for untrusted users if feasible, though this may break functionality.
Patch/upgrade steps:
- No patch is currently available (Patch confidence: 0/4). Monitor MongoDB security advisories for an official fix.
- Once a patch is released, test and deploy it promptly.
Long-term hardening:
- Implement role-based access control (RBAC) with strict data filtering.
- Regularly review user permissions and audit queries.
- Use MongoDB's built-in auditing and integrate with SIEM for anomaly detection.
- Keep MongoDB Server updated with the latest security patches.
References
- NVD Entry: https://nvd.nist.gov/vuln/detail/CVE-2026-103965
- MongoDB Security Advisories: https://www.mongodb.com/alerts
- CWE-94: https://cwe.mitre.org/data/definitions/94.html
- CVSS v3.1 Specification: https://www.first.org/cvss/v3.1/specification-document
- No known threat actor campaigns or exploit-in-the-wild evidence available.
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.