Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add to Azure Session Cookies HttpOnly and Secure attributes

In my ASP.NET MVC 4 application I use a third-party service. And one of the service's terms of use is adding to all session cookies HttpOnly and Secure attributes.

WebSite hosted on Windows Azure and works on SSL.

I added to root web.config the following settings:

<httpCookies httpOnlyCookies="true" requireSSL="true" lockItem="true"/>

<authentication mode="Forms">
    <forms loginUrl="~" timeout="2880" requireSSL="true" />
</authentication>

So now my application session cookie ".ASPXAUTH" has HttpOnly and Secure attributes.

But the main problem that Azure Balancer "WAWebSiteSID" and "ARRAffinity" cookies don't have this attributes.

Could you help me to find appropriate solution to add missing attributes to them?

like image 346
pryabov Avatar asked Jul 19 '13 16:07

pryabov


People also ask

How do I apply the secure attribute to session cookies?

The secure attribute is an option that can be set by the application server when sending a new cookie to the user within an HTTP Response. The purpose of the secure attribute is to prevent cookies from being observed by unauthorized parties due to the transmission of the cookie in clear text.

How do you set the HttpOnly attribute for any session cookie?

Set HttpOnly cookie in PHPini_set("session. cookie_httponly", True); This is the most common way to set cookies in PHP, empty variables will hold their default value.

Can a cookie be HttpOnly and secure?

You can ensure that cookies are sent securely and aren't accessed by unintended parties or scripts in one of two ways: with the Secure attribute and the HttpOnly attribute. A cookie with the Secure attribute is only sent to the server with an encrypted request over the HTTPS protocol.


1 Answers

I don't believe you can modify the secure and HttpOnly attributes as the cookies are added to the response downstream of the app (i.e. by a load balancing appliance that sits in front of the site).

Of course the pragmatic question is "why"? What advantage would you gain by not allowing client script or an MitM on the wire to access these cookies? They're nothing more than bytes of data intended to tie clients to site instances and contain nothing of a personal nature nor provide any conceivable upside for an attacker (at least not that I can think of).

The answer is probably "because it keeps a security scanning tool happy" which may make you feel warm and fuzzy, but of course it doesn't actually change the practical security position of the site one iota.

like image 162
Troy Hunt Avatar answered Sep 28 '22 03:09

Troy Hunt