Skip to content

decline invalid permessage-deflate offers rather than fail handshake#1019

Open
sahvx655-wq wants to merge 1 commit into
apache:mainfrom
sahvx655-wq:permessage-deflate-decline-invalid
Open

decline invalid permessage-deflate offers rather than fail handshake#1019
sahvx655-wq wants to merge 1 commit into
apache:mainfrom
sahvx655-wq:permessage-deflate-decline-invalid

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

A WebSocket client that offers permessage-deflate with an invalid window size, for example Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits=16, makes PerMessageDeflate.build() throw. An out-of-range value raises IllegalArgumentException and a non-numeric or value-less server_max_window_bits raises NumberFormatException; nothing on the server handshake path catches either, so the exception unwinds through UpgradeUtil.doUpgrade() and WsFilter and the upgrade is aborted with a 500. I traced it from the build stack, which surfaces at the Integer.parseInt/range check in build(), and since permessage-deflate is a default-installed extension every endpoint is reachable.

RFC 7692 section 5.1 requires the server to decline an offer that carries an invalid parameter, meaning the handshake should complete without that extension rather than fail. build() already returns null when it cannot agree terms, so wrapping the parameter loop and routing an invalid parameter down that existing decline path keeps the change in the one method that owns extension negotiation, with the validation and its messages untouched. The added test exercises the three trigger values and fails on the current tree.

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.

1 participant