Skip to content

fix: reject MQTT WebSocket text frames - #140

Open
OllieinCanada wants to merge 1 commit into
microsoft:mainfrom
OllieinCanada:fix/websocket-text-frame-138
Open

fix: reject MQTT WebSocket text frames#140
OllieinCanada wants to merge 1 commit into
microsoft:mainfrom
OllieinCanada:fix/websocket-text-frame-138

Conversation

@OllieinCanada

Copy link
Copy Markdown

Fixes #138

Summary

Reject inbound WebSocket text data frames instead of forwarding their UTF-8 bytes to the MQTT decoder.

MQTT 5 requires MQTT control packets to use WebSocket binary data frames. The adapter now returns a clear InvalidData transport error for any text frame, which takes the normal connection teardown path. Binary frames and Ping, Pong, and Close handling are unchanged.

Tests

Added deterministic localhost-only WebSocket tests that verify:

  • binary MQTT packets still decode after a control frame
  • valid-looking MQTT bytes carried in a text frame are rejected
  • empty text frames are also rejected

The main regression failed before the production change because the text frame decoded as Ok(RawPacket { first_byte: 48, ... }).

Validation after the fix:

  • cargo test --lib --features websockets io::tokio_ws::tests (3 passed)
  • make test (default, integration, and WebSocket feature sets passed)
  • cargo fmt --all -- --check
  • Clippy for both repository feature matrices with warnings denied
  • git diff --check

No external broker or network service is required by the new tests.

Signed-off-by: Oliver Slapinski <olliefromcanada@gmail.com>
@OllieinCanada

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

WebSocket transport accepts text data frames as MQTT bytes

1 participant