CVE-2026-71256: nanoMODBUS Client-Side Out-of-Bounds Read Leading to Wild-Pointer Write via object_id
nanoMODBUS through v1.23.0 contains an out-of-bounds stack read leading to a wild-pointer write in nmbsreaddeviceidentificationbasic() / recvreaddeviceidentificationres() in nanomodbus.c. A fixed 3-element stack array order[3] = {0,1,2} maps object IDs to buffer indices. The server-supplied objectid field (0-255, read directly from the wire) is used without any bounds check as bufindex = order[objectid]. When a malicious Modbus server sends a Read Device Identification response with objectid >= 3, this reads an out-of-bounds/garbage byte from the stack adjacent to order[], which is then used as an index into a 3-element buffers[] array of char pointers. The resulting wild pointer is passed to strncpy() as the destination, causing an arbitrary-address write with server-controlled data.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
nanoMODBUSto a version that resolves this vulnerability.Fixed in v1.23.0 - Compensating control
If you cannot patch immediately, restrict/deny connections to untrusted Modbus servers so attacker-controlled Read Device Identification responses (with object_id >= 3) cannot be received by nanoMODBUS.
Event History
Frequently Asked Questions
What is the severity of CVE-2026-71256?
The severity of CVE-2026-71256 is classified as high with a score of 8.1.
How do I fix CVE-2026-71256?
To fix CVE-2026-71256, update to the latest version of nanoMODBUS that includes the patch for this vulnerability.
What type of vulnerability is CVE-2026-71256?
CVE-2026-71256 is an out-of-bounds read vulnerability leading to a wild-pointer write.
What might be the impact of exploiting CVE-2026-71256?
Exploiting CVE-2026-71256 may lead to potential crashes or arbitrary code execution due to a corrupted memory state.
Which versions of nanoMODBUS are affected by CVE-2026-71256?
CVE-2026-71256 affects nanoMODBUS versions up to and including v1.23.0.