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

[Spec] Network revocation patches for WebSocket and WebTransport APIs #206

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 84 additions & 3 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ spec: attribution-reporting; urlPrefix: https://wicg.github.io/attribution-repor
spec: turtledove; urlPrefix: https://wicg.github.io/turtledove/
type: dfn
text: construct a pending fenced frame config; url: construct-a-pending-fenced-frame-config
spec: RFC6455; urlPrefix: https://datatracker.ietf.org/doc/html/rfc6455
type: dfn
text: fail the WebSocket connection; url: #section-7.1.7
spec: WebSocket; urlPrefix: https://websockets.spec.whatwg.org/
type: dfn
text: establish a WebSocket connection; url: #concept-websocket-establish
spec: WebTransport; urlPrefix: https://w3c.github.io/webtransport
type: dfn
for: WebTransport
text: cleanup; url: #webtransport-cleanup
text: queue a network task; url: #webtransport-queue-a-network-task
text: initialize WebTransport over HTTP; url: #initialize-webtransport-over-http
</pre>

<style>
Expand Down Expand Up @@ -2123,6 +2135,16 @@ Issue: This will require a RFC to add a test-only function to the WPT web driver
1. [=set/Append=] |nonce| to the user agent's [=network revocation nonce set=].

1. [=fetch group/terminated|Terminate=] |settings|'s [=fetch/fetch group=].

1. [=list/For each=] {{WebSocket}} object |webSocket| whose [=relevant settings object=] is
Copy link
Collaborator

Choose a reason for hiding this comment

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

This algorithm is called in parallel so I don't really think it's valid for us to be inspecting "each" WebIDL WebSocket object of a given settings object, and running algorithms on it that (a) HTML currently runs as a task on the Document's event loop, and (b) the WebSocket spec itself only runs as proper event-loop-bound networking tasks. So we should probably (a) figure out a better way to restructure this, and (b) add a step at the beginning of this algorithm to assert that this is running in parallel, to make it easier to catch this kind of stuff in the future.

|settings|, run [=fail the WebSocket connection=] given |webSocket|.
VergeA marked this conversation as resolved.
Show resolved Hide resolved

1. [=list/For each=] {{WebTransport}} object |webTransport| whose [=relevant settings object=] is
|settings|, [=WebTransport/cleanup=] |webTransport| with a newly [=exception/create|created=]
{{WebTransportError}} whose {{WebTransportErrorOptions/source}} is `"session"`.

Note: Not passing in a {{WebTransportCloseInfo}} ensures that the {{WebTransport}} object is
set to the `"failed"` state rather than the `"closed"` state.
</div>

<div algorithm>
Expand Down Expand Up @@ -2161,7 +2183,41 @@ The network revocation mechanism requires the following monkeypatches to the [[F
(<a href="https://github.com/WICG/fenced-frame/issues/191">WICG/fenced-frame#191</a>)
</div>

The network revocation mechanism requires the following monkeypatches to the [[HTML]] Standard.
<h3 id=disable-websocket>WebSocket monkeypatches for network revocation</h3>

The network revocation mechanism requires the following monkeypatch to the [[WebSockets]]
Standard.

<div algorithm=establish-websocket-patch>
Modify the [=establish a WebSocket connection=] algorithm. Add a new step after step 10 that
reads:

11. If the result of running [=determine if a navigable has revoked network for itself=] given
<var ignore>client</var>'s [=environment settings object/global object=]'s
[=Window/navigable=] is true, [=fail the WebSocket connection=].
</div>

<h3 id=disable-webtransport>WebTransport monkeypatches for network revocation</h3>

The network revocation mechanism requires the following monkeypatch to the [[WebTransport]]
Standard.

<div algorithm=initialize-webtransport-patch>
Modify the [=initialize WebTransport over HTTP=] algorithm. Rewrite step 5 (keeping all substeps
unchanged) to read:

5. If any of the following conditions are true:

- Running [=should request be blocked by Content Security Policy?=] with |request| returns
**"Blocked"**;
- Running [=should request be blocked due to a bad port=] with |request| returns **"blocked"**;
- Running [=determine if a navigable has revoked network for itself=] given <var
ignore>client</var>'s [=environment settings object/global object=]'s [=Window/navigable=]
returns true;

then abort the remaining steps and [=WebTransport/queue a network task=] with
<var ignore>transport</var> to run these steps:
</div>

<h3 id=new-request-destination>New [=request=] [=request/destination=]</h3>

Expand Down Expand Up @@ -2198,16 +2254,25 @@ table](https://fetch.spec.whatwg.org/#destination-table) to illustrate that <{fe

<h3 id=gating-methods-on-network-revocation>Gating methods on network revocation</h3>

*This first introductory paragraph is non-normative.*
*This introductory section is non-normative.*

After a fenced frame has fully disabled untrusted network access, meaning the {{Promise}} returned
by {{Fence/disableUntrustedNetwork()}} has [=resolved=], certain powerful interface methods will
become available to script which executes inside of the fenced frame. These methods are defined in
other specifications, which will use the below algorithm to determine if invocation can occur
other specifications, which will use the first algorithm below to determine if invocation can occur
successfully. One example of a method which is gated behind revocation of untrusted network access
is {{SharedStorage/get()}} when invoked outside of a {{SharedStorageWorklet}}. This method is
defined in the [[Shared-Storage]] draft specification.

In the intermediate state where {{Fence/disableUntrustedNetwork()}} has been called but the returned
{{Promise}} has not [=resolved=] yet, there are restrictions on features that involve making
requests over the network. The second algorithm below is used to determine whether those features
are allowed.
blu25 marked this conversation as resolved.
Show resolved Hide resolved

We make the distinction between "fully revoked" and "revoked for self"
because nested fenced frame trees might still have network access, and these restrictions will not
apply to them until they have invoked {{Fence/disableUntrustedNetwork()}} as well.

<div algorithm>
To <dfn export>determine if a navigable has fully revoked network</dfn> given a [=navigable=]
|navigable|:
Expand All @@ -2224,6 +2289,22 @@ defined in the [[Shared-Storage]] draft specification.
1. Return true.
</div>

<div algorithm>
To <dfn>determine if a navigable has revoked network for itself</dfn> given a [=navigable=]
|navigable|:

1. If |navigable|'s [=navigable/traversable navigable=] is not a [=fenced navigable
container/fenced navigable=], return false.

1. Let |config| be |navigable|'s [=navigable/active browsing context=]'s [=browsing
context/fenced frame config instance=].

1. If |config|'s [=fenced frame config instance/untrusted network status=] is [=untrusted network
status/enabled=], return false.

1. Return true.
</div>

<h3 id=automatic-reporting>Automatic Reporting</h3>

*This first introductory paragraph is non-normative.*
Expand Down
Loading