Repository navigation
Harden signin redirects while preserving native client schemes - #407
Merged
Merged
Conversation
Parse redirect URLs before denying javascript, data, and vbscript schemes. Handle absent and malformed redirect metadata and use the normalized URL for navigation in all 58 sample copies. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
|
Note this needs updating in products too |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The consistent implementation blocks normalized unsafe schemes while preserving intended redirects, with no blocking defects identified.
No open issues 🎉
What changed in this PR
This PR hardens sign-in redirects across 58 IdentityServer and BFF sample scripts while preserving native-client callbacks and relative URLs.
Changes:
- Standardizes all copies on URL parsing and normalized blocking of
javascript:,data:, andvbscript:schemes. - Stops navigation and logs errors for missing, blank, or malformed redirect targets.
- Replaces the two Docker samples’ HTTP(S)-only restriction with native-compatible validation.
| File | Description |
|---|---|
| various/clients/Owin/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds redirect validation to OWIN sample. |
| IdentityServer/v8/UserInteraction/WsFederationDynamicProviders/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/UserInteraction/WindowsAuthentication/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/UserInteraction/StepUp/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/UserInteraction/SpaLoginUi/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/UserInteraction/ProfileService/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/UserInteraction/DynamicProviders/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/UserInteraction/Ciba/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/SessionMigration/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/SessionManagement/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/SAML/IdPInitiated/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/SAML/Basic/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/Quickstarts/6_JS_without_backend/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v8/Quickstarts/6_JS_with_backend/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v8/Quickstarts/5_AspNetIdentity/src/IdentityServerAspNetIdentity/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v8/Quickstarts/4_EntityFramework/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v8/Quickstarts/3a_TokenManagement/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v8/Quickstarts/3_AspNetCoreAndApis/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v8/Quickstarts/2_InteractiveAspNetCore/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v8/PAT/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/MTLS/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/McpDemo/McpDemo.IdentityServer/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/IdentityServerHost/src/wwwroot/js/signin-redirect.js | Hardens main sample host redirects. |
| IdentityServer/v8/Diagnostics/Otel/src/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/Diagnostics/Aspire/IdentityServer/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/Configuration/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v8/AspNetIdentityPasskeys/IdentityServerAspNetIdentityPasskeys/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/UserInteraction/WsFederationDynamicProviders/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/UserInteraction/WindowsAuthentication/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/UserInteraction/StepUp/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/UserInteraction/SpaLoginUi/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/UserInteraction/ProfileService/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/UserInteraction/DynamicProviders/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/UserInteraction/Ciba/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/SessionMigration/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/SessionManagement/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/Quickstarts/6_JS_without_backend/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v7/Quickstarts/6_JS_with_backend/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v7/Quickstarts/5_AspNetIdentity/src/IdentityServerAspNetIdentity/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v7/Quickstarts/4_EntityFramework/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v7/Quickstarts/3a_TokenManagement/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v7/Quickstarts/3_AspNetCoreAndApis/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v7/Quickstarts/2_InteractiveAspNetCore/src/IdentityServer/wwwroot/js/signin-redirect.js | Hardens quickstart redirects. |
| IdentityServer/v7/PAT/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/MTLS/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/McpDemo/McpDemo.IdentityServer/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/IdentityServerHost/src/wwwroot/js/signin-redirect.js | Hardens main sample host redirects. |
| IdentityServer/v7/Diagnostics/Otel/src/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/Diagnostics/Aspire/IdentityServer/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/Configuration/IdentityServerHost/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| IdentityServer/v7/AspNetIdentityPasskeys/IdentityServerAspNetIdentityPasskeys/wwwroot/js/signin-redirect.js | Adds shared redirect validation. |
| BFF/v4/TokenExchange/TokenExchange.IdentityServer/wwwroot/js/signin-redirect.js | Hardens token-exchange sample redirects. |
| BFF/v4/MultiFrontendSSO/MultiFrontendSSO.IdentityServer/idsrv-wwwroot/js/signin-redirect.js | Hardens SSO server redirects. |
| BFF/v4/MultiFrontendSSO/MultiFrontendSSO.Client/wwwroot/js/signin-redirect.js | Hardens SSO client redirects. |
| BFF/v4/docker/ContainerizedIdentityServer/wwwroot/js/signin-redirect.js | Validates redirects while allowing native schemes. |
| BFF/v3/TokenExchange/TokenExchange.IdentityServer/wwwroot/js/signin-redirect.js | Hardens token-exchange sample redirects. |
| BFF/v3/docker/ContainerizedIdentityServer/wwwroot/js/signin-redirect.js | Validates redirects while allowing native schemes. |
| BFF/v2/TokenExchange/TokenExchange.IdentityServer/wwwroot/js/signin-redirect.js | Hardens token-exchange sample redirects. |
Review effort: Balanced
maartenba
approved these changes
Oct 27, 2026
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.
Summary
signin-redirect.jscopies, including the two BFF docker copies that previously allowed only HTTP(S).new URL(redirectUrl, window.location.href), reject normalizedjavascript:,data:, andvbscript:protocols, and navigate using the parsed URL'shref.This batch targets the 35 open
js/xss-through-domalerts associated withsignin-redirect.js. It deliberately does not restrict redirects to HTTP(S), since native clients can use schemes such asmyapp://callback. Any residual CodeQL alerts will be evaluated separately rather than weakening native-client compatibility or adding scanner-specific workarounds.Validation
javascript:URI.git diff --checkpasses.Only
signin-redirect.jsfiles are changed.