Tighten MQTT 3.1.1 packet validation#183
Merged
VolkerChristian merged 1 commit intoJul 10, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
0x01while preserving protocol-level private-bridge bit (0x80) behavior and reflect/masking logic; files changed:src/iot/mqtt/server/Mqtt.cpp.0x00|0x01|0x02are accepted and invalid option bytes cause parse error; file changed:src/iot/mqtt/server/packets/Subscribe.cpp.DUP=1with QoS 0, require non-empty topic, require non-zero packet identifier for QoS>0, and avoiduint16_ttruncation when sizing large payloads; file changed:src/iot/mqtt/server/packets/Publish.cpp.src/iot/mqtt/types/UIntV.cpp.tests/unit/mqtt/Mqtt311PacketValidationTest.cppandtests/unit/mqtt/CMakeLists.txt(and updatedtests/unit/CMakeLists.txt).Testing
cmake -S . -B build -DSNODEC_BUILD_TESTS=ON, builtMqtt311PacketValidationTest, and executed it underctest, all assertions passed for the new validation cases.ctestforMqtt311PacketValidationTestand existingMqttMigration08Test, both passed (100% pass for those targets in CI run performed here).Mqtt311PacketValidationTest(covers CONNECT private-bridge and reserved flag, SUBSCRIBE QoS validation, fixed-header flags, PUBLISH QoS/DUP/packet-id/topic/retain/large-payload, and Remaining Length malformed encodings), and CMake entries to run it as a unit test.mqttbridgesources were not present in the workspace, so end-to-end bridge republish verification against an external secondary broker was not run here; internal broker/packet paths and unit tests confirm private-bridge CONNECT masking and retain-bit preservation so retained-message propagation through mqttbridge remains a no-issue from the SNode.C side based on these tests and code paths.Codex Task