A web service is running a very old version of Sitecore, with IdentityServer3 and no custom configuration. It's not possible to upgrade to a more recent version of Identity Server.
/identity/postexternallogout?ReturnUrl=<any URL here> acts as an open-URL redirect, with no validation at all! How can IdentityServer 3 be configured to avoid this vulnerability?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
You’ve hit a bug/limitation of the stock IdentityServer3 “UI” layer, not the core protocol endpoints. The /identity/postexternallogout route is part of the sample MVC UI that ships with IdSrv3; it simply trusts the ReturnUrl query string. There is no built‑in IdentityServer3 option that will validate that ReturnUrl for you.
Practical ways to close the hole without upgrading
Pick one of these (or combine):
Intercept and validate ReturnUrl in OWIN (no change to IdSrv3 itself)
Add a tiny middleware before/around your IdSrv3 pipeline that only allows local return URLs (or a strict allowlist), and otherwise redirects to a safe page.
Example:
csharp
public void Configuration(IAppBuilder app)
{
// must run before the MVC controller that handles /identity/postexternallogout
app.Use(async (ctx, next) =>
{
if (ctx.Request.Path.Value != null &&
ctx.Request.Path.Value.Equals("/identity/postexternallogout", StringComparison.OrdinalIgnoreCase))
{
var returnUrl = ctx.Request.Query.Get("ReturnUrl");
// allow only same-site relative paths like /foo (not //host or http(s)://host)
var isLocal = !string.IsNullOrEmpty(returnUrl)
&& returnUrl.StartsWith("/", StringComparison.Ordinal)
&& !returnUrl.StartsWith("//", StringComparison.Ordinal);
// optional: enforce an allowlist instead of “isLocal”
// var allowed = new[] { "/logged-out", "/signin" }.Contains(returnUrl, StringComparer.Ordinal);
ctx.Response.Redirect(isLocal ? returnUrl : "/"); // pick your safe default
return;
}
await next();
});
// your existing IdentityServer3 setup follows…
// app.UseIdentityServer(options);
}
Block absolute ReturnUrl values at the edge (IIS URL Rewrite)
If you can’t touch code, add a rewrite rule that rejects any ReturnUrl that is absolute (http:, https:, or //).
Alternative: instead of 400, redirect to a fixed safe page.
Stop using postexternallogout; rely on the OIDC end_session flow
The core end-session endpoint (/connect/endsession with post_logout_redirect_uri) IS validated by IdentityServer3 against each client’s PostLogoutRedirectUris.
If possible in your app, use /connect/endsession and configure each client with an explicit PostLogoutRedirectUris allowlist (and optionally a custom IRedirectUriValidator for extra checks).
Then disable or neuter /identity/postexternallogout (via rewrite rule or route removal) so it can’t be abused.
Notes and gotchas
This issue is not fixable via an IdentityServer3 option toggle; it’s a UI/controller behavior.
If you use external identity providers with federated sign-out, ensure your change still lets the browser land on a local path you control after the external IdP redirects back.
Prefer strict allowlists (hosts or exact paths) over “local URL” checks if you have a small known set of valid targets.
Recommended path
Short term: add the IIS rewrite rule now (fastest mitigation).
Medium term: add the tiny OWIN middleware to validate/allowlist ReturnUrl and keep behavior predictable.
Long term (when possible): migrate off the sample UI endpoint and use OIDC end_session with validated PostLogoutRedirectUris.