GHSA-98qm-wvgf-w4cf: Pip/pymongo vulnerability

Published Oct 27, 2026
·
Updated

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.decodeall 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]).

Affected Software

1 affected componentFixes available
pip/pymongo>=3.9.0<=4.18.2
4.18.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/pymongo to a version that resolves this vulnerability.

    Fixed in 4.18.3
  2. Upgrade

    Upgrade PyMongo to a version that resolves this vulnerability.

    Fixed in 4.18.3
  3. Compensating control

    Decode untrusted BSON only from NUL-terminated bytes or bytearray buffers, and copy mmap input before decoding, for example with bytes(mm[:size]).

Event History

Oct 27, 2026
Advisory Published
via GitHub·03:36 PM
Data Sourced
via GitHub·03:36 PM
DescriptionWeaknessAffected Software

Frequently Asked Questions

1

Which applications are exposed to the crash risk?

Applications are affected if they decode untrusted BSON using PyMongo's C extension from mmap or array buffers. The driver's own transport and pure-Python installations are not affected.

2

What does an attacker need to trigger the issue?

An attacker needs to cause the application to decode a crafted, truncated BSON Regex element from an mmap or array buffer. The outcome is a process crash through an uncatchable SIGSEGV; out-of-bounds data is not returned.

3

Are common bytes-based decoding paths affected?

NUL-terminated bytes and bytearray buffers do not have the crash behavior. Malformed input on those buffer types raises InvalidBSON at worst.

4

What can be done before upgrading?

Decode untrusted BSON only from bytes or bytearray buffers. For mmap input, copy the relevant data first, for example with bytes(mm[:size]).

5

How can the issue be remediated?

Upgrade to PyMongo 4.18.3. The fix makes malformed Regex elements raise InvalidBSON for every accepted buffer type while leaving valid document decoding unchanged.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203