Repository navigation
Conversation
- Resolve the URI passed to IdentityRedirectManager.RedirectTo against NavigationManager.BaseUri and only navigate to it if it stays within the app; otherwise fall back to the base URI. - Apply the change to the net8.0, net9.0, net10.0 and net11.0 dotnet-scaffold templates and the VS.Web.CG.Mvc template, and update the net10.0 and net11.0 baselines. - Aligns the templates with dotnet/aspnetcore#70796. Fixes dotnet#3977 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 24, 2026
oroztocil
marked this pull request as ready for review
November 25, 2026 11:51
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.
The Blazor Identity scaffolder templates generate an
IdentityRedirectManager.RedirectTowhose open redirect check can be bypassed. The net8.0, net9.0 anddotnet-aspnet-codegeneratortemplates only checkUri.IsWellFormedUriString(uri, UriKind.Relative), which accepts//evil.example. The net10.0 and net11.0 templates also reject a leading//, buthttps://<app>///evil.examplegoes throughToBaseRelativePath, which returns//evil.examplewithout checking it again.This changes all of these templates to resolve the URI against
NavigationManager.BaseUriand only redirect to it if the result stays within the app. Anything else redirects to the home page. The code matches the recommended code merged in dotnet/aspnetcore#70796.Changes:
dotnet-scaffoldBlazor Identity templates for net8.0 to net11.0 (.ttand the preprocessed.cs)dotnet-aspnet-codegenerator(VS.Web.CG.Mvc) Blazor Identity template (.ttand.cs)In the preprocessed
.csfiles, only the affected template text was updated, because some of them already differ from their.ttin unrelated ways. That drift is fixed separately in #3980.Validation:
dotnet-scaffoldand VS.Web.CG.Mvc build, and the Blazor Identity baseline tests (net10.0, net11.0) and integration tests (net8.0, net9.0) pass.release/10.0has the same check in the VS.Web.CG.Mvc template, but publishing from that branch appears to be disabled. Let me know if 10.0.xdotnet-aspnet-codegeneratorusers need an update too.Fixes #3977