CVE-2026-29972

Stack-Based Buffer Overflow in nanoMODBUS Library Allows Remote Code Execution

Published May 8, 2026 CVSS 3.1 · 8.2 High EPSS < 1% KEV · Not listed
Description
nanoMODBUS through v1.22.0 has a stack-based buffer overflow in recv_read_registers_res() in nanomodbus.c. When a client calls nmbs_read_holding_registers() or nmbs_read_input_registers(), the library writes register data from the server response to the caller-provided buffer based on the response's byte_count field before validating that byte_count matches the requested quantity. A malicious Modbus TCP server can send a response with byte_count=250 (125 registers) regardless of the requested quantity, causing up to 248 bytes of attacker-controlled data to overflow the buffer, potentially allowing remote code execution.

Analysis

AI-generated

Technical impact

nanoMODBUS versions up to and including v1.22.0 suffer a stack-based buffer overflow in the recv_read_registers_res() routine. When a client invokes reading functions, the library transfers register data received from a Modbus TCP server to a caller-supplied buffer based on the response’s byte_count field before checking that the byte_count matches the originally requested quantity. A malicious server can advertise an excessively large byte_count, causing the library to write up to 248 bytes beyond the buffer’s boundary and potentially enable arbitrary code execution on the client system. This flaw is a classic buffer overflow and can be exploited remotely by an attacker who can control or impersonate a Modbus TCP server. The vulnerability can compromise confidentiality, integrity, and availability of the system that runs the affected library.

Affected Systems

The affected product is the nanoMODBUS library, any builds with a version number of 1.22.0 or earlier are vulnerable. No specific vendor is listed in the CNA data, but the library is commonly included in embedded or industrial control systems that communicate over Modbus TCP.

Risk and Exploitability

The CVSS score is 8.2, indicating high severity. The EPSS score is unavailable, so the exploitation probability remains uncertain. The vulnerability is not listed in the CISA KEV catalog, indicating no cataloged public exploits. The likely attack vector is remote and requires a malicious Modbus TCP server sending a forged byte_count that exceeds the requested quantity, triggering a stack-based overflow and potentially enabling remote code execution on the client system.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade nanoMODBUS to the latest release that includes a fix for the recv_read_registers_res() buffer overflow
  • If an update is unavailable, isolate Modbus clients from untrusted servers by limiting network connectivity to known, trusted Modbus sources
  • Implement local input validation to ensure the byte_count returned by a server matches the requested quantity or constrain the copy size to the caller’s buffer length before copying

Generated by OpenCVE AI on May 8, 2026 at 19:33 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
First Time appeared Debevv
Debevv nanomodbus
Vendors & Products Debevv
Debevv nanomodbus
Type Values Removed Values Added
Title Stack-Based Buffer Overflow in nanoMODBUS Library Allows Remote Code Execution
Type Values Removed Values Added
Weaknesses CWE-121
Metrics cvssV3_1

{'score': 8.2, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H'}

ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description nanoMODBUS through v1.22.0 has a stack-based buffer overflow in recv_read_registers_res() in nanomodbus.c. When a client calls nmbs_read_holding_registers() or nmbs_read_input_registers(), the library writes register data from the server response to the caller-provided buffer based on the response's byte_count field before validating that byte_count matches the requested quantity. A malicious Modbus TCP server can send a response with byte_count=250 (125 registers) regardless of the requested quantity, causing up to 248 bytes of attacker-controlled data to overflow the buffer, potentially allowing remote code execution.
References
Weaknesses
  • CWE-121

    Stack-based Buffer Overflow

Sources

Status
PUBLISHED
Assigner
mitre
Published
Updated
May 8, 2026, 3:59 PM
Reserved
Mar 4, 2026, 12:00 AM
Status
Deferred
Published
May 8, 2026, 4:16 PM
Modified
Jun 17, 2026, 10:29 AM