Merge pull request #3546 from sbwalker/dev

security improvement - ensure returnurl is a relativre path
This commit is contained in:
Shaun Walker 2023-12-12 15:55:03 -05:00 committed by GitHub
commit 53032140e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,11 +105,18 @@
Route route = new Route(_absoluteUri, SiteState.Alias.Path);
int moduleid = (int.TryParse(route.ModuleId, out moduleid)) ? moduleid : -1;
var action = (!string.IsNullOrEmpty(route.Action)) ? route.Action : Constants.DefaultAction;
var querystring = Utilities.ParseQueryString(route.Query);
var returnurl = "";
if (querystring.ContainsKey("returnurl"))
{
returnurl = WebUtility.UrlDecode(querystring["returnurl"]);
if (!returnurl.StartsWith("/"))
{
// urls which are not relative are vulnerable to open redirects or XSS
returnurl = "";
querystring["returnurl"] = "";
}
}
// reload the client application from the server if there is a forced reload