Skip to content

Fix 3705 ws unmasked frames - #3735

Open
v1rtu3x wants to merge 2 commits into
eclipse-mosquitto:masterfrom
v1rtu3x:fix-3705-ws-unmasked-frames
Open

v1rtu3x wants to merge 2 commits into
eclipse-mosquitto:masterfrom
v1rtu3x:fix-3705-ws-unmasked-frames

Conversation

@v1rtu3x

@v1rtu3x v1rtu3x commented Sep 5, 2026

Copy link
Copy Markdown

Fixes #3705

The built-in WebSocket transport accepted unmasked client frames, which violates RFC 6455 §5.1. It also meant an unmasked frame after a masked one would be XORed with a stale key and silently corrupted.

Add a check in read_ws_payloadlen_short() to reject frames with mask == 0, using disconnect_reason = 0xEA and errno = EPROTO to match the existing error style.

Tested with the reproducer from #3705:

  • unmasked CONNECT → rejected/closed (Protocol error)
  • masked CONNECT → accepted (CONNACK 0x00)

All conformant clients already mask, so this should not break anything legitimate.


  • Eclipse Contributor Agreement signed
  • Commits have Signed-off-by line
  • Bugfix based on master

In 2.1.x, session_expiry__check() was added to broker startup and runs
before bridge__start_all(). This causes restored outgoing bridge sessions
to be incorrectly expired if persistent_client_expiration has passed,
silently discarding the bridge's offline message queue.

Add a bridge guard in session_expiry__check() to skip outgoing bridge
sessions, consistent with the existing 'Outgoing bridge connection never
expire' guard in context__disconnect().

Fixes eclipse-mosquitto#3728

Signed-off-by: v1rtu3x <marktamas28@gmail.com>
RFC 6455 states that a server MUST close the connection upon receiving
a frame that is not masked from a client. The built-in WebSocket
transport previously accepted unmasked frames, which could also lead
to silent payload corruption due to stale masking keys.

Fixes eclipse-mosquitto#3705
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.

Built-in WebSockets: unmasked client frames are accepted (RFC 6455 §5.1)

1 participant