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

CVE-2026-96748: Host Injection Vulnerability in PyMongo Connection String Parsing

Amit Schendel
Amit Schendel
Senior Security Researcher

Oct 6, 2026·7 min read·23 visits

Executive Summary (TL;DR)

PyMongo's parser decoded percent-encoded characters before splitting hostnames, allowing attackers to inject rogue servers into connection strings.

A critical host injection vulnerability exists in PyMongo's connection string parser prior to version 4.18.2. The parser globally decodes percent-encoded characters in the host portion before splitting on delimiters, allowing attackers to inject arbitrary servers into the database client's connection pool.

Vulnerability Overview

CVE-2026-96748 is a host injection vulnerability affecting the official MongoDB Python driver, PyMongo. The issue is located in the connection string parsing routine, specifically within the host extraction and resolution pipeline. This vulnerability occurs when applications dynamically construct MongoDB connection URIs utilizing untrusted hostnames supplied by unauthenticated third parties.

The vulnerability allows an attacker to inject arbitrary backend servers into the database client's connection pool. By crafting hostnames containing percent-encoded delimiters, such as a comma (%2C) or a colon (%3A), attackers can manipulate the connection state. The driver parses these values incorrectly, causing the client to establish connections to external, unauthorized servers.

This bug class is classified under CWE-177: Improper Handling of URL Encoding. The impact of the flaw is significant, potentially leading to unauthorized data exposure or malicious manipulation of database operations. The vulnerability was officially resolved in PyMongo version 4.18.2, which was released on September 24, 2026.

Root Cause Analysis

The vulnerability originates from the sequence of decoding and parsing tasks in the PyMongo URI parser modules. In affected versions of PyMongo, the driver extracts the entire host list from the connection URI as a single string. It then processes this raw string before dividing it into separate node addresses.

Specifically, the parser executes a global percent-decoding operation on the entire host block using Python's unquote_plus() function. After decoding the entire string, PyMongo invokes functions to split the string on delimiters like commas and colons. This structural ordering allows percent-encoded commas (%2C) and colons (%3A) to be decoded into actual comma and colon characters before the split occurs.

Because the decoding happens before the string splitting, characters intended as payload data are promoted to structural delimiters. The parser subsequently treats the newly decoded commas and colons as boundaries for separate host addresses. This design flaw permits any percent-encoded string to generate arbitrary entries in the driver's internal server list.

Code Analysis: Vulnerable vs. Patched Code

Prior to the patch, the connection string parsing logic in pymongo/synchronous/uri_parser.py (and its asynchronous counterpart) decoded the entire host segment prematurely. The variable containing the raw host addresses was passed to unquote_plus() in a single step. This resulted in the global expansion of all escaped characters across the entire substring.

# Vulnerable implementation in pymongo/synchronous/uri_parser.py
# The entire hosts string is unquoted before any delimiter checks occur
hosts = unquote_plus(hosts)
 
# The decoded string is subsequently split on the comma character
for entity in hosts.split(","):
    # This processes each entry, which now includes injected elements
    nodes.append(parse_host(entity, default_port))

The fix implemented in version 4.18.2 restructures the processing order to guarantee that splitting occurs before decoding. The global unquote_plus() call was removed entirely from the main parsing loop. The utility function split_hosts in pymongo/uri_parser_shared.py now enforces strict structural separation before performing any decoding logic.

# Patched implementation in pymongo/uri_parser_shared.py
def split_hosts(hosts: str, default_port: Optional[int] = DEFAULT_PORT) -> list[tuple[str, Optional[int]]]:
    nodes = []
    # Splitting occurs directly on the raw, undecoded hosts string
    for entity in hosts.split(","):
        if not entity:
            raise ConfigurationError("Empty host (or extra comma in host list)")
        port = default_port
        node = entity
        
        # Percent-decoding is now restricted to specific valid use cases
        if entity.endswith(".sock"):
            node = unquote_plus(entity)
            port = None
        elif entity.startswith("["):
            node = entity.replace("%25", "%")
        elif "%" in entity:
            # Rejects percent-encoding in standard hostnames
            raise InvalidURI(
                "Percent-encoding is only allowed in Unix domain socket paths "
                f"and IPv6 zone indexes, not in hostnames: {entity}"
            )
        nodes.append(parse_host(node, port))
    return nodes

