CVE-2026-106435: MongoDB Python Driver: Out-of-bounds read in BSON decoding via a malformed Regex element
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.
References
- github.com/advisories/GHSA-98qm-wvgf-w4cf
- github.com/mongodb/mongo-python-driver/commit/bb8d4e195275e75bd94ebeffb53cc747d357fcf4
- github.com/mongodb/mongo-python-driver/pull/3109
- github.com/mongodb/mongo-python-driver/releases/tag/4.18.3
- github.com/mongodb/mongo-python-driver/security/advisories/GHSA-98qm-wvgf-w4cf
- jira.mongodb.org/browse/PYTHON-6110
- nvd.nist.gov/vuln/detail/CVE-2026-106435
Code Behaviors & Features
Detect and mitigate CVE-2026-106435 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →