Automatic update from web-platform-tests
Prevent sandboxed iframe Document from sharing execution context with initial about:blank Document
This change fixes an issue where a sandboxed iframe can be created such
that it contains a sandboxed Document with an opaque origin that still
shares a script context with the iframe's initial un-sandboxed
about:blank Document. The scenario is set up in the following manner:
- Create a new iframe dynamically, and set its src to a same-domain page
that we are going to sandbox.
- Insert the iframe into a Document, and synchronously grab a reference
to its initial about:blank Document.
- Synchronously set iframe.sandbox = "allow-scripts" (this is still
before the same-domain page has loaded in the frame).
- The iframe’s navigation to the same-domain page occurs, asynchronously.
FrameLoader::ShouldReuseDefaultView is called to determine the mode in
which to load the new page. FrameLoader::ShouldReuseDefaultView fails
to check the iframe’s sandbox flags (it only looks at the CSP ones),
so the navigation proceeds without resetting the type system of the
iframe. The result is that the newly loaded page shares the type
system of the initial about:blank Document.
- Code in the sandboxed iframe is now free to make changes to its type
system that can affect any usage of the about:blank Document since
they share the same type system. This is a sandbox escape in that if
the same-domain page that the iframe is navigated to contains
user-generated code, it could run outside the iframe. It can also
result in crashes if we poke things in the right way, since an object
that should be considered cross-origin can bleed into the top-level
page, with the result that access checks which are never expected to
fail can now fail.
This change fixes the issue by making FrameLoader::ShouldReuseDefaultView()
check the iframe's sandbox flags via FrameLoader::EffectiveSandboxFlags(),
in addition to the existing check for CSP sandbox flags.
Reviewed-by: Daniel Cheng <email@example.com>
Reviewed-by: Nate Chapin <firstname.lastname@example.org>
Commit-Queue: Dan Clark <email@example.com>