This structural change ensures that standard TCP hostnames cannot contain percent-encoded control characters. Any attempt to supply a hostname containing a percent character will trigger an InvalidURI exception. The patch also updates KMS endpoint validation to prevent similar exploitation vectors when managing client-side field-level encryption.

Exploitation Methodology & Proof of Concept

Exploitation of this vulnerability requires an application configuration where untrusted input is interpolated into the host field of a MongoDB connection string. An attacker must find an interface that dynamically populates host values, such as a database-as-a-service manager or a tenant routing system. By supplying a crafted string, the attacker initiates the exploit chain.

For example, if an attacker registers with a hostname value of legit-host.internal%2Cattacker-dns.com%3A27017, the application inserts this string into the connection URI. During parsing, PyMongo extracts the host portion as a single entity and decodes the %2C to a comma and %3A to a colon. The driver then splits the string, yielding two distinct connection destinations: legit-host.internal and attacker-dns.com:27017.

Once parsed, both destinations are registered in the MongoClient's internal connection pool or replica set seed list. The client subsequently initiates background discovery and connection tasks to both addresses. This behavior allows the attacker's server to participate in the application's database communication channels without requiring any prior authentication.

Impact Assessment

The impact of successful host injection is critical for confidentiality and integrity. By forcing the PyMongo client to connect to an attacker-controlled server, the attacker can intercept network packets containing authentication requests. Although PyMongo employs secure authentication mechanisms like SCRAM-SHA-256, the server receives connection handshakes containing user identifiers and challenge hashes.

Beyond credential exposure, the injected server can act as an adversary-in-the-middle. If the application configuration permits query routing to secondary members of a replica set, the client may send queries directly to the rogue server. The attacker's server can return modified or fabricated data payloads to the client application, leading to integrity violations.

This vulnerability does not directly lead to arbitrary code execution on the client server. However, the capacity to manipulate query responses and harvest connection information poses a substantial threat to application security. The National Vulnerability Database assigned this flaw a CVSS v3.1 score of 6.5, while the MongoDB CNA assigned a CVSS v4.0 score of 8.3, reflecting the severe consequences in multi-tenant environments.

Remediation & Secure Coding Practices

The recommended remediation is to upgrade the PyMongo package to version 4.18.2 or later. This version contains the structural patch that restricts percent-decoding to Unix domain socket paths and IPv6 zone indexes. Upgrading the package resolves the vulnerability at the parser level without requiring modifications to connection logic.

If an immediate package upgrade is not feasible, developers must implement strict input validation on all user-supplied host parameters. Hostnames should be verified against a strict regular expression that allows only alphanumeric characters, periods, and hyphens. Any input containing percent characters, commas, or colons must be rejected before connection string interpolation occurs.

import re
 
def sanitize_and_validate_host(host_input: str) -> str:
    # Restrict input to standard domain name characters
    if not re.match(r"^[a-zA-Z0-9.-]+$", host_input):
        raise ValueError("Invalid characters detected in host input")
    return host_input

Enforcing network-level egress restrictions is also a viable defense-in-depth measure. Configuring firewall rules to limit outgoing database connections to known, authorized IP ranges prevents the PyMongo client from establishing contact with external, rogue database seeds.

Official Patches

MongoDBPYTHON-5986 Host injection in PyMongo connection string parsing via percent-encoded delimiters
MongoDBOfficial PyMongo 4.18.2 Release Tag

Fix Analysis (2)

Technical Appendix

CVSS Score
8.3/ 10
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:H/VA:N/SC:N/SI:N/SA:N
EPSS Probability
0.26%
Top 84% most exploited

Affected Systems

PyMongo (Python Driver for MongoDB)

Affected Versions Detail

