GHSA-cr6f-gf5w-vhrc: Pymongo PyMongo Out-of-bounds Read Vulnerability

MODERATE
CVSS 5.2
CWE-125
Published
Advisory Summary

GHSA-cr6f-gf5w-vhrc is a MODERATE (CVSS 5.2) pymongo out-of-bounds read vulnerability (CWE-125: Out-of-bounds Read) affecting Pymongo libraries in the PyPI ecosystem. The issue involves pymongo out-of-bounds read in the bson module. Remediation is available by upgrading affected packages to version 4.6.3.

GHSA-cr6f-gf5w-vhrc at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-cr6f-gf5w-vhrc
Severity MODERATE
CVSS v3.1 Base Score 5.2
CWE Classification CWE-125: Out-of-bounds Read
Affected Product Pymongo
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:L).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix GHSA-cr6f-gf5w-vhrc

To remediate this vulnerability, upgrade all affected Pymongo dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pymongo fixed: 4.6.3
pip install pymongo>=4.6.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show pymongo

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-cr6f-gf5w-vhrc, inspect your installed packages using pip:

pip show pymongo

Analyze the terminal output to locate any version of Pymongo in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.6.3), your application is affected.

Note: The pip show pymongo command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-125: Out-of-bounds Read, where the product reads data past the end, or before the beginning, of the intended buffer. In Pymongo, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Versions of the package pymongo before 4.6.3 are vulnerable to Out-of-bounds Read in the bson module. Using the crafted payload the attacker could force the parser to deserialize unmanaged memory. The parser tries to interpret bytes next to buffer and throws an exception with string. If the following bytes are not printable UTF-8 the parser throws an exception with a single byte. This advisory was initially published as CVE-2024-21506, which has since been rejected as a duplicate of CVE-2024-5629.

GHSA-cr6f-gf5w-vhrc Affected Pymongo Versions

1 component(s)
Fixed Versions:
4.6.3
Product / Package Ecosystem Affected Versions Fixed Version
pymongo
PyPI
< 4.6.3
4.6.3

References

Frequently Asked Questions

What is GHSA-cr6f-gf5w-vhrc?
GHSA-cr6f-gf5w-vhrc is a security vulnerability in Pymongo involving PyMongo Out-of-bounds Read in the bson module under CWE-125: Out-of-bounds Read.
Which Pymongo versions are affected?
Affected versions include releases prior to 4.6.3 across affected packages: pymongo.
What version fixes GHSA-cr6f-gf5w-vhrc?
Upgrading to 4.6.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pymongo affected?
Yes, pymongo is affected in releases prior to 4.6.3. Upgrade your dependency to 4.6.3 or later.
What is the CVSS score of GHSA-cr6f-gf5w-vhrc?
GHSA-cr6f-gf5w-vhrc has a CVSS v3.1 base score of 5.2 (MODERATE) with vector string CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:L.
What CWE is associated with GHSA-cr6f-gf5w-vhrc?
GHSA-cr6f-gf5w-vhrc is classified under CWE-125: Out-of-bounds Read (The product reads data past the end, or before the beginning, of the intended buffer.).
How can I check PyPI dependencies for GHSA-cr6f-gf5w-vhrc?
Run the dependency tree command: 'pip show pymongo'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cr6f-gf5w-vhrc",
  "modified" : "2024-06-05T17:11:58Z",
  "published" : "2024-04-06T06:31:08Z",
  "withdrawn" : "2024-06-05T17:11:58Z",
  "aliases" : [ ],
  "summary" : "PyMongo Out-of-bounds Read in the bson module ",
  "details" : "Versions of the package pymongo before 4.6.3 are vulnerable to Out-of-bounds Read in the bson module. Using the crafted payload the attacker could force the parser to deserialize unmanaged memory. The parser tries to interpret bytes next to buffer and throws an exception with string. If the following bytes are not printable UTF-8 the parser throws an exception with a single byte.\n\nThis advisory was initially published as CVE-2024-21506, which has since been rejected as a duplicate of CVE-2024-5629.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pymongo"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.6.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-21506"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mongodb/mongo-python-driver/commit/56b6b6dbc267d365d97c037082369dabf37405d2"
  }, {
    "type" : "WEB",
    "url" : "https://gist.github.com/keltecc/62a7c2bf74a997d0a7b48a0ff3853a03"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mongodb/mongo-python-driver"
  }, {
    "type" : "WEB",
    "url" : "https://security.snyk.io/vuln/SNYK-PYTHON-PYMONGO-6370597"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-125" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-08T15:40:17Z",
    "nvd_published_at" : "2024-04-06T05:15:07Z"
  }
}