Skip to content

MQTT: do not crash when MQTTPublish has no underlayer - #5089

Open
DSeaStar wants to merge 1 commit into
secdev:masterfrom
DSeaStar:fix/mqtt-publish-no-underlayer
Open

MQTT: do not crash when MQTTPublish has no underlayer#5089
DSeaStar wants to merge 1 commit into
secdev:masterfrom
DSeaStar:fix/mqtt-publish-no-underlayer

Conversation

@DSeaStar

Copy link
Copy Markdown

Fixes #5071.

MQTTPublish reads QOS and len from pkt.underlayer in the msgid condition and the value length callback. Building or displaying a publish packet with no underlayer (MQTTPublish().show()) raised AttributeError: 'NoneType' object has no attribute 'QOS'.

Both callbacks now treat a missing underlayer as QoS 0 / empty payload, which matches how a standalone publish is constructed. Existing layered build/dissect tests are unchanged.

Repro that used to crash:

from scapy.contrib.mqtt import MQTTPublish
MQTTPublish().show()

./test/run_tests -P "load_contrib('mqtt')" -t test/contrib/mqtt.uts — 25 passed.

MQTTPublish.msgid and MQTTPublish.value read QOS/len from the underlayer
without a None check, so MQTTPublish().show() raised AttributeError.
Guard both callbacks so a standalone publish packet can be displayed.

Fixes secdev#5071

AI-Assisted: yes
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.

Missing pkt.underlayer causes MQTT to fail

1 participant