Skip to content

IFrames that set document.domain are still accessible from the parent #44669

Closed

Description

@jdm

c.html:

<iframe id=i src="c2.html"></iframe>
<script>
  i.onload = () => {
      console.log("iframe load");
      i.contentWindow.stop();
  }
</script>

c2.html

<script>
console.log("setting domain");
document.domain = document.domain;
</script>

In Firefox this shows:

12:49:08.941 setting domain [c2.html:2:11](http://localhost:8000/c2.html)
12:49:08.942 iframe load [c.html:4:15](http://localhost:8000/c.html)
12:49:08.942 Uncaught DOMException: Permission denied to access property "stop" on cross-origin object
    onload http://localhost:8000/c.html:5
    EventHandlerNonNull* http://localhost:8000/c.html:3

In Servo this shows:

setting domain
iframe load

Activity

  1. added
    C-has-manual-testcase
    on May 1, 2026
  2. jdm commented on May 1, 2026

    @jdm
    MemberAuthor

    I'm pretty sure this is the major motivation for cross-origin wrappers in Gecko. We need things like a Location reference obtained from a same-origin iframe to become cross-origin restricted if the iframe sets document.domain, and they also need to become unrestricted once again if the parent sets document.domain such that the iframe is once again same-origin.

  3. added
    A-content/bindings
    E-very-complex
    on May 1, 2026
  4. changed the title [-]Iframes that set document.domain are still accessible from the parent[/-] [+]IFrames that set document.domain are still accessible from the parent[/+] on May 1, 2026
  5. jdm commented on Jun 19, 2026

    @jdm
    MemberAuthor

    This also affects <iframe sandbox="">; iframe.contentWindow and iframe.contentDocument don't do anything special here.

    // TODO: These traps should change their behavior depending on
    // `IsPlatformObjectSameOrigin(this.[[Window]])`
    is relevant for iframe.contentWindow.

    <iframe sandbox=""></iframe>
    <script>
      let iframe = document.querySelector('iframe');
      console.log(iframe.contentWindow.foo);
    </script>

    This should throw an exception, but it just prints undefined in Servo.

  6. added a commit that references this issue on Sep 3, 2026
    dfac8fa
  7. added a commit that references this issue on Oct 6, 2026
    5dc8cf4
  8. added a commit that references this issue on Oct 12, 2026
    1ee1a34
  9. added a commit that references this issue on Nov 9, 2026
    ce22152
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/bindingsA-securityC-has-manual-testcaseE-very-complex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions