|
ArticleCompartmentalizingApplications
Compartmentalizing applications within the same domain
XSS is not just a problem across domains. Some domains, including google.com, host multiple applications. An XSS vulnerability in one application can be used to launch attacks on another, entirely separate application. There are several ways you can mitigate this risk. Use a Separate Sub-domainThe Same Origin Policy ensures that script on a page loaded from domain A cannot access any properties of a page loaded from domain B. If you host your application on myapp.google.com, cross-site scripting on e.g. labs.google.com cannot access your applications security context. There are a number of caveats:
Use the secure Cookie AttributeFor cookies that are intended to be only set and read by URLs served over https, it is highly recommended to set the cookie with the secure attribute. This is desirable mainly because it will prevent the browser from sending the cookie with non-https requests to the same server. From an XSS perspective, it also has the added benefit that this cookie is not accessible to script in non-https pages; i.e., a XSS vulnerability in a page that is not served over https cannot be used to steal a secure cookie. Note though that it is possible that a page that is normally intended to be served over http only may still be accessible via https, which would make secure cookies accessible after all. Use the HttpOnly Cookie AttributeThe `HttpOnly` attribute was introduced by Microsoft in IE 6 SP1, and will be supported by Mozilla Firefox 3.0. It instructs the browser to not make a cookie visible to script (i.e., the cookie won't be included in the document.cookie property, which makes it more difficult or impossible to steal such a cookie via XSS). This attribute should be used where possible. However, it does not fully mitigate the impact of XSS, and has a number of limitations:
Further reading |
Sign in to add a comment
The primary link you have listed for the "HttpOnly?" attribute is dead. You should relabel the alternate link as the primary. I.E. only list the link for what is currently the alternate link.
@james.herdman: Fixed, thanks.
For a better introduction to the same origin policy, see the Wikipedia article which has recently been rewritten by Michal Zalewski. Compared to the old Mozilla page, it is more comprehensive, contains more examples and includes links to further reading.
I would change the two links on same origin policy in the text of this article if I could, but I keep getting a collision detected error when I try to save my changes.