decline invalid permessage-deflate offers rather than fail handshake#1019
Open
sahvx655-wq wants to merge 1 commit into
Open
decline invalid permessage-deflate offers rather than fail handshake#1019sahvx655-wq wants to merge 1 commit into
sahvx655-wq wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A WebSocket client that offers permessage-deflate with an invalid window size, for example
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits=16, makesPerMessageDeflate.build()throw. An out-of-range value raisesIllegalArgumentExceptionand a non-numeric or value-lessserver_max_window_bitsraisesNumberFormatException; nothing on the server handshake path catches either, so the exception unwinds throughUpgradeUtil.doUpgrade()andWsFilterand the upgrade is aborted with a 500. I traced it from the build stack, which surfaces at theInteger.parseInt/range check inbuild(), 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 returnsnullwhen 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.