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 5 commits into
base: master
Choose a base branch
from

Conversation

blu25
Copy link
Collaborator

@blu25 blu25 commented Jan 10, 2025

This ensures that the following things happen for both WebTransport and WebSocket objects:

  • All open connections associated with a context are closed when untrusted network access is revoked.
  • New connections cannot be created after network access is revoked.

Preview | Diff

@blu25 blu25 requested a review from VergeA January 13, 2025 19:48
@blu25 blu25 marked this pull request as ready for review January 13, 2025 19:48
spec.bs Outdated Show resolved Hide resolved
spec.bs Show resolved Hide resolved
@VergeA
Copy link
Collaborator

VergeA commented Jan 14, 2025

LGTM % 1 comment

@blu25 blu25 requested a review from VergeA January 16, 2025 22:06
Copy link
Collaborator

@VergeA VergeA left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@blu25 blu25 requested a review from domfarolino January 17, 2025 15:56
spec.bs Outdated
@@ -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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm going to move this to the disableUntrustedNetwork() algorithm itself, before the parallel steps. I think that should work.

For WebSockets, the document unloading steps you linked calls the make disappear algorithm, which directly calls fail the websocket connection without first moving into a different event loop.

For WebTransport, the cleanup algorithm is invoked by close(), and it doesn't drop into a different event loop either.

Based on that, I think it should be fine to put it directly in the non-parallel section of disableUntrustedNetwork().

Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this compare to the implementation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The implementation checks for whether the nonce stored internally corresponds to one of the network revoked nonces. Nonces in the spec are not well defined at the moment. The assumption I'm making here is that there's a 1:1 ratio of nonces to fenced frame trees/windows. If we want to explicitly check the nonce value here, that will get more tricky.

I think we can check the nonce for WebTransport, since a WebTransport session references an underlying connection, and from there you can just grab its associated key's second tuple value.

WebSockets are more tricky. The underlying connection it uses is its own separate thing that's not shareable with the fetch connection object. They do have a nonce being generated during the connection process, but I'm wasn't sure if that's actually one that would be usable for what we're trying to do.

As an alternative, I opted to not use nonces in the spec. If you think that is too much of a deviation let me know and I can try to think of a better way to do this. If that is the case, this will probably be either blocked on the existing partition nonce work, or will require extra nonce work that will be blocked on that work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I'm more concerned about the timing of the revocation, and less about the nonces involved. I just want to make sure we have something in the implementation observable equivalent to the lines this PR is adding to disableUntrustedNetwork().

@blu25 blu25 requested a review from domfarolino January 27, 2025 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants