JavaScript: The Definitive Guide

Previous Chapter 20
JavaScript Security

20.3 The domain Property

As we've seen, Navigator 2.0.2 and later implement a very general security hobble intended to blanket an entire category of security holes: scripts from one server cannot read properties of windows or documents from another server. This is quite a severe restriction, and poses problems for large web sites that use more than one server. For example, a script from might legitimately want to read properties of a document loaded from While this seems like a reasonable and secure thing to do, the hobble does not allow it.

In order to support large web sites of this sort, Navigator 3.0 slightly relaxes the security hobble by introducing the domain property of the Document object. Internet Explorer 3.0 does not implement this property, but, as noted above, it also does not implement the problematic security hobble. By default, the domain property is the same as the hostname of the web server from which the document was loaded. You can set this property, but only to a string that is a valid domain suffix of itself. Thus, if domain is the string "", you can set it to the string "", but not to "home.netscape" or "", and certainly not to "".

If two windows contain scripts that both set their domain to the same value, then the security hobble will be relaxed for these two windows and in each of windows may read properties from the other.

Previous Home Next
Security Holes and Security Hobbles Book Index The Data-Tainting Security Model

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
Hosted by uCoz