We have been notified through a penetration test that our website is not securing the ASPXAUTH and ASP.NET_SessionId cookies.
I have made several changes to secure the cookies.
- 1) Added the requireSSL="true" attribute to the System.Web -> Authentication -> Forms element in the web.config.
- 2) In the code that clears the ASP.NET_SessionId and ASPXAUTH cookies on initial login and logout that sets them to be secure and HTTP Only.
- 3) Added code to the Application_EndRequest method Global.asax that specifically sets the ASP.NET_SessionId and ASPXAUTH cookies in Response.Cookies to Secure and HttpOnly.
I can't figure out why the second one matters, but without it, the ASP.NET_SessionId cookie never shows up in the response object as secure.
Using the Chrome Developer tools I have taken a screenshot at several timepoints and some of the behavior looks unexpected to me. If someone could take a look at this and let me know if things are behaving correctly, I would very much appreciate it.
This screenshot was taken on initial page load after clearing cookies for the site: Upon initial page load
The two SessionId cookies seem odd to me, why is there one that is secure, and one that isn't?
This screenshot was taken after clicking to log in to the site:After clicking log in
This one makes even less sense to me, why is the ASP.NET_SessionId cookie in the request not flagged as secure, or HttpOnly, is this expected behavior? I'm assuming no SessionId cookie being sent in the response is correct behavior
This screenshot was taken after clicking a link on the site to view a new page:enter image description here
If possible, this makes even less sense to me. The two cookies in question are sent in the request, both not set HttpOnly or Secure. Is this correct behavior? Additionally, is neither cookie appearing in the response correct?
I've spent quite a big of time here on StackOverflow and with The Google to try to find the correct way to configure these cookies. I just don't know if what I've done was correct, as I'm not sure what the fixed implementation should even look like.
Any help that can be provided would be very much appreciated.
Thank you, -Nathan