]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: mqtt: reject invalid CONNECT flags and MQTT 3.1.1 CONNACK return codes
authorMartin Mirchev <mirchevmartin2203@gmail.com>
Wed, 18 Nov 2026 12:35:30 +0000 (20:35 +0800)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 Nov 2026 11:36:58 +0000 (12:36 +0100)
commit795b4688ef325242fc9a645e411ccae1cdd596a1
tree3c2704675cac5449c162e5dd97e3fb84a972fb10
parentd77d76a440459e9d9a45e728257487d9a51ca59d
BUG/MINOR: mqtt: reject invalid CONNECT flags and MQTT 3.1.1 CONNACK return codes

mqtt_is_valid() and the mqtt_field_value() converter accept several
messages the specifications forbid:

  - a CONNECT with the Will QoS set to 3. The only check rejected the
    case where both QoS bits are set without the Will flag, so neither
    "Will QoS 3 with Will" nor "Will QoS 1 or Will Retain without Will"
    was caught (MQTT 3.1.1 3.1.2.6/3.1.2.7, MQTT 5.0 3.1.2.6/3.1.2.7);
  - an MQTT 3.1.1 CONNECT with the Password flag but not the User Name
    flag (MQTT 3.1.1 3.1.2.9; MQTT 5.0 allows it, so only 3.1.1 is
    checked);
  - an MQTT 3.1.1 CONNACK with a return code above 5, e.g. 200 (MQTT
    3.1.1 3.2.2.3 only defines 0 to 5).

For example mqtt_is_valid returns 1 for a 3.1.1 CONNECT with flags 0x1c
or 0x40, and for a 3.1.1 CONNACK "20 02 00 c8". Reject these messages.

This should be backported to all stable versions.
src/mqtt.c