All vulnerabilities

PyPI

CVE-2026-106435

MongoDB Python Driver: Out-of-bounds read in BSON decoding via a malformed Regex element

Severity
High
Published
27 Oct 2026
Last changed
27 Oct 2026
Added to UpHeron
23 Nov 2026
Fixed in
4.18.3
Exploit chance
under 0.1% in the next 30 daysEPSS by FIRST, 24 Nov 2026
Weakness
Out-of-bounds read (CWE-125)
Also known as
GHSA-98qm-wvgf-w4cf
Sources
OSV.dev and GitHub

Description

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.

From the GitHub Advisory Database, CC BY 4.0.

Workarounds

Decode untrusted BSON only from NUL-terminated buffers — bytes or bytearray — and copy mmap input first, e.g. bytes(mm[:size]).

Workarounds as given by the GitHub Advisory Database, CC BY 4.0.

Affected software

SoftwareAffected versions
pymongoPyPI · osv:PyPI:pymongo
  • From 3.9.0 before 4.18.3

About pymongo

Weekly downloads (PyPI)
18,250,243PyPI Stats, 23 Nov 2026

This is the only vulnerability in pymongo in our list.

References