Repository navigation
Update identity redirect handling - #69197
Merged
Merged
Conversation
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 -->
Contributor
There was a problem hiding this comment.
🟡 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 duringRedirectTo. - 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); | ||
| } |
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.
Updates identity redirect handling.