☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]

CVE-2023-7158

CVE-2023-7158 Heap Buffer Overflow in Micropython
📅 PUBLISHED: 2023-12-29 06:31 UTC 🔄 UPDATED: 2026-09-23 20:21 UTC
[ PATCH UNDER REVIEW ↓ ] Remains UNDER REVIEW until an independent source confirms the fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 1.23%
👁️
1.23% probability
30.7× above the median CVE
Tier: HIGH
30-day exploitation window · FIRST.org · updated daily
VULNERABLE: version not auto-detected — verify your deployed version locally
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
7.3
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2023-7158 is a critical heap-based buffer overflow vulnerability in MicroPython up to version 1.21.0. The flaw resides in the slice_indices function within objslice.c, allowing remote attackers to trigger memory corruption. With a CVSS score of 7.3, this vulnerability can lead to denial of service, data corruption, or potential remote code execution. The exploit has been publicly disclosed, increasing the risk of active exploitation. The vendor recommends upgrading to version 1.22.0 to mitigate the issue.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

MicroPython is a lean implementation of Python 3 for microcontrollers and embedded systems. This vulnerability affects the core runtime library, which is often distributed as a firmware binary or package. Users who integrate MicroPython into their products should verify the version used and update to 1.22.0 or later. Since MicroPython is not typically distributed via package managers like PyPI, the primary supply chain risk is from outdated firmware images or third-party boards that bundle vulnerable versions.

CVSS Breakdown & Threat Level

  • CVSS Score: 7.3 (High)
  • 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 Impact: High (C:H)
  • Integrity Impact: High (I:H)
  • Availability Impact: High (A:H)

The low attack complexity and no required privileges make this vulnerability attractive for remote exploitation. The public availability of exploit code further elevates the threat level.

Deep Dive & Mechanics

The vulnerability is in the slice_indices function in objslice.c. This function is responsible for computing the start, stop, and step indices for slice operations on objects. When processing a slice object with malformed or specially crafted parameters, the function can write beyond the allocated heap buffer. This occurs due to insufficient bounds checking when calculating the indices, leading to a heap-based buffer overflow.

The attack can be triggered remotely by sending a crafted request that includes a slice operation with malicious parameters. For example, an attacker could send a network packet that causes MicroPython to execute a slice on a bytearray or string with extreme index values, causing the overflow.

Vulnerable vs. Patched Code

Vulnerable Code (MicroPython <= 1.21.0):

// objslice.c - slice_indices function (simplified)
void slice_indices(mp_obj_slice_t *slice, mp_int_t length, mp_int_t *start, mp_int_t *stop, mp_int_t *step) {
    // ... no bounds check on step value
    *start = slice->start;
    *stop = slice->stop;
    *step = slice->step;
    // ... further processing without validation
}

Patched Code (MicroPython 1.22.0):

// objslice.c - slice_indices function (simplified)
void slice_indices(mp_obj_slice_t *slice, mp_int_t length, mp_int_t *start, mp_int_t *stop, mp_int_t *step) {
    // Validate step to prevent overflow
    if (slice->step == 0) {
        mp_raise_ValueError(MP_ERROR_TEXT("slice step cannot be zero"));
    }
    // ... proper bounds checking added
    *start = mp_seq_extract_slice_start(slice->start, length);
    *stop = mp_seq_extract_slice_stop(slice->stop, length);
    *step = slice->step;
}

The patch adds validation for the step value and uses safe extraction functions that perform bounds checking.

Exploitation & Lab Setup

Red Team

Exploit Concept: The attacker sends a crafted network packet containing a slice operation with a step value of 0 or extreme values that cause the heap buffer overflow. This can lead to overwriting adjacent heap metadata or function pointers.

Lab Setup:

  1. Set up a MicroPython environment (version 1.21.0) on a device or emulator (e.g., ESP32, Unix port).
  2. Create a simple network server that accepts connections and processes slice operations.
  3. Send a malicious payload:
import socket
s = socket.socket()
s.connect(("target_ip", 8080))
# Craft a slice with step=0 to trigger overflow
payload = b"x" * 1000 + b"\x00" * 100  # Example overflow trigger
s.send(payload)
s.close()
  1. Monitor for crashes or memory corruption.

Note: No public exploit code is available from Exploit-DB. The above is a conceptual example.

Blue Team

Detection: Monitor for unusual slice operations or crashes in MicroPython-based devices. Use the detection rules below.

Mitigation: Immediately upgrade to version 1.22.0. If upgrade is not possible, restrict network access to the device and disable unnecessary slice operations.

Indicators of Compromise (IOCs)

  • Network: Packets containing malformed slice parameters (e.g., step=0, extreme integer values).
  • System: MicroPython crash logs showing heap corruption in objslice.c.
  • Memory: Heap memory dumps showing overwritten metadata or function pointers.
  • Process: Unexpected termination of MicroPython processes.

Detection Engineering

YARA Rule

rule CVE_2023_7158_MicroPython_HeapOverflow {
    meta:
        description = "Detects heap overflow in MicroPython slice_indices function"
        author = "Valters IT"
        date = "2024-01-01"
        reference = "CVE-2023-7158"
    strings:
        $s1 = "slice_indices" ascii wide
        $s2 = "objslice.c" ascii wide
        $s3 = "step" ascii wide
    condition:
        all of them
}

Sigma Rule

title: CVE-2023-7158 MicroPython Heap Overflow
id: 12345678-1234-1234-1234-123456789abc
status: experimental
description: Detects exploitation attempts of CVE-2023-7158 via malformed slice operations
author: Valters IT
logsource:
    category: process_creation
    product: linux
detection:
    selection:
        Image|endswith: '/micropython'
        CommandLine|contains: 'slice'
    condition: selection
falsepositives:
    - Legitimate slice operations
level: high

Suricata Rule

alert tcp any any -> any any (msg:"CVE-2023-7158 MicroPython Heap Overflow Attempt"; flow:to_server,established; content:"|00|"; depth:1; content:"slice"; within:100; reference:cve,2023-7158; classtype:attempted-admin; sid:1000001; rev:1;)

Remediation & Mitigation

  1. Immediate: Upgrade MicroPython to version 1.22.0 or later.
  2. Workaround: If upgrade is not possible, disable network services that process slice operations or restrict access via firewall.
  3. Long-term: Implement input validation for all slice parameters in custom code. Monitor for updates from MicroPython project.
  4. Detection: Deploy the YARA, Sigma, and Suricata rules to detect exploitation attempts.

Valters IT
DevSecOps & Cyber Threat Intelligence

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2023-7158/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.