In asp.net, I am able to login using forms authentication as usual, copy our auth cookie value, log out, add the cookie artificially to the client using the ‘Edit This Cookie’ addon for Chrome, refresh the (anonymous) landing page and hey presto i’m logged in again. This seems to be a vulnerability – is there any way of fixing it using the the standard forms auth or will I have to do something like use a custom Authorize attribute which overrides the existing one in asp.net mvc?
Share
Cookies are always vulerable and we can’t do much about that. What we can do is prevent someone from stealing the cookies.
Regarding ASP.NET MVC it does a good job to avoid stealing cookies. Some of the main things it does by default as part of security are:
Encode the strings that are rendered to the view (if you are using Razor don’t know about others) to prevent from XSS attacks.
Request validation (stop potentially dangerous data ever reaching the
application).
Preventing GET access for JSON data.
Preventing CSRF Using the Antiforgery Helpers
Regarding cookies Microsoft provides
HttpOnlyfeature and this helps to hide the cookies from javascript. The Forms authentication that you are talking about is aHttpOnlycookie means someone can’t steal that through JavaScript and it’s more safe.