Product
Affected Versions
Fixed Version
PyMongo
MongoDB
>= 0, < 4.18.24.18.2
AttributeDetail
CWE IDCWE-177
Attack VectorNetwork
CVSS v4.0 Score8.3
EPSS Score0.00257 (15.78th percentile)
ImpactHost Injection / Adversary-in-the-Middle
Exploit StatusNone (No public PoC)
CISA KEV StatusNot Listed

MITRE ATT&CK Mapping

T1557Adversary-in-the-Middle
Credential Access
T1090Proxy
Command and Control
CWE-177
Improper Handling of URL Encoding (Hex Encoding)

The application does not properly decode percent-encoded characters before validating or parsing structural delimiters, leading to delimiter injection.

References & Sources

  • [1]GitHub Security Advisory GHSA-vp6j-j7w5-5xjj
  • [2]Fix Commit: Refactoring of host split and decode order
  • [3]CVE Record for CVE-2026-96748
  • [4]Official PyMongo Changelog

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

•about 1 hour ago•CVE-2026-126297
7.5

CVE-2026-126297: Algorithmic Complexity Denial of Service in NLTK ConllCorpusReader

CVE-2026-126297 (GHSA-v8f3-6phw-6mh9) is an uncontrolled resource consumption and algorithmic complexity vulnerability in the Natural Language Toolkit (NLTK) prior to version 3.10.4. Located in the Semantic Role Labeling (SRL) parser within `nltk/corpus/reader/conll.py`, the flaw allows an attacker to trigger quadratic O(N^2) CPU processing overhead by providing crafted CoNLL-formatted corpus inputs containing decoy span columns or nested full-width verb spans. Applications parsing untrusted linguistic corpora can experience prolonged CPU exhaustion and application-level Denial of Service (DoS).

Amit Schendel
Amit Schendel
1 views•12 min read
•about 2 hours ago•CVE-2026-126298
7.5

CVE-2026-126298: Quadratic Algorithmic Complexity Denial of Service in NLTK Tree.chomsky_normal_form

CVE-2026-126298 (also tracked as GHSA-r53h-rw34-8h97) is an algorithmic complexity Denial of Service (DoS) vulnerability in the Natural Language Toolkit (NLTK) Python library affecting all versions prior to 3.10.4. The vulnerability resides in the nltk.tree.transforms.chomsky_normal_form function and its corresponding public method Tree.chomsky_normal_form(). When transforming a parse tree into Chomsky Normal Form using the default right-factoring strategy, the function repeatedly invokes list.pop(0) inside a loop iterating over all children of a node. In CPython, removing the initial element of a standard list requires an O(N) memory shift operation, causing the overall binarization algorithm to degrade to O(N^2) quadratic time complexity relative to the width of a node. Furthermore, converting horizontal node width into vertical tree depth bypasses initial parsing depth bounds, triggering subsequent stack exhaustion (RecursionError) when recursive methods traverse the mutated structure. Unauthenticated remote attackers who can submit bracketed tree strings to applications invoking this transformation can exhaust single-threaded CPU resources or induce unhandled application exceptions.

Alon Barad
Alon Barad
5 views•12 min read
•about 3 hours ago•CVE-2026-126299
7.5

CVE-2026-126299: Quadratic Algorithmic Complexity Denial of Service in NLTK CCG Lexicon Parser

An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.

Alon Barad
Alon Barad
4 views•10 min read
•about 4 hours ago•CVE-2026-126295
7.1

CVE-2026-126295: Path Traversal and Unconfined File Access in NLTK BllipParser

CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.

Amit Schendel
Amit Schendel
2 views•11 min read
•about 5 hours ago•CVE-2026-126300
5.3

CVE-2026-126300: Algorithmic Complexity Denial of Service in NLTK TreebankWordTokenizer.span_tokenize

CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.

Amit Schendel
Amit Schendel
3 views•10 min read
•about 6 hours ago•GHSA-GPWC-27CW-RH9R
5.3

CVE-2026-126301: Quadratic CPU Exhaustion in NLTK LegalitySyllableTokenizer

The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.

Amit Schendel
Amit Schendel
5 views•10 min read