5.9medium
Application denial of service via out-of-bounds read in BSON Regex decoding in MongoDB Python Driver
- Severity
- 5.9medium CVSS:4.0 by mongodb
- Exploit likelihood
- 0.09% (higher than 0% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- mongodb
- Also known as
- GHSA-98qm-wvgf-w4cf
Description
The MongoDB Python Driver's binary accelerator can read outside a buffer when an application decodes malformed BSON containing a truncated regular-expression element without a trailing NUL byte. An actor who can supply BSON to the documented decode or decode_all API can cause the application process to terminate when the C extension is loaded. The driver's normal database wire-protocol path does not reach this code.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| MongoDB Python Driver | from 0.10.3 up to 4.18.2 | CVE List |
| pymongo (PyPI) | from 3.9.0 before 4.18.3 | GitHub Advisory Database |
| mongodb python_driver | before 4.18.3 | NVD |
All scores
| mongodb | 5.9medium CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N |
| mongodb | 5.1medium CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N |
| NVD | 4.7medium CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
The MongoDB Python Driver's binary accelerator can read outside a buffer when an application decodes malformed BSON containing a truncated regular-expression element without a trailing NUL byte. An actor who can supply BSON to the documented decode or decode_all API can cause the application process to terminate when the C extension is loaded. The driver's normal database wire-protocol path does not reach this code.
GitHub Advisory Database
Impact
The C extension's BSON decoder scans a Regex element's pattern and flags strings with strlen before checking the document's remaining length, so a crafted truncated Regex element can read past the end of the caller's buffer. bson.decode and bson.decode_all accept mmap and array buffers, which carry no NUL sentinel; the read can cross into unmapped memory and kill the process with an uncatchable SIGSEGV. Any application decoding untrusted BSON from such buffers is affected — impact is availability only, since the out-of-bounds bytes are never returned as content. NUL-terminated buffers (bytes, bytearray) raise InvalidBSON at worst; the driver's own transport and pure-Python installs are not affected. All releases through 4.18.2 are affected when the C extension is loaded.
Patches
Fixed in PyMongo 4.18.3. Malformed Regex elements now raise InvalidBSON on every accepted buffer type; valid documents decode unchanged.
Workarounds
Decode untrusted BSON only from NUL-terminated buffers — bytes or bytearray — and copy mmap input first, e.g. bytes(mm[:size]).
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-106435 changed 2026-10-09 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-98qm-wvgf-w4cf changed 2026-10-27 | CC-BY-4.0 |
| NVD | CVE-2026-106435 changed 2026-10-15 | Public domain |