Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gate javascript: navigation on sandboxing flags. #5083

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mikewest
Copy link
Member

@mikewest mikewest commented Nov 13, 2019

As javascript: URLs execute in the target browsing context, it's
somewhat surprising that they can be executed from a sandboxed document
if that document is allowed to create unsandboxed popups.

This patch gates javascript: URL execution on the source document's
sandboxing flags, which is more in line with developer expectations.


💥 Error: Wattsi server error 💥

PR Preview failed to build. (Last tried on Jan 15, 2021, 7:59 AM UTC).

More

PR Preview relies on a number of web services to run. There seems to be an issue with the following one:

🚨 Wattsi Server - Wattsi Server is the web service used to build the WHATWG HTML spec.

🔗 Related URL

Parsing MDN data...
Parsing...



If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.

As `javascript:` URLs execute in the target browsing context, it's
somewhat surprising that they can be executed from a sandboxed document
if that document is allowed to create unsandboxed popups.

This patch gates `javascript:` URL execution on the source document's
sandboxing flags, which is more in line with developer expectations.
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 14, 2019
Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 14, 2019
Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Nit: this doesn't gate navigation, but it gates execution.

I wonder though how accurate the navigation algorithm really is. Do we unload when navigating to a javascript: URL? Seems unlikely.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 15, 2019
Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 16, 2019
Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1916467
Reviewed-by: Daniel Vogelheim <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#716035}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 16, 2019
Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1916467
Reviewed-by: Daniel Vogelheim <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#716035}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Nov 29, 2019
… to `javascript:`., a=testonly

Automatic update from web-platform-tests
Prevent sandboxed frames from navigating to `javascript:`.

Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1916467
Reviewed-by: Daniel Vogelheim <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#716035}

--

wpt-commits: 89aa3f42131cce5a77268ddaeb2fab8a2e29c2a6
wpt-pr: 20250
xeonchen pushed a commit to xeonchen/gecko that referenced this pull request Nov 29, 2019
… to `javascript:`., a=testonly

Automatic update from web-platform-tests
Prevent sandboxed frames from navigating to `javascript:`.

Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1916467
Reviewed-by: Daniel Vogelheim <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#716035}

--

wpt-commits: 89aa3f42131cce5a77268ddaeb2fab8a2e29c2a6
wpt-pr: 20250
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Nov 30, 2019
… to `javascript:`., a=testonly

Automatic update from web-platform-tests
Prevent sandboxed frames from navigating to `javascript:`.

Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1916467
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Reviewed-by: Avi Drissman <avichromium.org>
Commit-Queue: Avi Drissman <avichromium.org>
Cr-Commit-Position: refs/heads/master{#716035}

--

wpt-commits: 89aa3f42131cce5a77268ddaeb2fab8a2e29c2a6
wpt-pr: 20250

UltraBlame original commit: 5379811f4fed12767e6ebfad53f9612f5424a191
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Nov 30, 2019
… to `javascript:`., a=testonly

Automatic update from web-platform-tests
Prevent sandboxed frames from navigating to `javascript:`.

Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1916467
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Reviewed-by: Avi Drissman <avichromium.org>
Commit-Queue: Avi Drissman <avichromium.org>
Cr-Commit-Position: refs/heads/master{#716035}

--

wpt-commits: 89aa3f42131cce5a77268ddaeb2fab8a2e29c2a6
wpt-pr: 20250

UltraBlame original commit: 5379811f4fed12767e6ebfad53f9612f5424a191
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Nov 30, 2019
… to `javascript:`., a=testonly

Automatic update from web-platform-tests
Prevent sandboxed frames from navigating to `javascript:`.

Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: I3b5fa676e73cbf78485b85ce2593284bce2e68cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1916467
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Reviewed-by: Avi Drissman <avichromium.org>
Commit-Queue: Avi Drissman <avichromium.org>
Cr-Commit-Position: refs/heads/master{#716035}

--

wpt-commits: 89aa3f42131cce5a77268ddaeb2fab8a2e29c2a6
wpt-pr: 20250

UltraBlame original commit: 5379811f4fed12767e6ebfad53f9612f5424a191
@domenic
Copy link
Member

domenic commented Jan 22, 2020

It seems some tests have landed. Is this ready to merge, @mikewest @annevk?

@mikewest
Copy link
Member Author

I think so, yes.

That said, I think the test is broken in Firefox and Safari (https://wpt.fyi/results/html/browsers/sandboxing/sandbox-disallow-scripts-via-unsandboxed-popup.tentative.html?label=master&label=experimental&aligned) due to some changes in the way opener is propagated. I'll send y'all a PR to add rel="opener".

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

I think this makes sense. @bzbarsky if the source browsing context (which ought to be source document) has scripting disabled, navigating to javascript URLs fails?

does not have the <span>sandboxed scripts browsing context flag</span> set.</p>

<p class="XXX"><a href="https://github.com/whatwg/html/issues/2591">Issue #2591</a> applies
here as well.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Shall we move this note outside the list as it now applies to two items?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not the state we should be using, imo. The state we should be using is state at the entrypoint to "navigate", not at this later point in time, just like we do for the sandboxFlags in https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate step 14.

This even matters if we use the document's sandbox flags, since those can change over time thanks to meta CSP...

@bzbarsky
Copy link
Contributor

Anyway, in terms of behavior treating the "source is sandboxed without allow-scripts" case the same as the "target is sandboxed without allow-scripts" case makes sense to me.

qtprojectorg pushed a commit to qt/qtwebengine-chromium that referenced this pull request Mar 6, 2020
Manual backport of patch originally reviewed on
https://chromium-review.googlesource.com/c/chromium/src/+/1916467:
Prevent sandboxed frames from navigating to `javascript:`.

Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: Id3e9ebf7f4082c96a92bdaccaea1dd73f5c9b54b
Reviewed-by: Jüri Valdmann <[email protected]>
qtprojectorg pushed a commit to qt/qtwebengine-chromium that referenced this pull request Mar 23, 2020
Manual backport of patch originally reviewed on
https://chromium-review.googlesource.com/c/chromium/src/+/1916467:
Prevent sandboxed frames from navigating to `javascript:`.

Frames with the `allow-popup` and `allow-popup-to-escape-sandbox` flags
can cause JavaScript execution in their origin by navigating to a
`javascript:` URL via `target=_blank` or similar. This is technically
correct, but surprising.

whatwg/html#5083 aims to tighten that check to
match developers' expectations that `javascript:` URLs controlled by a
page that's been sandboxed away from script will not execute.

Bug: 1014371
Change-Id: Id3e9ebf7f4082c96a92bdaccaea1dd73f5c9b54b
Reviewed-by: Michal Klocek <[email protected]>
Base automatically changed from master to main January 15, 2021 07:57
@whatwg whatwg deleted a comment Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants