CVE-2024-8946: Micropython copy Heap-based Buffer Overflow Vulnerability

MODERATE
Advisory Identifier: GHSA-74qm-4v7r-jw2f
CVSS 7.3
CWE-122 CWE-787
Published
Advisory Summary

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

CVE-2024-8946 at a Glance

CVE Identifier CVE-2024-8946
GHSA Identifier GHSA-74qm-4v7r-jw2f
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-8946

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-path fixed: Latest secure release
pip install micropython-os-path>=Latest secure release
micropython-string fixed: Latest secure release
pip install micropython-string>=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-8946, 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 classified as critical. Affected is the function mp_vfs_umount of the file extmod/vfs.c of the component VFS Unmount Handler. The manipulation leads to heap-based buffer overflow. It is possible to launch the attack remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 29943546343c92334e8518695a11fc0e2ceea68b. It is recommended to apply a patch to fix this issue. In the VFS unmount process, the comparison between the mounted path string and the unmount requested string is based solely on the length of the unmount string, which can lead to a heap buffer overflow read.

CVE-2024-8946 Affected Micropython copy Versions

4 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
micropython-copy
PyPI
≤ 3.3.3.post3
micropython-io
PyPI
≤ 0.1
micropython-os-path
PyPI
≤ 0.1.3
micropython-string
PyPI
≤ 0.1

References

Frequently Asked Questions

What is CVE-2024-8946?
CVE-2024-8946 is a security vulnerability in Micropython copy involving Heap-based 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-path, micropython-string.
What version fixes CVE-2024-8946?
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-8946?
CVE-2024-8946 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-8946?
CVE-2024-8946 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-8946?
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-74qm-4v7r-jw2f",
  "modified" : "2024-09-25T18:23:41Z",
  "published" : "2024-09-17T21:30:33Z",
  "aliases" : [ "CVE-2024-8946" ],
  "summary" : "Heap-based Buffer Overflow in MicroPython",
  "details" : "A vulnerability was found in MicroPython 1.23.0. It has been classified as critical. Affected is the function mp_vfs_umount of the file extmod/vfs.c of the component VFS Unmount Handler. The manipulation leads to heap-based buffer overflow. It is possible to launch the attack remotely. The exploit has been disclosed to the public and may be used. The name of the patch is 29943546343c92334e8518695a11fc0e2ceea68b. It is recommended to apply a patch to fix this issue. In the VFS unmount process, the comparison between the mounted path string and the unmount requested string is based solely on the length of the unmount string, which can lead to a heap buffer overflow read.",
  "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-path"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.1.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "micropython-string"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-8946"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/issues/13006"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/issues/13006#issuecomment-1820309455"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/commit/29943546343c92334e8518695a11fc0e2ceea68b"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-copy/PYSEC-2024-91.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-io/PYSEC-2024-93.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-os-path/PYSEC-2024-95.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-string/PYSEC-2024-96.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?ctiid.277764"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?id.277764"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?submit.409312"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-122", "CWE-787" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-25T18:23:41Z",
    "nvd_published_at" : "2024-09-17T19:15:29Z"
  }
}