I am running some security checks on an applicationI have built using ASP.net MVC 4.
I am currently using a web debugger to compose unathorize posts during testing.
My application enforces a policy where data can only be modified by the user that added it.
I use methods similar to the follwing the check the current user Id
if (item.AddedByUser != WebMatrix.WebData.WebSecurity.CurrentUserId)
{
throw new UnauthorizedException();
}
However, when I tried duplicating a previous succesfull POST (using an older 'ASP.NET_SessionId') I found that the WebMatrix.WebData.WebSecurity.CurrentUserId method returned the userid of the user that was active during the previous session, rather than the userId of the currently active user.
This looks like a potential security hole to me.
Does anyone know how this happens?
EDIT
I am calling the Sessioon.Abandon() method and clearing the ASP.NET_SessionId cookie as part of my LogOff method as follows
public virtual ActionResult LogOff()
{
WebSecurity.Logout();
Session.Abandon();
Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
Response.Cookies.Add(new HttpCookie(".ASPXAUTH", ""));
Response.Cookies.Add(new HttpCookie("__RequestVerificationToken", ""));
return RedirectToAction("Index", "Home");
}
However, the session still appears to be 'resusable' if a previous sessionid is passed as part of the POST