Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Potential fix for code scanning alert no. 316: URL redirection from remote source (#640)

Krzysztof Pajak0b6726ddfe31
diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.cs
index 9c4d14b15..8b385a0d5 100644
--- a/src/Web/Grand.Web/Controllers/CommonController.cs
+++ b/src/Web/Grand.Web/Controllers/CommonController.cs
@@ -266,10 +266,11 @@ public class CommonController : BasePublicController
}
//prevent open redirection attack
- if (!Url.IsLocalUrl(returnUrl))
- returnUrl = Url.RouteUrl("HomePage");
+ var redirectUrl = Url.RouteUrl("HomePage");
+ if (Url.IsLocalUrl(returnUrl))
+ redirectUrl = returnUrl;
- return Redirect(returnUrl);
+ return Redirect(redirectUrl);
void SetStoreCookie(Domain.Stores.Store store)
{