Closed Bug 445890 Opened 13 years ago Closed 13 years ago

XMLHttpRequest.responseXml not accessible from signed remote XUL code


(Core :: Security, defect)

1.8 Branch
Not set





(Reporter: fstauffer, Assigned: bzbarsky)



(Keywords: regression, verified1.8.1.17)


(1 file)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv: Gecko/20080702 Firefox/
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv: Gecko/20080702 Firefox/

We are developing a signed remote XUL CMS. Since firefox we have serious problems with XmlHttpRequests,the following code used to work just fine

p = new XMLHttpRequest();
p.onload = null;"GET", requestUrl, false);

if (p.responseXML)
     var preferencesDocumentId = parseInt(p.responseXML.getElementsByTagName('id').item(0);

but now it seems p.responseXML has some rather very restrictive security access restrictions. The workaround is to do something like this:

p = new XMLHttpRequest();
p.onload = null;"GET", requestUrl, false);
var xmlParser = new DOMParser();
var xmlResponse = xmlParser.parseFromString(p.responseText, 'text/xml');

Only Firefox and Mac/Win and probably linux exhibit that problem (even FF3 is fine).

Reproducible: Always

Steps to Reproduce:
(Online dummy testcase)

1. Install the signing certificate from here: (Select the first and last chechbox)
2. Open the following URL: jar:!/index.xul
Actual Results:  
JS Error console:
Error: uncaught exception: Permission denied to call method XMLDocument.getElementsByTagName

Expected Results:  
JS alert with the text "Hello"

Content of index.xul inside the signed jar:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

    title="Recherche de fichiers"

<script type="text/javascript">
function testXmlHttpRequests(){
    var request = new XMLHttpRequest();"GET", "", false);

<vbox flex="1">
		<button label="Test" oncommand="testXmlHttpRequests()" />
		<spacer flex="1"/>
	<spacer flex="1"/>



<?xml version="1.0" encoding="utf-8"?>

OS: Mac OS X → All
Hardware: Macintosh → All
Version: unspecified → 2.0 Branch
Boris, is this related to bug 434544 and/or bug 428995?
To be complete, the unsigned version of the script is directly accessible here:

Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Version: 2.0 Branch → unspecified
Version: unspecified → 1.8 Branch
Yeah.  The problem is that the signed script and the data gotten via XMLHttpRequest are different origins, since said data doesn't come from inside the signed jar.

On trunk, we set the calling document principal on the XMLHttpRequest response (see bug 326337), but that change never landed on branch, so we get this bug.
Blocks: 418996
Component: DOM → Security
Ever confirmed: true
Flags: wanted1.8.1.x?
Flags: blocking1.8.1.17?
Flags: blocking1.8.1.16?
Keywords: regression
QA Contact: general → toolkit
So this would be fixed by a branch version of the patch in bug 326337?
Assignee: nobody → peterv
Depends on: 326337
Flags: wanted1.8.1.x?
Flags: wanted1.8.1.x+
Flags: blocking1.8.1.17?
Flags: blocking1.8.1.17+
Flags: blocking1.8.1.16?
I would think so, yes.
If you want this fixed in the next three weeks you'll need to find a better owner.
Johnny or Boris, can you take this on?
Moving out to since peterv is out of town.
Flags: blocking1.8.1.17+ → blocking1.8.1.18+
Attachment #335415 - Flags: superreview?(jst)
Attachment #335415 - Flags: review?
Attachment #335415 - Flags: review? → review?(Olli.Pettay)
Comment on attachment 335415 [details] [diff] [review]
This should do the trick

It is different question if we need Bug 421228 on 1.8.
Attachment #335415 - Flags: review?(Olli.Pettay) → review+
Gah.  Yes, we'd need that; good catch.  But there is no nullprincipal on 1.8...  I guess we could make it use about:blank?
Actually, I don't think we need it.  The data document content policy won't get bypassed on branch, and that's all that really matters here, I think.
Attachment #335415 - Flags: superreview?(jst) → superreview+
Attachment #335415 - Flags: approval1.8.1.17?
Comment on attachment 335415 [details] [diff] [review]
This should do the trick

Is it going to matter that in a redirect case the principal doesn't get updated? On branch they're guaranteed same-origin so they would at least be equivalent principals, but is this case handled OK for XS-XHR on trunk?

regardless, for 1.8 branch approved for, a=dveditz for release-drivers
Attachment #335415 - Flags: approval1.8.1.17? → approval1.8.1.17+
Assignee: peterv → bzbarsky
Fix checked into 1.8 branch.
Closed: 13 years ago
Keywords: fixed1.8.1.17
Resolution: --- → FIXED
We don't have XS-XHR on trunk yet, and when we do we'll likely still stamp the document with the loader principal so that the loader can actually get that data.

Thanks for checking this in!
Verified with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2008082909 Firefox/
Depends on: 456705
Depends on: 457411
Removing the blocker flag for a release _after_ the one this was fixed in, since it's not really relevant anymore.
Flags: blocking1.8.1.18+
You need to log in before you can comment on or make changes to this bug.