Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per message compression: Illegal character CNTL=0xf #340

Closed
ahausladen opened this issue Dec 28, 2021 · 2 comments
Closed

Per message compression: Illegal character CNTL=0xf #340

ahausladen opened this issue Dec 28, 2021 · 2 comments

Comments

@ahausladen
Copy link
Contributor

If the per message compression is active the websocket client sends an illegal header to the server and the server (in my case Java Jetty) closes the connection with "HTTP/1.1 400 Illegal character CNTL=0xf".

This is caused by using an uint8_t for server_max_window_bits and client_max_window_bits in WebSocketPerMessageDeflateOptions.
A uint8_t is actually a "signed char" and so the byte value is interpreted as a character when building the headers.

Instead of
... ; server_max_window_bits=15; client_max_window_bits=15
the client sends
...; server_max_window_bits=\xf; client-max_window_bits=\xf

The ws tool can be used to show this. You can see the defect header with Wireshark.
ws send ws://localhost:8081/mywebsocket IXWebSocket/ws/ws.cpp

The ws tool's "receive" mode hides this bug because it uses strtol() to parse the presumed number and just returns zero because \xf is not a digit. The zero is then range-checked to the minimum window bits value (8).

@bsergean
Copy link
Collaborator

bsergean commented Jan 4, 2022

Great find, thanks !

Maybe I was trying to fix a warning, I can't remember why I changed those to a uint8_t.

@bsergean
Copy link
Collaborator

bsergean commented Jan 4, 2022

I think this is fixed now.

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

No branches or pull requests

2 participants