CVE-2026-56111
Received Received - Intake
Marlin Firmware Out-of-Bounds Write via M421 G-code

Publication date: 2026-06-24

Last updated on: 2026-06-24

Assigner: VulnCheck

Description
Marlin Firmware through 2.1.2.7, fixed in commit 1f255d1, when built with MESH_BED_LEVELING enabled, contains an out-of-bounds write vulnerability in the M421 G-code handler that allows attackers to corrupt firmware memory by supplying out-of-range X and Y grid indices. Attackers can send a single crafted G-code command via USB serial, network interface, or malicious gcode file to write an attacker-controlled 32-bit float value past the z_values array bounds, corrupting adjacent firmware variables and causing denial of service or firmware state corruption.
CVSS Scores
EPSS Scores
Probability:
Percentile:
Meta Information
Published
2026-06-24
Last Modified
2026-06-24
Generated
2026-06-25
AI Q&A
2026-06-24
EPSS Evaluated
N/A
NVD
EUVD
Affected Vendors & Products
Showing 2 associated CPEs
Vendor Product Version / Range
marlin_firmware marlin_firmware 2.1.2.7
marlin_firmware marlin_firmware to 2.1.2.7 (inc)
Helpful Resources
Exploitability
CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-129 The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.
Attack-Flow Graph
AI Quick Actions
Instant insights powered by AI
Executive Summary

CVE-2026-56111 is an out-of-bounds write vulnerability in Marlin Firmware versions up to 2.1.2.7 when built with MESH_BED_LEVELING enabled. The vulnerability exists in the M421 G-code handler, which is responsible for mesh bed leveling. It fails to properly validate the upper bounds of the X and Y grid indices, allowing attackers to supply out-of-range indices.

By sending a single crafted M421 G-code command via USB serial, network interface, or a malicious gcode file, an attacker can write an attacker-controlled 32-bit float value beyond the bounds of the z_values array. This out-of-bounds write corrupts adjacent firmware memory, potentially causing denial of service or firmware state corruption.

The issue was fixed in commit 1f255d1 by adding strict upper bound checks on the indices, ensuring they fall within valid ranges defined by GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y.

Impact Analysis

This vulnerability can impact you by allowing an attacker to corrupt the firmware memory of a device running the affected Marlin Firmware. Specifically, by exploiting the out-of-bounds write, an attacker can cause denial of service or corrupt the firmware's internal state.

Such corruption can lead to unpredictable device behavior, crashes, or failure to operate correctly, which may disrupt 3D printing operations or other functions relying on the firmware.

The attack can be executed remotely via USB serial, network interface, or by providing a malicious gcode file, making it a practical risk if the device interfaces are exposed.

Detection Guidance

This vulnerability can be detected by monitoring for the presence of crafted M421 G-code commands that contain out-of-range X and Y grid indices sent via USB serial, network interface, or malicious gcode files.

Specifically, detection involves checking if any M421 commands have indices outside the valid range of 0 to GRID_MAX_POINTS_X - 1 for X and 0 to GRID_MAX_POINTS_Y - 1 for Y, which in default configurations is typically 0 to 2.

You can inspect logs or intercept G-code commands sent to the firmware and look for M421 commands with invalid indices.

Example commands to detect suspicious M421 usage might include:

  • Using a serial monitor or network sniffer, filter for M421 commands and check their parameters.
  • Example grep command on logs: grep '^M421' <logfile> | awk '{if ($2 < 0 || $2 > 2 || $3 < 0 || $3 > 2) print $0}'
  • Use firmware debugging or verbose logging modes to capture and analyze incoming G-code commands.
Mitigation Strategies

The immediate mitigation step is to update the Marlin firmware to a version that includes the fix from commit 1f255d1 or later.

This fix enforces proper bounds checking on the M421 G-code handler, ensuring that X and Y indices are within valid ranges and preventing out-of-bounds writes.

Until the firmware is updated, restrict or monitor access to interfaces that accept G-code commands (USB serial, network, or file uploads) to prevent attackers from sending crafted M421 commands.

Additionally, consider disabling MESH_BED_LEVELING if it is not required, as the vulnerability only exists when this feature is enabled.

Compliance Impact

The provided information does not specify any direct impact of this vulnerability on compliance with common standards and regulations such as GDPR or HIPAA.

Chat Assistant
Ask questions about this CVE
Hi! I’m here to help you understand CVE-2026-56111. Ask me anything about the vulnerability, its impact, or mitigation strategies.
0/70
EPSS Chart