DescriptionCommit empty document instead of canceling the load for blocked CSP/XFO responses.
Currently, loads that are blocked due to X-Frame-Options or CSP
frame-ancestors are canceled (firing DidFailProvisionalLoad). As part
of blocking, the current Document's origin is also changed to unique,
and the load event is fired in the FrameOwner, presumably so that the
load looks like a normal cross-origin load, where one can't discover
whether or not it was blocked.
The current implementation means that if the frame was showing another
page before attempting the blocked load, that old page will still be
showing and interactive after the block. However, the old page's
origin becomes unique, so it loses ability to communicate with its
original origin. This is not only confusing, but also seems
dangerous, as it gives someone an ability to revoke the effective
origin of a page by navigating it to something known to be blocked.
Besides DoS, this also gives an attacker a way to probe if the block
happened or not: if the attacker owns the subframe's current page and
the navigation is blocked, the current page will keep existing and can
check in with the server.
Additionally, this behavior is not compliant with the spec
(https://www.w3.org/TR/CSP2/#directive-frame-ancestors), which says that
the user agent should:
- Act as if it received an empty HTTP 200 response.
- Redirect the user to a friendly error page which provides the option of
opening the blocked page in a new top-level browsing context.
This CL changes things to follow the first option in the spec and
pretend that a blocked frame receives an empty 200 response. It still
sets the unique origin on the resulting Document, since that is also
part of the spec (the spec actually says to sandbox the Document fully
and not just with SandboxOrigin, but that change can be done
separately if desired, as it will likely break a bunch of layout
tests). The load event on the FrameOwner will now be fired during the
regular commit process on the empty document, as opposed to special
logic in DocumentLoader::cancelLoadAfterXFrameOptionsOrCSPDenied.
The original motivation for this change was that canceling blocked
loads led to problems with cross-process iframes, since the blocking
happened after process swap, when the browser process assumes the
frame's new process is going to commit, but it doesn't. This change
is more compatible with OOPIFs, and in fact fixes a bunch of layout
tests with --site-per-process and all the problems mentioned in issue
584845 without any special logic in content/.
BUG=584845
TEST=http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/* and http/tests/security/XFrameOptions/* still pass
Committed: https://crrev.com/77f6ed50529fb670db4cb3989bae5d93515a33a5
Cr-Commit-Position: refs/heads/master@{#378762}
Patch Set 1 #Patch Set 2 : #Patch Set 3 : Cleanup #Patch Set 4 : Update expectations for XFO layout tests #
Total comments: 2
Patch Set 5 : Address japhet@'s comment #Messages
Total messages: 16 (8 generated)
|