XSS - Session hijacking

Discussion in 'ASP .Net Security' started by Robert Slaney, Feb 5, 2009.

  1. 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
     
    Robert Slaney, Feb 5, 2009
    #1
    1. Advertisements

  2. I think that it is set already, FireBug with firecookie shows the HttpOnly
    attribute is on for ASPNET_SessionID.
     
    Robert Slaney, Feb 5, 2009
    #2
    1. Advertisements

  3. Robert Slaney

    Steven Cheng Guest

    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:
    .

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

    --------------------
     
    Steven Cheng, Feb 5, 2009
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.