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
{{ message }}
Repository navigation
mqtt: Maximum Packet Size and publish QoS limit leak across connections on a worker #3129
MqttServerFactory keeps per-connection limits in fields of the factory, which is shared by every connection on an engine worker (line numbers on develop at 1e802cb).
maximumPacketSize (field, line 429) is lowered with Math.min by every CONNECT that carries Maximum Packet Size (line 3046) and is never restored. It is then used for the inbound packet size checks (lines 988, 1023, 1074, 1164) and for the outbound drop of oversized PUBLISH (line 7039) on all later connections of that worker.
publishQosMax (field, line 510) is overwritten from every session BEGIN (line 5841), so a connection sees whatever the most recent session on the worker reported.
MQTT 5.0 section 3.1.2.11.4: the Maximum Packet Size in CONNECT is the largest packet the Client is willing to accept, so it limits packets the server sends to that client. It has no effect on other connections, and it does not limit what the server accepts from that client.
Expected
Both values are state of the connection (the MqttServer stream), set when that connection's CONNECT / session BEGIN is decoded and never visible to another connection.
The client's declared Maximum Packet Size limits only packets sent to that client. The inbound check uses the server's own limit (none unless one is configured).
A duplicate Maximum Packet Size property in CONNECT is detected (the duplicate check currently uses the Topic Alias Maximum mask, line 3047).
Test plan (test-first)
Spec scripts for v5 (and v4 where applicable), run through the runtime MqttServerITs, with two connections on the same binding on the same worker:
connection 1 declares a small Maximum Packet Size; connection 2 declares none and exchanges a larger PUBLISH in both directions;
two sessions whose application BEGIN reports different publish QoS maximums keep their own limit;
a CONNECT with a duplicate Maximum Packet Size gets the protocol error.
The first commit contains the failing scripts, to confirm the leak before the change.
Notes
Found by a clause-by-clause audit of MQTT 3.1.1 and 5.0 conformance, by reading the code. Advertising the server's own Maximum Packet Size / Receive Maximum in CONNACK is out of scope here. Part of the MQTT conformance work under #512.
Activity
fix(binding-mqtt): scope maximum packet size and publish qos max to t…
fix(binding-mqtt): scope maximum packet size and publish qos max to t…