Skip to content

Fix heap-buffer-overflow in ModbusLayer on truncated packets#2159

Open
SAY-5 wants to merge 1 commit into
seladb:devfrom
SAY-5:say5-modbus-oob
Open

Fix heap-buffer-overflow in ModbusLayer on truncated packets#2159
SAY-5 wants to merge 1 commit into
seladb:devfrom
SAY-5:say5-modbus-oob

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Jun 2, 2026

Fixes #2155

A TCP packet to port 502 with fewer than 8 payload bytes was still parsed as a ModbusLayer, so the header getters (getTransactionId, getLength, toString, etc.) read past the end of the buffer. This adds a ModbusLayer::isDataValid check on the payload length before constructing the layer, matching how GtpV2Layer and BgpLayer guard their parsing. Added a regression test with a truncated Modbus packet that fails without the guard.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5 SAY-5 requested a review from seladb as a code owner June 2, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant