Repository navigation
fix(dial): require exact subprotocol selections - #606
Open
anishpentyala wants to merge 2 commits into
Open
anishpentyala wants to merge 2 commits into
anishpentyala wants to merge 2 commits into
Conversation
RFC 7936 requires case-sensitive subprotocol matching. Reject server selections that differ only by case from the offered values, while preserving existing server-side negotiation behavior.
Check exact and absent selections, case-only and unsolicited selections, later offered matches, payload reads and upgraded-transport cleanup.
This branch has not been deployed
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.
Dialaccepted a server's selected subprotocol when it differed only by case from an offered value. For example, a client offeringChatacceptedchat, even though that exact token was not offered. RFC 7936 section 2 specifies case-sensitive subprotocol matching, and RFC 6455 section 4.1 requires the client to reject a selection it did not offer.Use exact equality in native client response validation. This intentionally tightens behavior: case-only server selections that previously succeeded now fail the handshake with the existing unexpected-subprotocol error. No selection remains valid, and an exact match anywhere in the offered list still succeeds.
Refs #273 for context. That change preserved the client's spelling in server responses. This PR leaves server-side selection and its existing case-preservation test unchanged. Browser/WASM handshakes still use browser validation. Multiple response protocol fields and token-syntax validation are outside this change.
The new six-case HTTP upgrade integration test covers an exact mixed-case match, a case-only mismatch, a later exact offered match, no selection, an unsolicited selection, and a completely unoffered selection. Successful connections read a binary payload and check
Subprotocol; rejected handshakes check the protocol error and nil connection. The test also waits for the upgraded transport to close. Against unchanged production code, only the case-only mismatch assertion fails.Checked locally:
go test -count=1 ./...go test -race -count=1 ./...-race -count=100go vet ./...internal/examplesandinternal/thirdpartyci/test.shAutobahn was not run locally:
AUTOBAHN=1 go test -run '^TestAutobahn$'failed during setup because Docker is not installed.Standards: https://www.rfc-editor.org/rfc/rfc7936#section-2 and https://www.rfc-editor.org/rfc/rfc6455#section-4.1 .