Skip to content

Encode logout id in WsFed remote-failure redirect - #408

Merged
maartenba merged 1 commit into
mainfrom
dh/code-scanning-alerts-plan
Oct 27, 2026
Merged

maartenba merged 1 commit into
mainfrom
dh/code-scanning-alerts-plan

Conversation

@damianh

@damianh damianh commented Oct 27, 2026

Copy link
Copy Markdown
Member

Addresses the cs/web/unvalidated-url-redirection alert in UserInteraction/WsFederationDynamicProviders/IdentityServerHost/WsFed/WsFedConfigureOptions.cs (v7 and v8).

OnRemoteFailure redirected to the local LogoutUrl and appended the raw logoutId query value to it. The value is now URL-encoded with QueryString.Create, so the redirect always stays on the local logout page.

Both hosts build. If CodeQL still flags the line after this merges (the target comes from configured IdentityServerOptions), the alert will be dismissed as a false positive during triage.

Part of the code scanning alert cleanup, alongside #406 and the Bootstrap, signin-redirect and log-forging PRs.

The OnRemoteFailure handler redirected to the local logout page with the
raw logoutId query value appended. URL-encode it via QueryString.Create
so request input cannot alter the redirect target (CodeQL
cs/web/unvalidated-url-redirection).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:14

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.

🟢 Approval recommended

Both changes correctly encode query data while preserving the existing logout flow, with no blocking issues identified.

No open issues 🎉

What changed in this PR

This PR hardens the WS-Federation remote-failure logout redirects in the v7 and v8 samples by encoding query data before appending it to the configured logout URL.

Changes:

  • Uses QueryString.Create to encode the logout parameter instead of concatenating its raw value.
  • Applies the same change to both sample versions while preserving existing failure handling.
File Description
IdentityServer/​v8/​UserInteraction/​WsFederationDynamicProviders/​IdentityServerHost/​WsFed/​WsFedConfigureOptions.cs Encodes the logout query parameter in the v8 redirect.
IdentityServer/​v7/​UserInteraction/​WsFederationDynamicProviders/​IdentityServerHost/​WsFed/​WsFedConfigureOptions.cs Applies equivalent redirect encoding in v7.

Review effort: Balanced

@maartenba
maartenba merged commit f9b975c into main Oct 27, 2026
12 checks passed
@maartenba
maartenba deleted the dh/code-scanning-alerts-plan branch October 27, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants