Skip to content

Harden SignalR negotiateVersion parsing. - #67908

Merged
cincuranet merged 1 commit into
dotnet:mainfrom
cincuranet:neg-version
Jul 22, 2026
Merged

cincuranet merged 1 commit into
dotnet:mainfrom
cincuranet:neg-version

Conversation

@cincuranet

Copy link
Copy Markdown
Contributor

Fixes #67751

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a SignalR client negotiation-version downgrade bug by ensuring negotiateVersion is detected via an exact query-string key match (rather than a substring search), preventing unrelated query values (e.g. ?x=negotiateVersion) from suppressing appending negotiateVersion=1.

Changes:

  • Java client: switch to URL parsing to check for an existing negotiateVersion query parameter by exact key name.
  • .NET client: replace Query.Contains("negotiateVersion") with an exact query-parameter key check using QueryStringEnumerable.
  • Add regression tests in both Java and .NET for query strings containing negotiateVersion as a value/sub-string and for existing negotiateVersion parameters.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/SignalR/clients/java/signalr/test/src/main/java/com/microsoft/signalr/ResolveNegotiateUrlTest.java Adds coverage for query strings that contain negotiateVersion as a value/sub-string and ensures correct version appending behavior.
src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/Negotiate.java Hardens negotiateVersion detection by parsing query parameter names instead of substring matching.
src/SignalR/clients/csharp/Http.Connections.Client/src/Microsoft.AspNetCore.Http.Connections.Client.csproj Includes the shared QueryStringEnumerable implementation so the client can perform exact query key checks.
src/SignalR/clients/csharp/Http.Connections.Client/src/Internal/Utils.cs Adds HasQueryStringParameter helper using QueryStringEnumerable for exact key matching.
src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnection.cs Uses HasQueryStringParameter to decide whether to append negotiateVersion.
src/SignalR/clients/csharp/Client/test/UnitTests/HttpConnectionTests.Negotiate.cs Adds regression coverage for the previously broken URL shapes and existing negotiateVersion values.
src/Shared/QueryStringEnumerable.cs Adjusts decoding implementation to be safe across TFMs by guarding intrinsics-based logic behind #if NET.

@cincuranet
cincuranet marked this pull request as ready for review July 21, 2026 07:57
@gfoidl gfoidl added the area-signalr Includes: SignalR clients and servers label Jul 21, 2026

@BrennanConroy BrennanConroy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scanning for negotiateVersion= would probably be the fastest, but this is perfectly fine

@cincuranet
cincuranet merged commit 285cae5 into dotnet:main Jul 22, 2026
35 checks passed
@cincuranet
cincuranet deleted the neg-version branch July 22, 2026 07:13
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-signalr Includes: SignalR clients and servers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection downgrades to negotiateVersion=0 when hub URL contains the substring negotiateVersion

4 participants