XSS - Session hijacking

R

Robert Slaney

note - using ASP.NET 2.0

I would like to set the httponly cookie flag on the asp.net sessionid
cookie. I know I can set this via the httpCookies element in web.config, but
I don't want to set all cookies to have this flag.

I have some cached static pages that use values from the cookies in
javascript so until I can reengineer these pages to remove this I cannot set
the web.config in this way.

Does the default asp.net session provider have the ability to set it's
cookie to HttpOnly ?

Cheers...

Rob
 
R

Robert Slaney

I think that it is set already, FireBug with firecookie shows the HttpOnly
attribute is on for ASPNET_SessionID.
 
S

Steven Cheng

Hi Rob,

As for the SessionID cookie, it is generated internally by the default
sessionIdManager. You can find the internal code logic through reflector.
Here is the code snippet extract from it:

======default SessionIdManager class======

private static HttpCookie CreateSessionCookie(string id)
{
HttpCookie cookie = new HttpCookie(Config.CookieName, id);
cookie.Path = "/";
cookie.HttpOnly = true;
return cookie;
}

=================

As you can see, it explicitly set HttpOnly to true. Also, I've tested the
session cookie via some javascript, and the javascript code cannot retrieve
it, that also indicate the cookie is httpOnly and protected from
client-script.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top