Does anyone know exactly how to set HTTPONLY on classic ASP session cookies?
This is the final thing that's been flagged in a vulnerability scan and needs fixing ASAP, so any help is appreciated.
~~~A LITTLE MORE INFORMATION ON MY PROBLEM~~~
Can anyone please help me with this?
I need to know how to set HTTPONLY on the ASPSESSION cookie created by default from ASP & IIS.
This is the cookie automatically created by the server for all asp pages.
If needed i can set HTTPONLY on all cookie across the site.
Any help on how to do this would be massively appreciated.
Thanks
Thanks Elliott
I compiled the Microsoft's ISAPI filter example. This solved my problem.
The ISAPI DLL is here
Feel free to download.
Source: http://www.asp101.com/tips/index.asp?id=160
Microsoft includes an example using an ISAPI filter to all outbound cookies: http://msdn.microsoft.com/en-us/library/ms972826
or URL rewriting could be used http://forums.iis.net/p/1168473/1946312.aspx
Setting the ASP session cookie as HttpOnly can be done in web.config using URLrewrite:
It's also possible to use URLrewrite to make all cookies HttpOnly / Secure, but sometimes you need cookies to be readable in JavaScript, so here's a collection of functions and sub routines I wrote a while ago for creating regular cookies that can enable or disable "HttpOnly" and "Secure":
Examples:
This page has lots of information that's relevant to your problem.
.NET 1.1 doesn't add
HttpOnly
because it hadn't been invented yet.If your app will run under .NET 2.0 (I moved several Classic ASP sites to 2.0 virtually unchanged) HttpOnly is set by default.
If I read him right, you can get the Session cookie and append
; HttpOnly;
to it. He gives a java example:Lastly, he suggests:
Edited to add: to those who think migrating to .NET (which can accommodate most Classic ASP code unchanged) is too drastic a change to get such a small feature, my experience of ISAPI filters is that they, too, can be a major pain, and in some common situations (shared hosting) you can't use them at all.
If you have IIS7 + you need to make sure the URL Rewrite module is installed. You can install it with the Web Platform Installer. The Web Platform Installer can be found in the features view for your website. You need to run IIS Manager as administrator.
Click on the Web Platform Installer in the features view for your website:
Maker sure the URL Rewrite Server Product is installed. If it isn't, then install it.
With the URL Rewrite Server Product installed, you can use the URL Rewrite Feature on your website to add a rule to add HttpOnly for your Session ID cookies.
You should see, if it doesn't already exist, a web.config file created for your ASP site. it will have the following contents:
If you use Firebug in Firefox to inspect your cookies, you should now see the HttpOnly flag set: