Skip to content

Correct management of sandboxing flag sets - #5686

Merged
domenic merged 3 commits into
whatwg:masterfrom
bocoup:sandboxing-flags-mgmt
Jul 10, 2020
Merged

domenic merged 3 commits into
whatwg:masterfrom
bocoup:sandboxing-flags-mgmt

Conversation

@jugglinmike

@jugglinmike jugglinmike commented Jun 26, 2020 •

Copy link
Copy Markdown
Contributor

Replace ambiguous references to a browsing context property named
"sandboxing flag set".

Closes gh-5682.


@annevk I've attempted to implement the intention as you described it in gh-5628. I'm concerned about one aspect of it, though. The "sandboxing flags" for a browsing context is described as follows:

After creation, the sandboxing flags for a browsing context browsing context are the result of determining the creation sandboxing flags given browsing context and browsing context's container.

This patch introduces a post-creation modification of the "popup sandboxing flag set" which influences the "sandboxing flags." Should the modification of "popup sandboxing flag set" also include text to update the "sandboxing flags"?


/browsing-the-web.html ( diff )
/origin.html ( diff )

Replace ambiguous references to a browsing context property named
"sandboxing flag set".

Closes whatwggh-5682.
Comment thread source Resolved
Comment thread source Resolved
Comment thread source Outdated
<li><p>Set <var>newBrowsingContext</var>'s <span>sandboxing flag set</span> to
<li><p>Set <var>newBrowsingContext</var>'s <span>popup sandboxing flag set</span> to
the <span data-x="set union">union</span> of
<var>newBrowsingContext</var>'s <span>popup sandboxing flag set</span> and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable. If we go with this should we use this language in "choosing" as well? However, if the popup sandboxing flag set is always empty at this point it might be bit confusing. Is there ever a case where it is not? Setting it to the same set or a copy of the set might be more straightforward?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are cases where the new browsing context's "popup sandboxing flag
set" is non-empty. One would be when following a hyperlink whose target is
_blank from a sandboxed iframe.

Here's my rationale

I think it may be set. For example, when following a hyperlink whose target
is _blank:

  1. Let target and replace be the result of applying the rules for choosing a
    browsing context given targetAttributeValue, source, and noopener.

[...]

  1. Queue an element task on the DOM manipulation task source given subject
    to navigate the target browsing context to request. If replace is true,
    the navigation must be performed with replacement enabled. The source
    browsing context must be source.

"target" should have a non-empty "popup sandboxing flag set" according to "The
rules for choosing a browsing context":

If the user agent has been configured such that in this instance it will
create a new browsing context

[...]

  1. If sandboxingFlagSet's sandbox propagates to auxiliary browsing contexts
    flag is set, then all the flags that are set in sandboxingFlagSet must be
    set in chosen's popup sandboxing flag set.

So, continuing on to "navigate":

  1. This is the step that attempts to obtain resource, if necessary. Jump to
    the first appropriate substep:

    [...]

    If resource is a request whose url's scheme is a fetch scheme

    • Run process a navigate fetch given resource, the source browsing
      context, browsingContext, navigationType, sandboxFlags,
      incumbentNavigationOrigin, and activeDocumentNavigationOrigin.

"Process a navigate fetch":

  1. While true:

    [...]

    1. Otherwise:

      [...]

      1. If browsingContext is a top-level browsing context, then:

        [...]

        1. Let responseRequiresBrowsingContexGroupSwitch be the result of
          checking if the response requires a browsing context group switch
          given browsingContext, responseOrigin, and responseCOOP.
        2. If responseRequiresBrowsingContextGroupSwitch is true, set
          browsingContextSwitchNeeded to true.
          [...]
  2. Run process a navigate response given request, response, navigationType,
    the source browsing context, browsingContext, finalSandboxFlags,
    responseOrigin, incumbentNavigationOrigin,
    activeDocumentNavigationOrigin, responseCOOP,
    browsingContextSwitchNeeded, and reservedEnvironment.

"browsingContextSwitchNeeded" should be true, according to "check if a response
requires a browsing context group switch":

  1. If browsingContext's only entry in its session history is the about:blank
    Document that was added when browsingContext was created, then set
    isInitialAboutBlank to true.

So, continuing on to "process a navigate response":

  1. If the user agent has been configured to process resources of the given
    type using some mechanism other than rendering the content in a browsing
    context, then skip this step. Otherwise, if the type is one of the
    following types, jump to the appropriate entry in the following list, and
    process response as described there:
  • an HTML MIME type
    • Follow the steps given in the HTML document section providing
      browsingContext, request, response, finalSandboxFlags,
      finalResponseOrigin, incumbentNavigationOrigin,
      activeDocumentNavigationOrigin, reservedEnvironment, responseCOOP, and
      browsingContextSwitchNeeded. Once the steps have completed, return.

From "an HTML document is to be loaded":

  1. Let document be the result of creating and initializing a Document object
    providing "html", "text/html", request, response, browsingContext,
    finalSandboxFlags, finalResponseOrigin, incumbentNavigationOrigin,
    activeDocumentNavigationOrigin, environment, responseCOOP, and
    browsingContextSwitchNeeded.

From "create and initialize a Document object":

  1. If browsingContextSwitchNeeded is true, set browsingContext to the result
    of the obtain a browsing context to use for a navigation response
    algorithm, given browsingContext, finalSandboxFlags, and navigationCOOP.

Does that seem right to you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would

If sandboxFlags is not empty and responseCOOP is not "unsafe-none", then set response to an appropriate network error and break.

not be hit in this scenario?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I lost track of that value. Do you think it's reasonable to explicitly assert that fact?

The reference to "union" is no longer needed in this patch, but I'm still committed to introducing it in a follow-up.

Comment thread source
@@ -82283,7 +82287,7 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
close to reality its current definition is. -->

<li><p>Let <var>finalSandboxFlags</var> be the union of <var>browsingContext</var>'s

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe link union here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind if I fix that in a follow up? There are a handful of other places where it's needed, and doing that in a separate commit will keep this one a little more focused.

Comment thread source Resolved
@annevk

annevk commented Jul 10, 2020

Copy link
Copy Markdown
Member

Yeah that seems fine to me (to both). @domenic should probably have a look as well.

@domenic
domenic merged commit 87736f1 into whatwg:master Jul 10, 2020
@domenic domenic added topic: frames/navigables/browsing contexts iframe, navigables, browsing contexts and browsing context groups topic: sandbox Sandboxing: the iframe sandbox attribute and the sandboxing flags labels Jul 10, 2020
@jugglinmike

Copy link
Copy Markdown
Contributor Author

Thank you! Here's the "set union" patch @annevk requested #5730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: frames/navigables/browsing contexts iframe, navigables, browsing contexts and browsing context groups topic: sandbox Sandboxing: the iframe sandbox attribute and the sandboxing flags

Development

Successfully merging this pull request may close these issues.

COOP: Potential ambiguity in definition of sandboxing flag sets

3 participants