Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

invalidate aspx authentication cookie

I have an asp.net web form. when a user authenticate, it create a Secured cookie called .aspxauth

uppon logout, I call these 2 methods

FormsAuthentication.SignOut(); 
Session.Abandon()

Problem is that we had penetration test and if I steal the cookie, logout and manually reinsert the cookie, I become loggued in again. So the .aspauth isn't invalidated server side.

I've googled it and I can't find the answer to that security breach.

like image 782
Yannick Richard Avatar asked Jul 22 '15 14:07

Yannick Richard


1 Answers

Microsoft has acknowledged this issue here: https://support.microsoft.com/en-us/kb/900111

They offer several ideas for mitigating this vulnerability:

  1. protect the application by using SSL
  2. Enforce TTL and absolute expiration
  3. Use HttpOnly cookies and forms authentication in ASP.NET 2.0
  4. Use the Membership class in ASP.NET 2.0

Regarding the last one, I'll paste the contents from the site for convenience/preservation:

When you implement forms authentication in ASP.NET 2.0, you have the option of storing user information in a Membership provider. This option is a new feature that is introduced in ASP.NET 2.0. The MembershipUser object contains specific users.

If the user is logged in, you can store this information in the Comment property of the MembershipUser object. If you use this property, you can develop a mechanism to reduce cookie replay issues in ASP.NET 2.0. This mechanism would follow these steps:

  1. You create an HttpModule that hooks the PostAuthenticateRequest event.
  2. If a FormsIdentity object is in the HttpContext.User property, the FormsAuthenticationModule class recognizes the forms authentication ticket as valid.
  3. Then, the custom HttpModule class obtains a reference to the MembershipUser instance that is associated with the authenticated user. You examine the Comment property to determine whether the user is currently logged in.

Important: You must store information in the Comment property that indicates when the user explicitly signed out. Also, you must clear the information that is in the Comment property when the customer eventually signs in again.

If the user is not currently logged in as indicated by the Comment property, you must take the following actions:

  1. Clear the cookie.
  2. Set the Response.Status property to 401.
  3. Make a call to the Response.End method that will implicitly redirect the request to the logon page.

By using this method, the forms authentication cookie will only be accepted if the user has not been explicitly signed out and the forms authentication ticket has not yet expired.

like image 116
Gray Avatar answered Oct 20 '22 18:10

Gray