To fix the security flaw, XPCNativeWrappers, a new feature of the then-in-development Firefox 1.5, were used to isolate privileged user script code from insecure content pages. Certain other changes were made, including restrictions on the GM_xmlhttpRequest method, to disallow access to local files.
Wrapping the user script environment this way creates a sandbox.
This sandbox introduces many side effects and limitations.
To allow maximum flexibility for user script authors, the
unsafeWindow property was added in to the sandbox.
For user scripts, this global window option is in fact a "deep wrapper" of the content window.
The content window can be accessed by user scripts, but only indirectly through the wrapper.
unsafeWindow property is a direct line to the actual content window.
Use of the
unsafeWindow property should be avoided whenever possible.
Its use has the potential to open up all the original security holes that introducing the XPCNativeWrappers fixed.
When a user script relies on the
unsafeWindow property, it should be included only on trusted pages, and even then is not guaranteed to be safe.