CVE-2024-8947: Micropython copy Use After Free Vulnerability

MODERATE
Advisory Identifier: GHSA-pwwp-3q7j-9mx8
CVSS 5.6
CWE-416
Published
Advisory Summary

CVE-2024-8947 is a MODERATE (CVSS 5.6) use after free vulnerability (CWE-416: Use After Free) affecting Micropython copy libraries in the PyPI ecosystem. The issue involves use after free in micropython. Remediation is available in the latest vendor maintenance releases.

CVE-2024-8947 at a Glance

CVE Identifier CVE-2024-8947
GHSA Identifier GHSA-pwwp-3q7j-9mx8
Severity MODERATE
CVSS v3.1 Base Score 5.6
CWE Classification CWE-416: Use After Free
Affected Product Micropython copy
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.6

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

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
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-8947

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
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-8947, 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-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. 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.22.2. It has been declared as critical. Affected by this vulnerability is an unknown functionality of the file py/objarray.c. The manipulation leads to use after free. The attack can be launched remotely. The complexity of an attack is rather high. The exploitation appears to be difficult. Upgrading to version 1.23.0 is able to address this issue. The identifier of the patch is 4bed614e707c0644c06e117f848fa12605c711cd. It is recommended to upgrade the affected component. In micropython objarray component, when a bytes object is resized and copied into itself, it may reference memory that has already been freed.

CVE-2024-8947 Affected Micropython copy Versions

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

References

Frequently Asked Questions

What is CVE-2024-8947?
CVE-2024-8947 is a security vulnerability in Micropython copy involving Use After Free in MicroPython under CWE-416: Use After Free.
Which Micropython copy versions are affected?
Affected versions include releases prior to current release patches across affected packages: micropython-copy, micropython-io.
What version fixes CVE-2024-8947?
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-8947?
CVE-2024-8947 has a CVSS v3.1 base score of 5.6 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2024-8947?
CVE-2024-8947 is classified under CWE-416: Use After Free (The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.).
How can I check PyPI dependencies for CVE-2024-8947?
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-pwwp-3q7j-9mx8",
  "modified" : "2024-09-25T18:18:16Z",
  "published" : "2024-09-17T21:30:32Z",
  "aliases" : [ "CVE-2024-8947" ],
  "summary" : "Use After Free in MicroPython",
  "details" : "A vulnerability was found in MicroPython 1.22.2. It has been declared as critical. Affected by this vulnerability is an unknown functionality of the file py/objarray.c. The manipulation leads to use after free. The attack can be launched remotely. The complexity of an attack is rather high. The exploitation appears to be difficult. Upgrading to version 1.23.0 is able to address this issue. The identifier of the patch is 4bed614e707c0644c06e117f848fa12605c711cd. It is recommended to upgrade the affected component. In micropython objarray component, when a bytes object is resized and copied into itself, it may reference memory that has already been freed.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:H/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"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-8947"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/issues/13283"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/issues/13283#issuecomment-1918479709"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/commit/4bed614e707c0644c06e117f848fa12605c711cd"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micropython/micropython/releases/tag/v1.23.0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-copy/PYSEC-2024-92.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/micropython-io/PYSEC-2024-94.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?ctiid.277765"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?id.277765"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?submit.409316"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-416" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-25T18:18:16Z",
    "nvd_published_at" : "2024-09-17T19:15:29Z"
  }
}