reject oversized websocket origin in callback_broker_mqtt#555
reject oversized websocket origin in callback_broker_mqtt#555jmestwa-coder wants to merge 1 commit into
Conversation
|
Can one of the admins verify this patch? |
|
Hi @jmestwa-coder , thank you for this code contribution. I have asked @embhorn to look it over. Can you tell us more about your project and use of wolfMQTT? In order to accept this code we need to have a signed contributor agreement. Please email support at wolfssl dot com and reference this pull request. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the embedded broker’s libwebsockets handshake filtering so that an oversized Origin header cannot bypass the configured WebSocket Origin allowlist (CSWSH defense).
Changes:
- Treat a present-but-unreadable
Origin(e.g., too large for the copy buffer) as rejectable by checkinglws_hdr_total_length()rather than relying solely onlws_hdr_copy()’s return code. - Improve the rejection log message to avoid logging uninitialized/invalid origin data when the header is oversized.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Sure. I'm running wolfMQTT in broker mode with the websocket transport on an embedded IoT gateway, and I keep ws_allowed_origin set so browser dashboards stay pinned to our own front end. That allowlist path is what I was going through when I noticed an oversized Origin slips past it. I'll email support@wolfssl.com and reference this PR to get the contributor agreement signed. |
WebSocket Origin allowlist fails open on an oversized header
When
ws_allowed_originis configured, a present Origin header longer than the 256-byte copy buffer makeslws_hdr_copyreturn <= 0, so the gate reads it as "no Origin" and lets the connection through, bypassing the CSWSH allowlist. A browser served from an attacker-controlled origin string over 255 bytes hits this path. Keyed the allow/deny onlws_hdr_total_lengthso a present-but-unverifiable Origin is rejected while a genuinely absent one still passes for native clients.