I was trying to make a guard for some action so it is not accessible unless the request comes from a certain host. Here is the sample code.
public ActionResult test()
{
if (Request.UrlReferrer == null || Request.UrlReferrer.Host != "mydomain.com") { return Content("Blocked!"); }
else { return Content("Authorized!"); }
}
Everything seems to work well until I went to mydomain.com "typed the link in the addressbar" , opened the browser console and typed
window.location.href = "https://domainholdingthatacion.whatever/ActionRoute/test"; //trying to get unauthorized access
It worked! It enters the else branch. I need your input because I have no idea if I am using it wrong as Request.UrlReferrer is not meant to be used for that or It is inherently vulnerable.