Closed Bug 1419501 Opened 8 years ago Closed 6 months ago

consider requiring user interaction for cross-origin iframe window.top.location navigation

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

57 Branch
enhancement

Tracking

()

RESOLVED FIXED
144 Branch
Tracking Status
firefox144 --- fixed

People

(Reporter: bkelly, Assigned: mdauer)

References

(Blocks 1 open bug, )

Details

(Keywords: dev-doc-complete, sec-want, spec-needed, Whiteboard: [adv-main144-])

Attachments

(6 files, 2 obsolete files)

We should consider requiring user interaction before allowing a cross-origin iframe to navigate the top window. For example, to prevent stuff like this: https://twitter.com/NateTheFinch/status/933030604844740609 Chrome has been running an intervention to experiment with this and are shipping some kind of mitigation in chrome 64: https://github.com/WICG/interventions/issues/16 If they are successful in shipping that, it might be nice to follow suit.
Priority: -- → P3
See Also: → 1433267
Component: DOM → DOM: Core & HTML
Severity: normal → S3
Duplicate of this bug: 1814879
Duplicate of this bug: 1955740
No longer duplicate of this bug: 1955740
Duplicate of this bug: 1749231
Duplicate of this bug: 1800190
Assignee: nobody → mdauer
Keywords: sec-want
Duplicate of this bug: 1813977
Duplicate of this bug: 1903463
Duplicate of this bug: 1942943
Duplicate of this bug: 1928010
Duplicate of this bug: 1938564
Status: NEW → ASSIGNED
Attachment #9490292 - Attachment is obsolete: true
Attachment #9496289 - Attachment description: Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention` pref, r?#settings-reviewers,maltejur,freddyb → Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention` pref, r?maltejur,freddyb
Attachment #9496289 - Attachment description: Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention` pref, r?maltejur,freddyb → Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention.enabled` pref, r?#settings-reviewers,maltejur,freddyb
Attachment #9496289 - Attachment description: Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention.enabled` pref, r?#settings-reviewers,maltejur,freddyb → Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention.enabled` pref, r?maltejur,freddyb
Duplicate of this bug: 1976497
Attachment #9503556 - Attachment description: WIP: Bug 1419501 - Part 5: Framebusting intervention browser tests → Bug 1419501 - Part 5: Framebusting intervention browser tests, r?freddyb,maltejur
Attachment #9496289 - Attachment description: Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention.enabled` pref, r?maltejur,freddyb → Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention.enabled` pref, r?#settings-reviewers,maltejur,freddyb
Attachment #9496289 - Attachment description: Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention.enabled` pref, r?#settings-reviewers,maltejur,freddyb → Bug 1419501 - Part 1: Add `dom.security.framebusting_intervention.enabled` pref, r?maltejur,freddyb
Attachment #9490715 - Attachment description: WIP: Bug 1419501 - Expand web-platform tests for preventing iframes from navigating their parent r?mdauer → Bug 1419501 - Expand web-platform tests for preventing iframes from navigating their top window r?mdauer
Pushed by mjurgens@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/1fe32fbd965f https://hg.mozilla.org/integration/autoland/rev/64540082033b Part 1: Add `dom.security.framebusting_intervention.enabled` pref, r=maltejur https://github.com/mozilla-firefox/firefox/commit/7663d6e2f74b https://hg.mozilla.org/integration/autoland/rev/34abfdeecba5 Part 2: Rename existing user-facing popup related strings, r=fluent-reviewers,bolsson,Gijs https://github.com/mozilla-firefox/firefox/commit/71ceddee6be6 https://hg.mozilla.org/integration/autoland/rev/20fbc6d90d1e Part 3: Introduce `RedirectBlockedEvent`, r=maltejur,webidl,frontend-codestyle-reviewers,smaug https://github.com/mozilla-firefox/firefox/commit/70b9c571f251 https://hg.mozilla.org/integration/autoland/rev/49381a07dfe2 Part 4: Implement framebusting intervention, r=fluent-reviewers,desktop-theme-reviewers,tabbrowser-reviewers,bolsson,edgar,mstriemer,sfoster,sthompson,emz https://github.com/mozilla-firefox/firefox/commit/cdf51f29463f https://hg.mozilla.org/integration/autoland/rev/1e1236d315cb Part 5: Framebusting intervention browser tests, r=maltejur,frontend-codestyle-reviewers https://github.com/mozilla-firefox/firefox/commit/375dd3f042bc https://hg.mozilla.org/integration/autoland/rev/a745e721346e Expand web-platform tests for preventing iframes from navigating their top window r=mdauer
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/54792 for changes under testing/web-platform/tests
See Also: → 1988107

