Skip to content

Update identity redirect handling - #69197

Merged
wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/63741
Sep 11, 2026
Merged

wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/63741

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Sep 10, 2026

Copy link
Copy Markdown
Member

Updates identity redirect handling.

Updates identity redirect handling.

----
#### AI description  (iteration 1)
#### PR Classification
Security bug fix to prevent open redirect vulnerabilities in identity redirect handling.

#### PR Summary
This pull request strengthens the open redirect protection in the Blazor Web template's identity redirect manager by adding an additional validation check for protocol-relative URLs.

- `IdentityRedirectManager.cs`: Added validation to reject URIs starting with `//` (protocol-relative URLs) to prevent potential open redirect attacks, in addition to the existing well-formed URI check.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
Copilot AI lite review requested due to automatic review settings September 10, 2026 15:54
@wtgodbe
wtgodbe requested a review from a team as a code owner September 10, 2026 15:54
@github-actions github-actions Bot added the area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI label Sep 10, 2026

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.

🟡 Changes recommended

The new // handling can route unsafe input into ToBaseRelativePath and trigger an unhandled ArgumentException (500) instead of a safe fallback, and it should also account for leading backslashes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the Blazor Web App (C#) project template’s IdentityRedirectManager to tighten redirect validation in Identity pages, aiming to reduce open-redirect risk when redirect targets originate from untrusted inputs (for example, ReturnUrl query parameters).

Changes:

  • Extends the open-redirect guard to treat protocol-relative URLs (//...) as unsafe during RedirectTo.
  • Adjusts redirect normalization behavior in the template’s Identity redirect helper.
File summaries
File Description
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Account/IdentityRedirectManager.cs Tightens redirect validation for Identity-related navigations in the Blazor Web template.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 24 to 28
if (!Uri.IsWellFormedUriString(uri, UriKind.Relative)
|| uri.StartsWith("//", StringComparison.Ordinal))
{
uri = navigationManager.ToBaseRelativePath(uri);
}
@wtgodbe
wtgodbe merged commit f297276 into dotnet:main Sep 11, 2026
29 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants