html icon indicating copy to clipboard operation
html copied to clipboard

The rules for choosing a navigable "_parent" lets a cross-origin child navigate a parent != top, but implementations block it

Open sqrt0x opened this issue 2 months ago • 0 comments

What is the issue with the HTML Standard?

Assume a page with two nested iframes

Main document (Origin A)
      |---> iframe1 (Origin A)
               |---> iframe2 (Origin B)

when iframe2 is cross origin from iframe1 and iframe2._parent != iframe2._top and try to run

window.open(URL,"_parent")

most browsers stops the navigation and mark it as unsafe but the specs allows it (as per rules of choosing the _parent)

the rules for choosing a navigable

  1. Let targetNavigable and windowType be the result of applying the rules for choosing a navigable given target, sourceDocument's node navigable, and noopener.

  2. Otherwise, if name is an ASCII case-insensitive match for "_parent", set chosen to currentNavigable's parent, if any, and currentNavigable otherwise. in our case this resolves parent

  3. If sourceDocument's node navigable is not allowed by sandboxing to navigate navigable given sourceSnapshotParams... If exceptionsEnabled is true, then throw a "SecurityError" DOMException. 2. Return. in our case this is not sandboxed

  4. If target is not a top-level traversable, then return true. in our case its not top-level

to test this: WPT: https://phabricator.services.mozilla.com/D320401

sqrt0x avatar Sep 14 '26 14:09 sqrt0x