Repository navigation
Harden identity redirect handling in Blazor template - #70796
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The redirect logic loses query strings and fragments for valid slashless app-root URLs, and the new URI-resolution and fallback behavior lacks regression coverage.
2 open issues
What changed in this PR
This PR updates identity redirects in the Blazor Web App template to validate resolved destinations against the application’s base URI.
Changes:
- Resolve redirect input to an absolute URI before validation.
- Fall back to the app’s home page when resolution fails or the destination is outside the base URI.
- Pass the validated absolute URI directly to
NavigateTo.
| File | Description |
|---|---|
| src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/IdentityRedirectManager.cs | Replaces raw-input validation with resolved-URI validation and a home-page fallback. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/review |
There was a problem hiding this comment.
Source-only review of frozen head d06e03409b7d07d6863ec9d53cb91219d45f67b1.
One unresolved P2 candidate is attached inline: the new OrdinalIgnoreCase containment check accepts a case-different application path, but the material hosting outcome is not established by the frozen repository contracts or available immutable evidence.
Existing-feedback coverage: No supported duplicate was republished. The earlier query/fragment thread (#discussion_r4670392025) is contradicted by the current head's GetLeftPart(UriPartial.Path) + "/" handling while retaining absoluteUri; the test-only thread (#discussion_r4670392066) does not establish a concrete behavioral defect.
Unresolved: Case-sensitive deployment behavior for /app/ versus /APP/; missing target-version System.Uri contract/validation, exact query-binding evidence, and a binding hosting contract or immutable artifact establishing the consumer-visible result.
DISCARDED
- External origins and sibling paths such as
/app2are rejected by the new boundary check. - Query strings and fragments remain in
absoluteUri.AbsoluteUri; the slashless app-root case is accepted by the appended/comparison. - Null, empty, malformed, and ordinary relative inputs resolve or fall back as shown by frozen source.
- No applicable API, lifecycle, resource, concurrency, build, packaging, trimming, analyzer, or other source-backed regression was found.
Per-guide completion: docs/CrossCuttingGuidance.md complete; assessed scope, compatibility, URI correctness, nullability, exceptions, path/casing behavior, templates, consumers, and test-source coverage. Execution, tests, CI, browser workflows, implementation samples, and security implications were excluded by the supplied source-only policy.
Uncovered: No materially changed area lacked a routed guide.
Provenance: Bundle v2; guidance commit 635a8e68e7ebb2408701dae39aba97b383984299; merge base/base tip 635a8e68e7ebb2408701dae39aba97b383984299; independent guide worker and candidate verifier both used gpt-5.6-sol (reasoning effort not supplied; runtime default).
Test boundary and limitations: No target code or tests were executed. Proof is source-only and limited to tracked Git bytes; symlinks, submodules, LFS targets, runtime/BCL behavior, external hosting behavior, and feedback posted after bundle preparation were not observable.
Generated by ASP.NET Core Pull Request Review for #70796 · copilot · gpt56 · 91.4 AIC · ⌖ 8.63 AIC · ⊞ 20.3K
Comment /review to run again
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
I rewrote the code comments with the perspective that this is guidance for users of the templates, not framework code. |
|
ℹ️ This pull request wasn't processed automatically. This change requires specialized review. Please confirm whether documentation updates are needed and handle them through the appropriate process. |
|
/backport to release/11.0 |
|
Started backporting to |
|
/backport to release/10.0 |
|
Started backporting to |


IdentityRedirectManager.RedirectToin the Blazor Web App template validated the raw redirect string, and that check could be bypassed.ToBaseRelativePathstrips the app's base URI and can leave a network-path reference such as//evil.example(or\/evil.example), whichNavigateTothen resolves to another host.This change resolves the URI against the app's base URI and only uses it if the result stays within the app. Anything else redirects to the home page instead of throwing. The app root without a trailing slash (for example
/app?page=2) is still accepted, matchingToBaseRelativePath. The path is compared ordinally, so a path base with different casing such as/APP/is rejected, while scheme and host stay case-insensitive becauseSystem.Urinormalizes them.This is the reference for the recommended code. Once it's merged, the other places that ship this kind of code will be checked against it:
Validation: checked with a generated app in Chrome and against a set of valid, malicious and malformed return URLs with root and
/app/base paths. The existing template tests cover the valid redirects.Fixes #70797