Skip to content

Reject non-positive SignalR sequence IDs - #69399

Merged
BrennanConroy merged 3 commits into
dotnet:mainfrom
Souheyl7Gouadria:signalr-reject-nonpositive-sequence-id
Oct 14, 2026
Merged

BrennanConroy merged 3 commits into
dotnet:mainfrom
Souheyl7Gouadria:signalr-reject-nonpositive-sequence-id

Conversation

@Souheyl7Gouadria

Copy link
Copy Markdown
Contributor

Reject non-positive SignalR sequence IDs

Validate the lower bound of a received SequenceMessage.SequenceId.

Description

With stateful reconnect, MessageBuffer.ShouldProcessMessage only checked that a received SequenceId wasn't larger than expected. A value below 1 (for example long.MinValue) was accepted and stored as the current receiving ID. Every following invocation then compared as a duplicate and was dropped. The connection stayed open and kept answering pings while it discarded everything the peer sent.

Sequence IDs start at 1, so a value below 1 now throws InvalidOperationException, the same as the existing check for IDs that are too large.

MessageBuffer is shared source, so the check applies to both the server and the .NET client.

Added a test for 0, -1 and long.MinValue. It fails without the fix.

Fixes #69283

Copilot AI lite review requested due to automatic review settings September 18, 2026 21:06

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the area-signalr Includes: SignalR clients and servers label Sep 18, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Sep 18, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @Souheyl7Gouadria. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@Souheyl7Gouadria

Copy link
Copy Markdown
Contributor Author

@Souheyl7Gouadria please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree

@Souheyl7Gouadria

Souheyl7Gouadria commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@BrennanConroy could you review this when you have time?

Two unrelated failures: the Blazor E2E test AnchorMode_NearTop_AppendKeepsViewportStable (also failing on main) and the Helix QUIC test BidirectionalStream_MultipleStreamsOnConnection_ReusedFromPool, previously quarantined as flaky in #59978. Can someone re-run those?

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service Bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Oct 2, 2026
@BrennanConroy

Copy link
Copy Markdown
Member

There should probably be functional tests that show the connection is closed by the server and that the client closes the connection if it receives a bad sequence ID.

The server closes the connection with an error and the .NET client
closes with the exception when a SequenceMessage with a non-positive
ID is received.
@Souheyl7Gouadria

Copy link
Copy Markdown
Contributor Author

@BrennanConroy added functional tests: NonPositiveSequenceIdClosesConnectionWithError (server sends a close message with the error and OnDisconnectedAsync receives the exception) and ConnectionClosedWithErrorWhenNonPositiveSequenceIdReceived (.NET client raises Closed with the exception). Both fail without the fix.

Also use RunContinuationsAsynchronously for the TaskCompletionSource
in the .NET client test.
@BrennanConroy
BrennanConroy merged commit 44d1ebe into dotnet:main Oct 14, 2026
29 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

✅ No documentation PR was created.

Confidence that documentation is needed: 10%

No docs needed: internal bug fix with tests; no deterministic docs signals.

Documentation surfaces considered

  • Conceptual article: Not required — No public API/config change; invalid sequence IDs now throw InvalidOperationException in MessageBuffer, consistent with the existing too-large check. Confident no docs needed.
  • Migration guidance: Not required — No action needed for users upgrading.
  • Breaking change: Not required — Only malformed protocol input (non-positive sequence IDs) is rejected; no valid existing usage is affected.

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — c9126f4b Deployed Oct 14, 2026 by BrennanConroy via conclusion #41
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 community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SignalR] Negative SequenceMessage.SequenceId permanently silences a connection

3 participants