I have done some research on HttpOnly cookies and the problem that exist with the possibility to use an XHR request in combination with the TRACE method to get the cookie value echoed back from the server.
For a secure webapplication I currently have the following setup:
- Session cookie is sent at login with secure and httpOnly properties set
- The TRACE http method is disabled for the complete domain (returning "405 Method not allowed")
To avoid cross site request forgery I have added a random key in a hidden field to the forms. This key is must be returned in each POST request for the request to be accepted.
Apart from this all HTML is escaped by default using whitelisting to select tags and attributes that are allowed, but to illustrate why this is not enough: We previously allowed the style-attribute on span to be used (to color text for example), which could be used to pass javascript in Internet Explorer in the following way:
<span style="width: expression(alert('Example'));"> </span>
And then to the final question: Could anybody point out any flaws or suggestions to possible flaws in this setup? Or are you using the same or completely different approaches?
Known problems:
- Not all browsers support httpOnly
- Filtering css JS-expressions is not enough, @import(external-style-sheet) could also work