You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Observation: The payload of inbound PUBLISH packets with Properties exceeding 127 bytes in length is not decoded correctly. The decoding logic does not consider any extra bytes in the Properties Variable Byte Integer header when decoding subsequent data.
The issue has been discovered using Mochi MQTT v2.1.6 and is also present in later (and earlier) v2 versions.
To reproduce: Publish the following PUBLISH packet on an MQTT v5 client connected to Mochi MQTT using protocol version 5:
After decoding, the payload bytes which are sent to the subscribers look like this (see debug hook output above):
[98 1 2 3 4 5]
The decoded payload includes an extra leading byte 98 ("b"), which is the last byte of the encoded Properties bytes, i.e. the last character of the value "pub" belonging to User Property key "sr".
This issue happens whenever Properties of an encoded CONNECT, CONNACK, PUBLISH, SUBACK, SUBSCRIBE, UNSUBACK, UNSUBSCRIBE packet require a VBI which consists of more than 1 byte. Subsequent data "overlaps" with the preceding Properties, including up to 3 of the Properties final bytes at the beginning. The reason is that Mochi decoding function (packets.Properties).Decode does not take into account any extra bytes occupied by the Properties VBI header for decoding subsequent data.
Observation: The payload of inbound PUBLISH packets with Properties exceeding 127 bytes in length is not decoded correctly. The decoding logic does not consider any extra bytes in the Properties Variable Byte Integer header when decoding subsequent data.
The issue has been discovered using Mochi MQTT v2.1.6 and is also present in later (and earlier) v2 versions.
To reproduce: Publish the following PUBLISH packet on an MQTT v5 client connected to Mochi MQTT using protocol version 5:
Enabling Mochi debug hook, the PUBLISH packet received and decoded by Mochi looks like this:
The corresponding PUBLISH packet bytes look like this:
After decoding, the payload bytes which are sent to the subscribers look like this (see debug hook output above):
[98 1 2 3 4 5]
The decoded payload includes an extra leading byte 98 ("b"), which is the last byte of the encoded Properties bytes, i.e. the last character of the value "pub" belonging to User Property key "sr".
This issue happens whenever Properties of an encoded CONNECT, CONNACK, PUBLISH, SUBACK, SUBSCRIBE, UNSUBACK, UNSUBSCRIBE packet require a VBI which consists of more than 1 byte. Subsequent data "overlaps" with the preceding Properties, including up to 3 of the Properties final bytes at the beginning. The reason is that Mochi decoding function
(packets.Properties).Decode
does not take into account any extra bytes occupied by the Properties VBI header for decoding subsequent data.To fix this issue, I have prepared a PR.
Thanks for providing a patch release!
The text was updated successfully, but these errors were encountered: