{"id":"CVE-2026-106435","kind":"vulnerability","aliases":["CVE-2026-106435","GHSA-98qm-wvgf-w4cf"],"related":[],"title":"MongoDB Python Driver: Out-of-bounds read in BSON decoding via a malformed Regex element","description":"### 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]).","summary":"PyMongo's C BSON decoder reads past the end of the caller's buffer when a Regex element is truncated, because it scans for a NUL terminator before checking the remaining length. An attacker who can supply untrusted BSON decoded from mmap or array buffers can crash the process with SIGSEGV, a denial of service; the out-of-bounds bytes are not returned.","severity":"high","cvss":5.9,"epss":0.00093,"exploited":false,"exploited_at":null,"products":[{"name":"pymongo","fixed":["4.18.3"],"affected":">= 3.9.0, <= 4.18.2","ecosystem":"pypi"},{"name":"mongodb python driver","fixed":["4.18.3"],"affected":"< 4.18.3","ecosystem":"vendor"}],"ecosystems":["pypi","vendor"],"tags":["bson","cwe-125","mongodb","package","pymongo","python"],"not_affected_if":["nul-terminated-buffers","pure-python-install","trusted-input-only"],"how_to_check":"- Run `pip show pymongo` and confirm the installed version is `4.18.2` or lower, which is affected when the C extension is loaded.\n- Search the codebase for `bson.decode` or `bson.decode_all` calls that take mmap or array input from untrusted sources.","fix":"- Upgrade PyMongo to `4.18.3` or later.\n- Until upgraded, decode untrusted BSON only from `bytes` or `bytearray`, and copy mmap input first, e.g. `bytes(mm[:size])`.","status":"open","published_at":"2026-10-08T21:17:51+00:00","first_seen_at":"2026-10-27T15:39:16+00:00","triaged_at":"2026-10-27T15:39:47+00:00","updated_at":"2026-10-27T16:03:35+00:00","category":"package","confidence":0.8,"triage":{"at":"2026-10-27T15:39:47Z","model":"claude-haiku-5-5","output":{"fix":"- Upgrade PyMongo to `4.18.3` or later.\n- Until upgraded, decode untrusted BSON only from `bytes` or `bytearray`, and copy mmap input first, e.g. `bytes(mm[:size])`.","reach":"network","title":"PyMongo: malformed BSON Regex element crashes the process through an out-of-bounds read","impact":"low","summary":"PyMongo's C BSON decoder reads past the end of the caller's buffer when a Regex element is truncated, because it scans for a NUL terminator before checking the remaining length. An attacker who can supply untrusted BSON decoded from mmap or array buffers can crash the process with SIGSEGV, a denial of service; the out-of-bounds bytes are not returned.","category":"package","nicknames":[],"who_cares":["python","pymongo","mongodb","bson"],"confidence":0.8,"needs_auth":"unknown","worst_case":"Process crashes via uncatchable SIGSEGV, denying service to the application","analyst_note":"","how_to_check":"- Run `pip show pymongo` and confirm the installed version is `4.18.2` or lower, which is affected when the C extension is loaded.\n- Search the codebase for `bson.decode` or `bson.decode_all` calls that take mmap or array input from untrusted sources.","needs_analyst":false,"not_affected_if":["nul-terminated-buffers","trusted-input-only","pure-python-install"],"who_is_affected":"Applications that decode untrusted BSON with the C extension loaded, particularly through bson.decode or bson.decode_all on mmap or array buffers, are exposed. Applications that only decode NUL-terminated bytes or bytearray buffers raise InvalidBSON instead, and the driver's own transport and pure-Python installs are not affected.","user_interaction":"no","needs_special_setup":"yes","severity_if_unknown":"high"},"cost_usd":0.000697,"input_tokens":3670,"output_tokens":659,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-106435':19A,27A '-125':34B '-2026':18A,26A '4.18.2':225C '4.18.3':238C '98qm':22A 'accept':148C,247C 'affect':182C,221C,227C 'applic':174C 'array':82B,151C 'attack':72B 'avail':185C 'bound':7A,98B,192C 'bson':10A,32B,42B,77B,108C,177C,257C 'bson.decode':144C,146C 'buffer':52B,83B,143C,152C,180C,202C,248C,263C 'byte':99B,193C,203C,264C,273C 'bytearray':204C,266C 'c':41B,105C,230C 'caller':50B,141C 'carri':154C 'check':67B,122C 'content':198C 'copi':268C 'craft':130C 'crash':85B 'cross':161C 'cve':17A,25A 'cwe':33B 'decod':11A,43B,78B,109C,175C,252C,255C 'denial':91B 'document':124C,251C 'driver':3A,31A,210C 'e.g':272C 'element':16A,56B,113C,133C,241C 'end':47B,138C 'everi':246C 'extens':106C,231C 'first':271C 'fix':235C 'flag':117C 'ghsa':21A 'ghsa-98qm-wvgf-w4cf':20A 'impact':103C,183C 'input':270C 'instal':218C 'invalidbson':206C,244C 'kill':166C 'length':70B,127C 'load':233C 'malform':14A,239C 'memori':164C 'mm':274C 'mmap':80B,149C,269C 'mongodb':1A,29A,35B 'never':195C 'nul':64B,156C,200C,261C 'nul-termin':199C,260C 'out-of-bound':4A,95B,189C 'packag':36B 'past':45B,136C 'patch':234C 'pattern':115C 'process':87B,168C 'pure':216C 'pure-python':215C 'pymongo':28A,37B,39B,237C 'python':2A,30A,38B,217C 'rais':205C,243C 'read':8A,44B,135C,159C 'regex':15A,55B,112C,132C,240C 'releas':223C 'remain':69B,126C 'return':102B,196C 'scan':61B,110C 'sentinel':157C 'servic':93B 'sigsegv':89B,172C 'sinc':187C 'size':275C 'string':118C 'strlen':120C 'suppli':75B 'termin':65B,201C,262C 'transport':213C 'truncat':58B,131C 'type':249C 'uncatch':171C 'unchang':253C 'unmap':163C 'untrust':76B,176C,256C 'valid':250C 'via':12A 'w4cf':24A 'workaround':254C 'worst':208C 'wvgf':23A","nicknames":[],"mitigations":[],"who_affected":"Applications that decode untrusted BSON with the C extension loaded, particularly through bson.decode or bson.decode_all on mmap or array buffers, are exposed. Applications that only decode NUL-terminated bytes or bytearray buffers raise InvalidBSON instead, and the driver's own transport and pure-Python installs are not affected.","tier":"B","verified":{},"analyst_revisit_at":null,"first_public_at":"2026-10-08T21:17:51+00:00","kev":null,"cvss_vector":"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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X","cvss_by":"cna@mongodb.com","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-98qm-wvgf-w4cf","url":"https://github.com/advisories/GHSA-98qm-wvgf-w4cf","severity":"high","published_at":"2026-10-27T15:36:35+00:00","modified_at":"2026-10-27T15:36:37+00:00","first_seen_at":"2026-10-27T15:39:16+00:00","fetched_at":"2026-10-27T15:39:16+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-106435","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-106435","severity":null,"published_at":"2026-10-08T21:17:51+00:00","modified_at":"2026-10-15T17:00:36+00:00","first_seen_at":"2026-10-27T16:03:35+00:00","fetched_at":"2026-10-27T16:03:35+00:00","note":null}],"documents":[],"notice":"Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai"}