Firefox cookie-stealing vulnerability

By | February 15, 2007

A new zero-day vulnerability in Mozilla Firefox allows malicious web sites to forge authentication cookies for certain web sites.

The problem lies in the way Firefox handles writes to ´location.hostname´ DOM property, says Michal Zalewski, an independent security researcher.

According to Zalewski, it is possible for a malicious script to set the value of the hostname property that would not be accepted as a hostname when parsing a regular URL.

Doing this prompts a peculiar behavior: internally, DOM string variables are not NULL-terminated, and as such, most of checks will consider ´´ to be a part of * domain. The DNS resolver, however, and much of the remaining browser code, operates on ASCII strings native to C/C++ instead, treating the aforementioned example as ´´.

This makes it possible for to modify location.hostname as described above, and have the resulting HTTP request still sent to Once the new page is loaded, the attacker will be able to set cookies for *; he´ll be also able to alter document.domain accordingly, in order to bypass the same-origin policy for XMLHttpRequest and cross-frame / cross-window data access.

The vulnerability affects Firefox version, but it is likely also to affect older versions.

Leave a Reply