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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Improve security and logic flow in CommonController methods
KrzysztofPajakf0ed90381b76
diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.csindex c975bfd11..1d03af0a6 100644--- a/src/Web/Grand.Web/Controllers/CommonController.cs+++ b/src/Web/Grand.Web/Controllers/CommonController.cs@@ -274,12 +274,12 @@ public class CommonController : BasePublicController[FromServices] ICustomerService customerService,int customerTaxType, string returnUrl = ""){- var taxDisplayType = (TaxDisplayType)Enum.ToObject(typeof(TaxDisplayType), customerTaxType);-//prevent open redirection attackif (!Url.IsLocalUrl(returnUrl))returnUrl = Url.RouteUrl("HomePage");+ var taxDisplayType = (TaxDisplayType)Enum.ToObject(typeof(TaxDisplayType), customerTaxType);+//whether customers are allowed to select tax display typeif (!taxSettings.AllowCustomersToSelectTaxDisplayType)return Redirect(returnUrl);@@ -300,6 +300,10 @@ public class CommonController : BasePublicController[FromServices] StoreInformationSettings storeInformationSettings,[FromServices] IThemeContextFactory themeContextFactory, string themeName, string returnUrl = ""){+ //prevent open redirection attack+ if (!Url.IsLocalUrl(returnUrl))+ returnUrl = Url.RouteUrl("HomePage");+if (!storeInformationSettings.AllowCustomerToSelectTheme) return Redirect(returnUrl);var themeContext = themeContextFactory.GetThemeContext("");@@ -308,10 +312,6 @@ public class CommonController : BasePublicController//notificationawait _mediator.Publish(new ChangeThemeEvent(_workContext.CurrentCustomer, themeName));- //prevent open redirection attack- if (!Url.IsLocalUrl(returnUrl))- returnUrl = Url.RouteUrl("HomePage");-return Redirect(returnUrl);}