CVE-2026-96747: PyMongo Remote Code Execution Vulnerability
MODERATECVE-2026-96747 is a MODERATE (CVSS 5.0) remote code execution vulnerability (CWE-20: Improper Input Validation) affecting PyMongo libraries in the PyPI ecosystem. The issue involves python-5990 forced unix domain socket connection via a .sock kms endpoint in client-side field level encryption. Remediation is available by upgrading affected packages to version 4.18.2.
CVE-2026-96747 at a Glance
Security Impact
CVSS: 5.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:N/A:N).
How to Fix CVE-2026-96747
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-96747, 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. 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-96747 Affected PyMongo Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pymongo
|
PyPI |
≥ 3.9.0
< 4.18.2
|
4.18.2
|
References
Frequently Asked Questions
What is CVE-2026-96747?
Which PyMongo versions are affected?
What version fixes CVE-2026-96747?
Is pymongo affected?
What is the CVSS score of CVE-2026-96747?
What CWE is associated with CVE-2026-96747?
How can I check PyPI dependencies for CVE-2026-96747?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-qx36-8mw2-4r3x",
"modified" : "2026-10-05T23:46:53Z",
"published" : "2026-10-05T23:46:53Z",
"aliases" : [ "CVE-2026-96747" ],
"summary" : "PyMongo: PYTHON-5990 Forced Unix domain socket connection via a .sock KMS endpoint in client-side field level encryption",
"details" : "### Summary\n\nPyMongo passed the KMS endpoint of a data key verbatim into `parse_host()`, which returns any string ending in `.sock` unchanged instead of validating it as a hostname and port. The driver's connection code then treats such an address as a Unix domain socket path and connects to it with `AF_UNIX`. Because the endpoint originates from `masterKey.endpoint` in a key vault document, a party who can write to the key vault could redirect the driver's KMS connection to an arbitrary Unix domain socket path on the application host.\n\n### Impact\n\nAn application using client-side field level encryption (CSFLE) or Queryable Encryption is affected if an attacker can write to its key vault collection. Setting `masterKey.endpoint` on a data key to a `.sock`-suffixed string causes the next KMS request for that key (key cache TTL is ~60 seconds) to open an `AF_UNIX` connection to the attacker-chosen filesystem path from inside the victim application process. The documented custom KMS endpoint feature supports TCP hosts only, so this crosses a boundary the feature was never intended to allow.\n\nImpact is limited to the side effects of the connection itself. The socket is still wrapped in a verifying TLS context using the `.sock` string as `server_hostname`, and insecure KMS TLS options are rejected, so the handshake always fails and the KMS message is never sent. The attacker controls the connect target but not the transmitted bytes (a fixed TLS ClientHello).\n\nApplications that do not use CSFLE or Queryable Encryption are not affected. Applications whose key vault is not writable by untrusted parties are not affected.\n\n### Patches\n\nFixed in PyMongo 4.18.2 `_EncryptionIO.kms_request` now rejects a `.sock`-suffixed KMS endpoint with `pymongo.errors.ConfigurationError` immediately after parsing, before any connection is attempted, on both the synchronous and asynchronous paths. No application code changes are required beyond upgrading.\n\n### Workarounds\n\nIf you cannot upgrade immediately:\n\n- Restrict write access to the key vault collection to trusted principals only. This is the recommended configuration regardless of this issue.\n- Validate `masterKey.endpoint` on data keys you create, and audit existing key vault documents for endpoints ending in `.sock`.\n\n### Details\n\n- `_EncryptionIO.fetch_keys` reads key vault documents from the server and hands them to libmongocrypt, which surfaces the stored `masterKey.endpoint` verbatim as `kms_context.endpoint`.\n- `_EncryptionIO.kms_request` passed that string to `parse_host(endpoint, 443)`. `parse_host` returns entities ending in `.sock` verbatim, skipping the hostname and port validation applied to every other input.\n- `_create_connection` (and the async equivalent) checks `host.endswith(\".sock\")` and performs an `AF_UNIX` `sock.connect(host)`, treating the string as a filesystem path.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:N/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:N/SC:L/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pymongo"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.9.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-qx36-8mw2-4r3x"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-96747"
}, {
"type" : "WEB",
"url" : "https://github.com/mongodb/mongo-python-driver/pull/3066"
}, {
"type" : "WEB",
"url" : "https://github.com/mongodb/mongo-python-driver/commit/44119d0f9dfa0224d84b03be702a6d9a5ef1dea7"
}, {
"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-20", "CWE-918" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-10-05T23:46:53Z",
"nvd_published_at" : "2026-09-24T19:17:20Z"
}
}