Skip to content

Commit 277afac

Browse files
Fix code scanning alert no. 124: Cross-site scripting (#482)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 967a017 commit 277afac

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

samples/IdentityServer.ServerSample/Controllers/AccountController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Duende.IdentityServer.Services;
33
using Microsoft.AspNetCore.Authentication;
44
using Microsoft.AspNetCore.Mvc;
5-
5+
using System.Net;
66
namespace IdentityServer.ServerSample.Controllers;
77

88
public class AccountController : Controller
@@ -23,7 +23,8 @@ public async Task<IActionResult> Login(string returnUrl)
2323
var providers = schemes
2424
.Where(x => x.DisplayName != null)
2525
.Select(x => new ExternalProvider(x.DisplayName ?? x.Name, x.Name));
26-
var viewModel = new AccountLoginViewModel(providers, returnUrl);
26+
var sanitizedReturnUrl = System.Net.WebUtility.HtmlEncode(returnUrl);
27+
var viewModel = new AccountLoginViewModel(providers, sanitizedReturnUrl);
2728

2829
return View(viewModel);
2930
}

samples/IdentityServer.ServerSample/Views/Account/Login.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<a class="btn btn-primary btn-lg"
1818
asp-action="ExternalLogin"
1919
asp-route-provider="@provider.AuthenticationScheme"
20-
asp-route-returnUrl="@Model.ReturnUrl">
20+
asp-route-returnUrl="@Html.Raw(Model.ReturnUrl)">
2121
@provider.DisplayName
2222
</a>
2323
}

0 commit comments

Comments
 (0)