{"id":"GHSA-98qm-wvgf-w4cf","summary":"MongoDB Python Driver: Out-of-bounds read in BSON decoding via a malformed Regex element","details":"### Impact\nThe 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.\n\n### Patches\nFixed in PyMongo 4.18.3. Malformed Regex elements now raise InvalidBSON on every accepted buffer type; valid documents decode unchanged.\n\n###  Workarounds\nDecode untrusted BSON only from NUL-terminated buffers — bytes or bytearray — and copy mmap input first, e.g. bytes(mm[:size]).","aliases":["CVE-2026-106435"],"modified":"2026-10-27T15:47:24.276730806Z","published":"2026-10-27T15:36:35Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2026-10-27T15:36:35Z","nvd_published_at":null,"cwe_ids":["CWE-125"],"severity":"HIGH"},"references":[{"type":"WEB","url":"https://github.com/mongodb/mongo-python-driver/security/advisories/GHSA-98qm-wvgf-w4cf"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-106435"},{"type":"WEB","url":"https://github.com/mongodb/mongo-python-driver/pull/3109"},{"type":"WEB","url":"https://github.com/mongodb/mongo-python-driver/commit/bb8d4e195275e75bd94ebeffb53cc747d357fcf4"},{"type":"PACKAGE","url":"https://github.com/mongodb/mongo-python-driver"},{"type":"WEB","url":"https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.3"},{"type":"WEB","url":"https://jira.mongodb.org/browse/PYTHON-6110"}],"affected":[{"package":{"name":"pymongo","ecosystem":"PyPI","purl":"pkg:pypi/pymongo"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.9.0"},{"fixed":"4.18.3"}]}],"versions":["3.10.0","3.10.1","3.11.0","3.11.1","3.11.2","3.11.3","3.11.4","3.12.0","3.12.1","3.12.2","3.12.3","3.13.0","3.9.0","4.0","4.0.1","4.0.2","4.1.0","4.1.1","4.10.0","4.10.1","4.11","4.11.1","4.11.2","4.11.3","4.12.0","4.12.1","4.13.0","4.13.0.dev0","4.13.1","4.13.2","4.14.0","4.14.1","4.15.0","4.15.1","4.15.2","4.15.3","4.15.4","4.15.5","4.16.0","4.16.0.dev0","4.17.0","4.18.0","4.18.1","4.18.2","4.2.0","4.3.2","4.3.3","4.4.0","4.4.0b0","4.4.1","4.5.0","4.6.0","4.6.1","4.6.2","4.6.3","4.7.0","4.7.1","4.7.2","4.7.3","4.8.0","4.8.0b0","4.9","4.9.1","4.9.2"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-98qm-wvgf-w4cf/GHSA-98qm-wvgf-w4cf.json","last_known_affected_version_range":"\u003c= 4.18.2"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V4","score":"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"}]}