Closed Bug 1045537 Opened 10 years ago Closed 10 years ago

Permission denied to access object in iframe when document.domain is modified

Categories

(Core :: DOM: Core & HTML, defect)

29 Branch
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox31 - wontfix
firefox32 + wontfix
firefox33 + wontfix
firefox34 + wontfix

People

(Reporter: kohei, Unassigned)

References

()

Details

(Keywords: regression, site-compat)

Attachments

(2 obsolete files)

A Firefox 31 regression reported in https://twitter.com/PG_IDMS/status/493776386205970432

I'll try to make a minimum testcase.
Attached file testcase (obsolete) —
Attachment #8463926 - Attachment mime type: text/plain → text/html
Attached file testcase (obsolete) —
Attachment #8463926 - Attachment is obsolete: true
https://push.boerse-stuttgart.de/files/js-api/1.6.1/iframe.html
document.domain is changed to "boerse-stuttgart.de"

https://push.boerse-stuttgart.de/files/js-api/1.6.1/jframe.html
document.domain is kept as "push.boerse-stuttgart.de"

So the same-origin policy prevent jframe.html from being accessed by iframe.html, while this was working without an error on Firefox 30 and below.
Component: DOM: Core & HTML → DOM
Summary: Permission denied to access object when the object is in iframe → Permission denied to access object in iframe when document.domain is modified
>document.domain is changed to "boerse-stuttgart.de"
>document.domain is kept as "push.boerse-stuttgart.de"

Then those should not be same-origin and shouldn't have been in Firefox 30 either.

It looks like the exact sequence here is this.  iframe.html does:

  var jInit;
  jInit        = jframe.contentWindow.jInit;
  // set document.domain here, so it's no longer same-origin with jframe
  init        = function(logger, base64, lowerBound, upperBound, config)
              { jInit(logger, base64, lowerBound, upperBound, config); };

Then later this init function is called.

Imo, this code should not, in fact, work.  I'm really surprised it ever did.  Bobby, do you have any idea how it managed that?
Flags: needinfo?(bobbyholley)
Comment on attachment 8463927 [details]
testcase

This testcase is not working on Firefox 30 anyway. I've got an Error: Permission denied to access property 'document'
Attachment #8463927 - Attachment is obsolete: true
Hi,

thank you for your investigation. I looks like the functions from jframe.html are being set in iframe.html and used after iframe.html sets its document.domain. This should prevent iframe.html from using the functions from jframe.html, but the pointers set in iframe.html are still working despite the document.domain being different. I guess one of the first developers of this API knew this bug and used it to set the document.domain within the initialization function instead of at the start of every iframe.

I have managed to change the order of the document.domain being set.
It now is no longer set in the initialization functions but within the iframes themselves right at the start. I hope this does not cause any regressions.

Thank you very much,
Philipp Gemind
We won't make a new release of 31 for this. However, we would be happy to take a patch in 32.
This used to work because the testcase was calling a function it already had a reference to (and nothing else). In bug 976704, I changed our opaque wrappers to deny CALL.

The spec for this stuff is basically at an impasse, which isn't likely to change any time soon - our behavior is more secure, but WebKit/Blink won't implement it because it's hard. Regardless though, bug 976704 makes our behavior more consistent, so absent more major web-compat regressions I think it should stay.
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: needinfo?(bobbyholley)
Resolution: --- → WONTFIX
Blocks: 976704
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: