CVE-2024-8948: Micropython copy Heap-buffer-overflow Vulnerability

MODERATE
Advisory Identifier: GHSA-vh3x-525m-jp4r
CVSS 7.3
CWE-122 CWE-787
Published
Advisory Summary

CVE-2024-8948 is a MODERATE (CVSS 7.3) heap-buffer-overflow vulnerability (CWE-122: Heap-based Buffer Overflow) affecting Micropython copy libraries in the PyPI ecosystem. The issue involves heap-buffer-overflow in micropython. Remediation is available in the latest vendor maintenance releases.

CVE-2024-8948 at a Glance

CVE Identifier CVE-2024-8948
GHSA Identifier GHSA-vh3x-525m-jp4r
Severity MODERATE
CVSS v3.1 Base Score 7.3
CWE Classification CWE-122: Heap-based Buffer Overflow
Affected Product Micropython copy
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.3

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

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2024-8948

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

micropython-copy fixed: Latest secure release
pip install micropython-copy>=Latest secure release
micropython-io fixed: Latest secure release
pip install micropython-io>=Latest secure release
micropython-os fixed: Latest secure release
pip install micropython-os>=Latest secure release
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 micropython-copy

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-8948, inspect your installed packages using pip:

pip show micropython-copy

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-122: Heap-based Buffer Overflow, where a heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). In Micropython copy, 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

A vulnerability was found in MicroPython 1.23.0. It has been rated as critical. Affected by this issue is the function mpz_as_bytes of the file py/objint.c. The manipulation leads to heap-based buffer overflow. The attack may be launched remotely. The exploit has been disclosed to the public and may be used. The patch is identified as 908ab1ceca15ee6fd0ef82ca4cba770a3ec41894. It is recommended to apply a patch to fix this issue. In micropython objint component, converting zero from int to bytes leads to heap buffer-overflow-write at mpz_as_bytes.

CVE-2024-8948 Affected Micropython copy Versions

3 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
micropython-copy
PyPI
≤ 3.3.3.post3
micropython-io
PyPI
≤ 0.1
micropython-os
PyPI
≤ 0.8

References

Frequently Asked Questions

What is CVE-2024-8948?
CVE-2024-8948 is a security vulnerability in Micropython copy involving heap-buffer-overflow in MicroPython under CWE-122: Heap-based Buffer Overflow.
Which Micropython copy versions are affected?
Affected versions include releases prior to current release patches across affected packages: micropython-copy, micropython-io, micropython-os.
What version fixes CVE-2024-8948?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is micropython-copy affected?
Yes, micropython-copy is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
Is micropython-io affected?
Yes, micropython-io is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2024-8948?
CVE-2024-8948 has a CVSS v3.1 base score of 7.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2024-8948?
CVE-2024-8948 is classified under CWE-122: Heap-based Buffer Overflow (A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().).
How can I check PyPI dependencies for CVE-2024-8948?
Run the dependency tree command: 'pip show micropython-copy'. 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-vh3x-525m-jp4r",
  "modified" : "2024-09-24T17:34:09Z",
  "published" : "2024-09-17T21:30:32Z",
  "aliases" : [ "CVE-2024-8948" ],
  "summary" : "heap-buffer-overflow in MicroPython",
  "details" : "A vulnerability was found in MicroPython 1.23.0. It has been rated as critical. Affected by this issue is the function mpz_as_bytes of the file py/objint.c. The manipulation leads to heap-based buffer overflow. The attack may be launched remotely. The exploit has been disclosed to the public and may be used. The patch is identified as 908ab1ceca15ee6fd0ef82ca4cba770a3ec41894. It is recommended to apply a patch to fix this issue. In micropython objint component, converting zero from int to bytes leads to heap buffer-overflow-write at mpz_as_bytes.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:L/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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "micropython-copy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "3.3.3.post3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "micropython-io"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "micropython-os"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.8"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-8948"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/issues/13041"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/commit/908ab1ceca15ee6fd0ef82ca4cba770a3ec41894"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-copy/PYSEC-2024-87.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-io/PYSEC-2024-88.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-os/PYSEC-2024-89.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?ctiid.277766"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?id.277766"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?submit.409317"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-122", "CWE-787" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-24T17:34:09Z",
    "nvd_published_at" : "2024-09-17T19:15:29Z"
  }
}