CVE-2026-96748: PyMongo Remote Code Execution Vulnerability
HIGHCVE-2026-96748 is a HIGH (CVSS 6.5) remote code execution vulnerability (CWE-177: Improper Handling of URL Encoding (Hex Encoding)) affecting PyMongo libraries in the PyPI ecosystem. The issue involves python-5986 host injection in pymongo connection string parsing via percent-encoded delimiters. Remediation is available by upgrading affected packages to version 4.18.2.
CVE-2026-96748 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N).
How to Fix CVE-2026-96748
To remediate this vulnerability, upgrade all affected PyMongo dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install pymongo>=4.18.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show pymongo
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-96748, inspect your installed packages using pip:
pip show pymongo
Analyze the terminal output to locate any version of PyMongo in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.18.2), your application is affected.
Note: The pip show pymongo command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-177: Improper Handling of URL Encoding (Hex Encoding), where the product does not properly handle when all or part of an input has been url encoded. In PyMongo, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-96748 Affected PyMongo Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pymongo
|
PyPI |
≥ 3.5.0
< 4.18.2
|
4.18.2
|
References
Frequently Asked Questions
What is CVE-2026-96748?
Which PyMongo versions are affected?
What version fixes CVE-2026-96748?
Is pymongo affected?
What is the CVSS score of CVE-2026-96748?
What CWE is associated with CVE-2026-96748?
How can I check PyPI dependencies for CVE-2026-96748?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-vp6j-j7w5-5xjj",
"modified" : "2026-10-05T23:47:07Z",
"published" : "2026-10-05T23:47:07Z",
"aliases" : [ "CVE-2026-96748" ],
"summary" : "PyMongo: PYTHON-5986 Host injection in PyMongo connection string parsing via percent-encoded delimiters",
"details" : "### Summary\n\nPyMongo percent-decoded the entire host section of a connection string before splitting it into individual `host:port` entries. A percent-encoded `,` or `:` in a hostname therefore decoded into a real delimiter, injecting an additional attacker-chosen host and port into the client's seed list.\n\n### Impact\n\nAn application that interpolates untrusted input into a MongoDB connection string -- for example, a tenant name or hostname fragment taken from a request -- could be made to add an attacker-controlled server to the seed list. Because `%2C` and `%3A` survive most URL-safety checks and only become delimiters inside PyMongo's parser, input that looks like a single hostname to the application becomes two hosts to the driver. The client may then perform topology discovery and authentication against the attacker's host, exposing credentials, or route operations to it.\n\nUnix domain socket paths, the only host identifiers that legitimately require percent-encoding, are not affected.\n\n### Patches\n\nFixed in PyMongo 4.18.2. Percent-decoding was moved into `split_hosts` and now applies only to Unix domain socket paths, identified by an unescaped `.sock` suffix before decoding, and only after splitting on `,`.\n\n### Workarounds\n\nDo not interpolate untrusted input into the host portion of a connection string. If unavoidable, reject or percent-decode-and-validate the value before building the URI.\n\n### Details\n\nThe decoding was introduced in PyMongo 3.5.0 (PYTHON-1282), where `unquote_plus` was applied to the whole host section in `_validate_uri` and, later, `_parse_srv`, before the string was split on `,` and `:`.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N"
}, {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pymongo"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.5.0"
}, {
"fixed" : "4.18.2"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 4.18.1"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/mongodb/mongo-python-driver/security/advisories/GHSA-vp6j-j7w5-5xjj"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-96748"
}, {
"type" : "WEB",
"url" : "https://github.com/mongodb/mongo-python-driver/pull/3066"
}, {
"type" : "WEB",
"url" : "https://github.com/mongodb/mongo-python-driver/commit/1e7a56db4649b14c4c9a6ac20aa4a8d0d1bb238a"
}, {
"type" : "WEB",
"url" : "https://github.com/mongodb/mongo-python-driver/commit/640dd2383a1a2fb1a10e5222d50ebc0b22a61bd7"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/mongodb/mongo-python-driver"
}, {
"type" : "WEB",
"url" : "https://github.com/mongodb/mongo-python-driver/blob/4.18.2/doc/changelog.rst"
}, {
"type" : "WEB",
"url" : "https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.2"
}, {
"type" : "WEB",
"url" : "https://www.mongodb.com/community/forums/t/pymongo-4-18-2-released/343732"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-177" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-10-05T23:47:07Z",
"nvd_published_at" : "2026-09-24T19:17:20Z"
}
}