Cloudanix VulnDB

CVE-2024-8948

High · 7.3

heap-buffer-overflow in MicroPython

CVSS

7.3

EPSS

1.0%

Published

Sep 17, 2024

CISA due date

—

Cloudanix analysis

Monitor only SSVC: Track

A bug in widely used lightweight Python software for small devices lets attackers remotely crash or take over those devices by sending specially crafted data.

Exploitation
Remote Unauthenticated
Attacker needs
None
Complexity
Low
Impact
Data Tampering
Component
Library
Class
Memory Corruption
Remediation
Patch
Effort
Low
Patch risk
Low

What it actually does

Heap-based buffer overflow write in mpz_as_bytes (py/objint.c) triggered when converting an integer value of zero to its byte representation.

Why it matters to the business

Attackers may crash MicroPython-based devices or execute arbitrary code, disrupting IoT, embedded, and automation systems that rely on this runtime.

How an attack unfolds

An attacker sends a remotely crafted integer conversion request that reaches mpz_as_bytes with a zero value; the missing length check allows an out-of-bounds write on the heap, potentially leading to code execution.

How to fix it

Upgrade micropython/micropython to commit 908ab1ceca15ee6fd0ef82ca4cba770a3ec41894 or later; rebuild and redeploy all affected firmware images.

How to confirm the fix worked

Confirm the installed commit hash is 908ab1ceca15ee6fd0ef82ca4cba770a3ec41894 or newer; re-run unit tests covering int-to-bytes conversion of zero and monitor for crashes or sanitizer violations.

Typical attack path

  1. Locate a network-reachable MicroPython instance exposing integer-to-bytes conversion surfaces
  2. Craft and transmit a zero integer value that reaches mpz_as_bytes without proper bounds checking
  3. Trigger the heap buffer overflow write to corrupt adjacent memory structures
  4. Leverage the corruption for arbitrary code execution or denial of service

How to detect it

Review application and system logs for unexpected crashes or memory errors during integer conversion routines; inspect heap dumps or sanitizer reports for out-of-bounds writes in mpz_as_bytes; correlate with network traffic containing integer serialization requests.

What your security team should do

  • Immediately update all MicroPython deployments to the patched commit
  • Scan source trees and build pipelines for the vulnerable objint.c file
  • Disable or sandbox remote interfaces that accept untrusted integer conversions until patched
  • Monitor vendor advisories for downstream firmware updates

The record

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.

Affected packages

Ecosystem Package Introduced Fixed
PyPI micropython-copy 0 No fix
PyPI micropython-io 0 No fix
PyPI micropython-os 0 No fix
Debian:13 micropython 0 No fix
Debian:14 micropython 0 1.24.0+ds-1
Ubuntu:20.04:LTS micropython 0 No fix
Ubuntu:22.04:LTS micropython 0 No fix
Ubuntu:24.04:LTS micropython 0 No fix
Ubuntu:24.10 micropython 0 No fix
Ubuntu:Pro:20.04:LTS micropython 0 No fix

Related vulnerabilities