XMLHttpRequest.responseXml not accessible from signed remote XUL code

VERIFIED FIXED

Status

()

Core
Security
--
major
VERIFIED FIXED
9 years ago
9 years ago

People

(Reporter: Franck Stauffer, Assigned: bz)

Tracking

({regression, verified1.8.1.17})

1.8 Branch
regression, verified1.8.1.17
Points:
---
Dependency tree / graph
Bug Flags:
wanted1.8.1.x +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

9 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16

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

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

if (p.responseXML)
{
     var preferencesDocumentId = parseInt(p.responseXML.getElementsByTagName('id').item(0).firstChild.data);
[...]

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;
p.open("GET", requestUrl, false);
p.send(null);
               
var xmlParser = new DOMParser();
var xmlResponse = xmlParser.parseFromString(p.responseText, 'text/xml');
[...]

Only Firefox 2.0.0.15 and 2.0.0.16 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: 
http://www.lowcoders.fr/xul/getcert.php (Select the first and last chechbox)
2. Open the following URL: jar:http://www.lowcoders.fr/xul/getjar.php!/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"?>

<window
    id="findfile-window"
    title="Recherche de fichiers"
    orient="horizontal"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">


<script type="text/javascript">
function testXmlHttpRequests(){
    var request = new XMLHttpRequest();
    request.open("GET", "http://www.lowcoders.fr/xul/test.xml", false);
    request.send(null);
    alert(request.responseXML.getElementsByTagName("test").item(0).firstChild.data);
}
</script>

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

</window>

where http://www.lowcoders.fr/xul/test.xml

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

<root>
 <test>Hello!</test>
</root>
(Reporter)

Updated

9 years ago
OS: Mac OS X → All
Hardware: Macintosh → All
(Reporter)

Updated

9 years ago
Version: unspecified → 2.0 Branch
Boris, is this related to bug 434544 and/or bug 428995?
(Reporter)

Comment 2

9 years ago
To be complete, the unsigned version of the script is directly accessible here:

http://www.lowcoders.fr/xul/index.xul

Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Version: 2.0 Branch → unspecified

Updated

9 years ago
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
Status: UNCONFIRMED → NEW
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 1.8.1.18 since peterv is out of town.
Flags: blocking1.8.1.17+ → blocking1.8.1.18+
Created attachment 335415 [details] [diff] [review]
This should do the trick
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.

Updated

9 years ago
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 1.8.1.17, 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.
Status: NEW → RESOLVED
Last Resolved: 9 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:1.8.1.17) Gecko/2008082909 Firefox/2.0.0.17.
Status: RESOLVED → VERIFIED
Keywords: fixed1.8.1.17 → verified1.8.1.17
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.