Fix SignalR reconnect identity bypass with EnableAuthenticationRefresh - #68008
Open
BrennanConroy wants to merge 1 commit into
Open
Fix SignalR reconnect identity bypass with EnableAuthenticationRefresh#68008BrennanConroy wants to merge 1 commit into
BrennanConroy wants to merge 1 commit into
Conversation
The transport-layer identity reject added in PR #67409 was bypassed when EnableAuthenticationRefresh is enabled: a different authenticated user presenting a stolen connection token could attach a long poll or stateful WebSocket reconnect and be served the original user's stream, because the stale/skip branches assume same-user without verifying identity. - Ungate the identity reject in EnsureConnectionStateAsync so it always runs for reconnect-capable connections regardless of EnableAuthenticationRefresh. A legitimate same-user token refresh keeps the same identity key and still flows through the authentication-refresh path. - Add an identity check in ProcessRefresh before OnAuthenticationRefresh and UpdateUser, rejecting a different user with 403 'user_changed' via the JSON error contract without tearing down the connection. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes an identity-bypass gap in SignalR reconnect-capable transports when EnableAuthenticationRefresh is enabled, ensuring a stolen connection token can’t be used by a different authenticated user to attach to an existing connection’s stream.
Changes:
- Add an explicit identity-key comparison on the
/refreshendpoint (beforeOnAuthenticationRefresh/UpdateUser) and return a JSON 403 error (user_changed) without tearing down the existing connection. - Ensure the transport-layer “user changed” rejection runs for reconnect-capable requests (Long Polling / stateful WebSocket reconnect) regardless of
EnableAuthenticationRefresh. - Expand test coverage for
/refresh, Long Polling, and stateful reconnect scenarios where a different user attempts to reuse a connection token.
Show a summary per file
| File | Description |
|---|---|
| src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.AuthenticationRefresh.cs | Adds targeted regression tests ensuring different-user refresh/reconnect attempts are rejected while preserving the original connection. |
| src/SignalR/common/Http.Connections/src/Internal/HttpConnectionDispatcher.cs | Enforces identity mismatch rejection for /refresh and reconnect-capable requests even when authentication refresh is enabled. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
halter73
approved these changes
Jul 30, 2026
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.
Fixes #67409 (comment)
The transport-layer identity reject added in PR #67409 was bypassed when EnableAuthenticationRefresh is enabled: a different authenticated user presenting a stolen connection token could attach a long poll or stateful WebSocket reconnect and be served the original user's stream, because the stale/skip branches assume same-user without verifying identity.