Skip to content

Commit 5b5fcb5

Browse files
committed
Define behavior for WebRTC.
As discussed in #6, we've landed on a global toggle for WebRTC. This PR defines the toggle and sketches the integration into the WebRTC specification.
1 parent a6184e2 commit 5b5fcb5

1 file changed

Lines changed: 95 additions & 9 deletions

File tree

index.bs

Lines changed: 95 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ and/or misconfigurations:
121121
responses regardless of destination will be blocked. Developers can choose to allow all redirect
122122
responses by setting a parameter on the header. See [[#redirects]] for details.
123123

124+
* Similarly, WebRTC connections are difficult to constrain via URL patterns, as they often involve
125+
dynamic endpoint discovery and peer-to-peer connections. We'll provide a global toggle to allow
126+
developers to choose whether to allow or block WebRTC connections entirely. See [[#webrtc]] for
127+
details.
128+
124129

125130
Overlap with Content Security Policy {#overlap-with-csp}
126131
------------------------------------
@@ -168,6 +173,10 @@ is allowed to connect. It is a [=struct=] with the following [=struct/items=]:
168173
<dfn grammar for="Connection Allowlist/redirects">allow</dfn> or
169174
<dfn grammar for="Connection Allowlist/redirects">block</dfn>. It is
170175
<a grammar for="Connection Allowlist/redirects">block</a> unless otherwise specified.
176+
* <dfn for="Connection Allowlist">webrtc</dfn>, which is either
177+
<dfn grammar for="Connection Allowlist/webrtc">allow</dfn> or
178+
<dfn grammar for="Connection Allowlist/webrtc">block</dfn>. It is
179+
<a grammar for="Connection Allowlist/webrtc">block</a> unless otherwise specified.
171180

172181

173182
Connection Allowlist Headers {#headers}
@@ -202,6 +211,13 @@ The [=structured header/inner list=] may have arbitrary [=structured header/para
202211
[=structured header/token=] `block`, and
203212
<a grammar for="Connection Allowlist/redirects">allow</a> otherwise.
204213

214+
* The <dfn grammar for="Connection-Allowlist">`webrtc`</dfn> parameter's value will be parsed
215+
as a [=structured header/token=]. If it is present, it will be used to set the allowlist's
216+
[=Connection Allowlist/webrtc=]. It will be set to
217+
<a grammar for="Connection Allowlist/webrtc">block</a> if the value is the
218+
[=structured header/token=] `block`, and
219+
<a grammar for="Connection Allowlist/webrtc">allow</a> otherwise.
220+
205221
All other parameters will be ignored.
206222

207223
Parsing {#parsing}
@@ -280,6 +296,15 @@ To <dfn abstract-op local-lt="parse header">parse a Connection Allowlist header<
280296
2. Else, set |allowlist|'s [=Connection Allowlist/redirects=] to
281297
<a grammar for="Connection Allowlist/redirects">allow</a>.
282298

299+
3. If |key| is <a grammar for="Connection-Allowlist">`webrtc`</a> and |value| is a
300+
[=structured header/token=]:
301+
302+
1. If |value| is "`block`", set |allowlist|'s [=Connection Allowlist/webrtc=] to
303+
<a grammar for="Connection Allowlist/webrtc">block</a>.
304+
305+
2. Else, set |allowlist|'s [=Connection Allowlist/webrtc=] to
306+
<a grammar for="Connection Allowlist/webrtc">allow</a>.
307+
283308
6. Return |allowlist|.
284309

285310

@@ -345,8 +370,7 @@ The <dfn abstract-op export>should |url| be blocked by Connection Allowlists</df
345370

346371
1. [=list/iterate|For each=] |connection allowlist| in |connection allowlists|:
347372

348-
1. If [=match a URL to a Connection Allowlist=] given |url| and |connection allowlist| returns [=success=],
349-
[=continue=].
373+
1. If |url| [=matches=] |connection allowlist|, [=continue=].
350374

351375
2. [$report|Report a violation$] given |url|, |environment|, and
352376
|connection allowlist|.
@@ -384,8 +408,7 @@ takes a [=/request=] (|request|), and returns either [=allowed=] or [=blocked=]:
384408

385409
4. [=Continue=].
386410

387-
2. If [=match a URL to a Connection Allowlist=] given |request|'s [=request/url=] and
388-
|allowlist| returns [=success=], [=continue=].
411+
2. If |request|'s [=request/url=] [=matches=] |allowlist|, [=continue=].
389412

390413
3. [$report|Report a violation$] given |request|'s [=request/url=], |request|'s
391414
[=request/client=], and |allowlist|.
@@ -417,6 +440,28 @@ a [=/host=] (|host|), an [=environment=] (|environment|), and a [=list=] of
417440
</div>
418441

419442

443+
<div algorithm>
444+
The <dfn abstract-op export>should WebRTC be blocked by Connection Allowlists</dfn> algorithm takes
445+
an [=environment settings object=] (|environment|) and returns either [=allowed=] or [=blocked=]:
446+
447+
1. Let |allowlists| be |environment|'s [=environment settings object/policy container=]'s
448+
[=policy container/connection allowlists=].
449+
450+
1. [=list/iterate|For each=] |allowlist| in |allowlists|:
451+
452+
1. If |allowlist|'s [=Connection Allowlist/webrtc=] is
453+
<a grammar for="Connection Allowlist/webrtc">allow</a>, [=continue=].
454+
455+
2. [$report|Report a violation$] given "`webrtc`", |environment|, and |allowlist|.
456+
457+
3. If |allowlist|'s [=Connection Allowlist/disposition=] is
458+
<a grammar for="Connection Allowlist/disposition">enforce</a>, return [=blocked=].
459+
460+
2. Return [=allowed=].
461+
462+
</div>
463+
464+
420465
Reporting {#reporting}
421466
---------
422467

@@ -445,15 +490,20 @@ serialized [=/URL=] of the connection which violated the allowlist.
445490
is the {{ConnectionAllowlistViolationReport/allowlist}}'s [=Connection Allowlist/disposition=].
446491

447492
<div algorithm>
448-
To <dfn abstract-op local-lt="report">report a violation</dfn> given a [=URL=] (|resource URL|),
449-
an [=environment=] (|environment|), and a [=connection allowlist=] (|allowlist|):
493+
To <dfn abstract-op local-lt="report">report a violation</dfn> given a [=URL=] or the [=string=]
494+
"`webrtc`" (|resource URL|), an [=environment=] (|environment|), and a
495+
[=connection allowlist=] (|allowlist|):
450496

451497
1. If |allowlist|'s [=Connection Allowlist/reporting endpoint=] is `null`, return.
452498

453499
2. Let |violation| be a new {{ConnectionAllowlistViolationReport}}, initialized as follows:
454500

501+
: {{ConnectionAllowlistViolationReport/url}}
502+
:: |environment|'s [=environment/creation URL=], [=strip URL for use in reports|stripped for use in reports=].
503+
455504
: {{ConnectionAllowlistViolationReport/connection}}
456-
:: |resource URL|, [=strip URL for use in reports|stripped for use in reports=].
505+
:: If |resource URL| is a [=URL=], then |resource URL|, [=strip URL for use in reports|stripped for use in reports=].
506+
:: Otherwise, |resource URL|.
457507

458508
: {{ConnectionAllowlistViolationReport/allowlist}}
459509
:: A new list containing the result of serializing each pattern in |allowlist|'s [=Connection Allowlist/allowlist=]
@@ -542,7 +592,8 @@ step to the [=create a policy container from a fetch response=] algorithm:
542592
Integration with WebRTC {#rtc}
543593
-----------------------
544594

545-
ISSUE: I need to read more, as I have no idea how any of this works from a spec perspective. :)
595+
To constrain WebRTC connections, [[webrtc]] can call into the [$should WebRTC be blocked by Connection Allowlists$]
596+
algorithm while determining whether candidates are <a spec="webrtc">administratively prohibited</a>.
546597

547598

548599
Security and Privacy Considerations {#security}
@@ -576,7 +627,7 @@ be helpful to explore.
576627
Service Workers {#security-service-worker}
577628
---------------
578629

579-
[=Service Workers=] complicate the story around allowlists, just as other same-origin contexts do.
630+
[=/Service Workers=] complicate the story around allowlists, just as other same-origin contexts do.
580631
Because they have a [=/policy container=] distinct from each of the documents they manage, it's
581632
quite possible for them to respond to messages or requests initiated in documents whose allowlist
582633
differs from the service worker's allowlist. This proposal follows other policies' design, allowing
@@ -669,3 +720,38 @@ trusted endpoints to handle redirects correctly.
669720
sites.
670721
</div>
671722

723+
WebRTC {#webrtc}
724+
------
725+
726+
By default, Connection Allowlists block all WebRTC connections. This is a conservative posture
727+
intended to mitigate the risk of data exfiltration through WebRTC's unique networking
728+
characteristics, which can be difficult to constrain via URL patterns alone.
729+
730+
The <a grammar for="Connection-Allowlist">`webrtc`</a> parameter allows developers to control
731+
this behavior.
732+
733+
If set to <a grammar for="Connection Allowlist/webrtc">`block`</a> (the default), any attempt to
734+
establish a WebRTC connection will be blocked.
735+
736+
If set to <a grammar for="Connection Allowlist/webrtc">`allow`</a>, WebRTC connections will be
737+
allowed.
738+
739+
<div class="example" id="example-webrtc">
740+
Consider a document with the following header:
741+
742+
```http
743+
Connection-Allowlist: ("https://api.example")
744+
```
745+
746+
Any attempt to establish a WebRTC connection will be **blocked**, as WebRTC is blocked by default.
747+
748+
If the header is instead:
749+
750+
```http
751+
Connection-Allowlist: ("https://api.example"); webrtc=allow
752+
```
753+
754+
WebRTC connections will be **allowed**.
755+
</div>
756+
757+

0 commit comments

Comments
 (0)