Skip to content

Fix SignalR fallback authorization for non-authorization metadata - #69683

Open
utsavjain2809 wants to merge 1 commit into
dotnet:mainfrom
utsavjain2809:fix-signalr-fallback-clean
Open

utsavjain2809 wants to merge 1 commit into
dotnet:mainfrom
utsavjain2809:fix-signalr-fallback-clean

Conversation

@utsavjain2809

Copy link
Copy Markdown

Fix SignalR fallback authorization for non-authorization metadata

Prevent non-authorization hub metadata from triggering fallback authorization

Description

SignalR hub method authorization used the presence of any method authorization metadata to determine whether authorization should run.

This caused metadata that does not define an authorization policy, such as [AllowAnonymous] or an unrelated attribute, to enter the authorization path. When AuthorizationPolicy.CombineAsync found no applicable IAuthorizeData, AuthorizationPolicy, or IAuthorizationRequirementData, the configured fallback policy was applied instead.

With a fallback policy requiring an authenticated user, this caused anonymous hub method invocations to be rejected unexpectedly.

This change ensures that hub method authorization is only performed when the metadata contains authorization-relevant data.

The regression test AnonymousConnectionCanInvokeMethodsOnAllowAnonymousHubWithFallbackPolicy covers:

  • Async method without additional attributes
  • Async method with [AllowAnonymous]
  • Async method with an explicit open authorization policy
  • Synchronous method without additional attributes
  • Synchronous method with [AllowAnonymous]
  • Method with unrelated metadata

The full SignalR test suite was also run successfully after the change.

Note: The standalone reproduction in the issue reports AsyncNoAttribute as unauthorized on .NET 11 RC1. That specific behavior was not reproduced by the lower-level HubConnectionHandlerTests test infrastructure, where a method with no authorization metadata bypasses method authorization. The regression test reproduces the [AllowAnonymous] and unrelated-metadata failures addressed by this change.

Fixes #69624

Note

AI assistance was used to help understand the existing test structure and to prepare this pull request description.

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

Copy link
Copy Markdown
Contributor

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

@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 13, 2026
@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 69683 in repo dotnet/aspnetcore

@utsavjain2809

Copy link
Copy Markdown
Author

Hi @halter73 @BrennanConroy , just a gentle follow-up on this PR, as it has been awaiting review for around 3 weeks.

Whenever you get a chance, I would appreciate your review and feedback. Please let me know if any further changes are needed.

Thanks for your time!

lahma added a commit to quartznet/quartznet that referenced this pull request Nov 3, 2026
…es not hold them to a fail-closed FallbackPolicy

ASP.NET Core 11 reads every custom attribute on a hub method as authorization metadata, and a method with
any attribute but none that names a policy is authorized against the host's FallbackPolicy, whatever the
hub's endpoint allows (dotnet/aspnetcore#69624, which dotnet/aspnetcore#67765 introduced and
dotnet/aspnetcore#69683 proposes to fix). An async method has one, AsyncStateMachineAttribute, so under a
fail-closed policy the agent hub's Register refused every agent its token check had let in, and the
live-events hub's JoinScheduler would refuse an anonymous dashboard. No endpoint lost its AllowAnonymous:
negotiate and the transport both carry it on 11.

Register, Events and JoinScheduler now hand their awaiting to private methods. The token check is the
hub's own, unchanged: a wrong token and a token in the query string are still refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGkLQvYPaRLpBF3dTvpE6T
lahma added a commit to quartznet/quartznet that referenced this pull request Nov 3, 2026
…es not hold them to a fail-closed FallbackPolicy

ASP.NET Core 11 reads every custom attribute on a hub method as authorization metadata, and a method with
any attribute but none that names a policy is authorized against the host's FallbackPolicy, whatever the
hub's endpoint allows (dotnet/aspnetcore#69624, which dotnet/aspnetcore#67765 introduced and
dotnet/aspnetcore#69683 proposes to fix). An async method has one, AsyncStateMachineAttribute, so under a
fail-closed policy the agent hub's Register refused every agent its token check had let in, and the
live-events hub's JoinScheduler would refuse an anonymous dashboard. No endpoint lost its AllowAnonymous:
negotiate and the transport both carry it on 11.

Register, Events and JoinScheduler now hand their awaiting to private methods. The token check is the
hub's own, unchanged: a wrong token and a token in the query string are still refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGkLQvYPaRLpBF3dTvpE6T
(cherry picked from commit 7ec865d)
ryceg added a commit to nightscout/nocturne that referenced this pull request Nov 11, 2026
…3291)

* chore: move to .NET 11 and Aspire 13.6.5, and build without warnings

Retargets every project, the CI workflows, base images and docs to .NET 11,
bumps Aspire to 13.6.5 and other packages within their current majors, and
clears all 455 build warnings.

.NET 11 behaviour changes handled:
- double-to-decimal casts keep the exact binary value: DecimalConversion.ToDecimal
  replaces every cast, and decimal factors are decimal constants
- Math.Round(double, digits) rounds the exact value: ScaledRounding.Round keeps
  the scale-round-unscale result Nightscout gives
- SignalR evaluates the fallback policy for anonymous hub methods
  (dotnet/aspnetcore#69683): HasPermissionsHandler passes hub invocations to
  HubAuthorizationFilter
- HttpClient observes cancellation after the handler returns: an unstored
  Google Health grant is revoked after a repeated account lookup

EF Core stays on 10 until Npgsql's provider 11 ships; NSwag stays on 14.6.3,
since 14.7 changes the generated client.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

* fix(deps): pin System.Formats.Cbor past GHSA-vmv3-wvjp-wqpj

Fido2 4.3.2 depends on 9.0.0, which projects that reference the API without
the ASP.NET Core framework restore.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

* ci: review fixes for the .NET 11 move

- sdk-publish's C# job installs an SDK the repository's global.json accepts
- screenshot-regen installs the Aspire CLI the AppHost now takes DCP from
- a boxed double in a profile activation's residue converts with ToDecimal

Co-Authored-By: Claude Fable 5.2 <[email protected]>

* ci: the test solutions hold only the test projects on the .NET 11 SDK

dotnet sln add includes project references by default from SDK 11 and fails
when two share a file name in one solution folder.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

* fix(statistics): a local day whose midnight the clock skipped still has bounds

From .NET 11 TimeZoneInfo.ConvertTimeToUtc throws for a skipped local time on
Linux as it does on Windows, so the punch card, the reports range, the data
overview year and alert replay failed for a zone whose clocks go forward at
midnight. They convert with TimeZoneHelper.ConvertTimeToUtc, which resolves a
skipped time to the first instant after the gap.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>

This branch has not been deployed

No deployments
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 hub methods ignore [AllowAnonymous]

1 participant