Comment on attachment 9512678 [details]
WIP: Bug 1419501 - Add "DOMRedirectBlockedEvent" handling for mobile, r?freddy,maltejur

Revision D264466 was moved to bug 1988107. Setting attachment 9512678 [details] to obsolete.

Attachment #9512678 - Attachment is obsolete: true
Upstream PR merged by moz-wptsync-bot
Upstream PR merged by moz-wptsync-bot
Blocks: 1988107
See Also: 1988107
QA Whiteboard: [qa-triage-done-c145/b144]
Regressions: 1988311

FF144 MDN docs for this can be tracked in https://github.com/mdn/content/issues/41138

My understanding is that prior to this change a non-sandboxed cross-origin <iframe> could perform top navigation (if otherwise allowed by various protections such as those provided by COOP/COEP, whatever). So if an embedded iframe set window.top.location = 'https://example.com'; on frame load, this would succeed.

Following this change the navigation would fail unless the user had already interacted with some element in the embedded frame - i.e. Sticky activation. So you might set the top location using a button, but not on page load.
However this only applies to cross-origin frames - a same origin frame behaves as before.

  1. Is that correct?
  2. If the navigation is blocked, my understanding is that an error would be reported in the developer console and the page would simply not navigate. Is that right?
  3. How are sandboxes affected by this? Would a sandbox with allow-top-navigation still require user interaction for a cross-origin sandbox? (i.e. I don't know how to interpret the sandbox-cross-navigationXxxx tests in https://wpt.fyi/results/html/semantics/embedded-content/the-iframe-element?label=master)
  4. For browser compatibility data we might add a new subfeature "cross-origin top navigation requires sticky activation"
  5. Do you have a preferred MDN release note for this?
Flags: needinfo?(mdauer)

Thanks for working on the MDN docs for this!

  1. Is that correct?

Yes, this is correct! :]

  1. If the navigation is blocked, my understanding is that an error would be reported in the developer console and the page would simply not navigate. Is that right?

Yes. If a third-party redirect is blocked, a notification appears giving the user the choice to allow the navigation. Chrome behaves the same, whereas on Safari (at least on mobile) there is no such option. The message in the developer console looks like this:

Attempting to navigate the top-level browsing context from frame with url "https://cross.origin.frame/" which is neither same-origin nor has the required user interaction.
  1. How are sandboxes affected by this? Would a sandbox with allow-top-navigation still require user interaction for a cross-origin sandbox? (i.e. I don't know how to interpret the sandbox-cross-navigationXxxx tests in https://wpt.fyi/results/html/semantics/embedded-content/the-iframe-element?label=master)

This can be a bit tricky. Let me demonstrate with two examples. We have page A, page B and page C. All pages are cross-origin to each other and page A is always the top-level page.

  • Case 1: Page A embeds page B with the sandbox attribute set to allow-top-navigation.
  • Case 2: Page A embeds page B without a sandbox attribute. However, this time, page B embeds page C with the sandbox attribute set to allow-top-navigation.

In case 1, page B would be allowed to navigate the top-level page.

What about case 2, should page C be allowed to navigate the top-level page? No, because page B is not allowed to.
In other words, if a page is embedded with allow-top-navigation and it tries to navigate the top-level, we check if the parent is allowed to navigate.

  1. For browser compatibility data we might add a new subfeature "cross-origin top navigation requires sticky activation"

Sounds good to me, I think that's the most accurate description. Other terms that we've used are "framebusting intervention" or "third-party redirect blocking".
For the versions, this is from the Intent to prototype:

I wouldn't use the web platform tests at this point, they are marked tentative and I'm actually not quite sure why we don't pass all of the iframe_top_navigation_* tests.

  1. Do you have a preferred MDN release note for this?

As a suggestion and feel free to change it as you see the need, maybe something like this:

Framebusting Intervention: Cross-origin frames now require sticky activation to navigate the top-level page, aligning behavior with Chrome and Safari.
Flags: needinfo?(mdauer)
Depends on: 1973653

Hamish: Also take a look at the upcoming SUMO article. It may also help explain what is going on. Revision history should allow you to view the upcoming article at https://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting/history.

Furthermore, a potentially interesting difference between the browsers that we observed

  • Firefox prompts the user and logs to console
  • Chrome prompts the user and logs to console
  • Safari always blocks.
Whiteboard: [adv-main144-]
See Also: → 1992757
Duplicate of this bug: 1996448
No longer duplicate of this bug: 1996448
Regressions: 2003033
See Also: → 2004902
Blocks: 2004969
Regressions: 2006600
See Also: → 2017220
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: