nanoMODBUS versions through 1.22.0 contain a stack-based buffer overflow vulnerability in the recv_read_registers_res() function. This occurs when the library writes register data from a server response to a caller-provided buffer based on the response's byte_count field without validating that byte_count matches the requested quantity. A malicious Modbus TCP server can exploit this by sending a response with an inflated byte_count value, causing up to 248 bytes of data to overflow the buffer, potentially enabling remote code execution.