Skip to content

Commit 8077176

Browse files
Fixing link to "scope" and copying changes to v1. (#1413)
1 parent c1f3619 commit 8077176

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

docs/index.bs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
21282128

21292129
*This section is non-normative.*
21302130

2131-
In addition to the [[#origin-restriction|origin restriction]], service workers are restricted by the [=url/path=] of the service worker script. For example, a service worker script at <code>https://www.example.com/~bob/sw.js</code> can be registered for the [=scope=] <code>https://www.example.com/~bob/</code> but not for the scope <code>https://www.example.com/</code> or <code>https://www.example.com/~alice/</code>. This provides some protection for sites that host multiple-user content in separated directories on the same origin. However, the path restriction is not considered a hard security boundary, as only origins are. Sites are encouraged to use different origins to securely isolate segments of the site if appropriate.
2131+
In addition to the [[#origin-restriction|origin restriction]], service workers are restricted by the [=url/path=] of the service worker script. For example, a service worker script at <code>https://www.example.com/~bob/sw.js</code> can be registered for the [=service worker registration/scope url=] <code>https://www.example.com/~bob/</code> but not for the scope <code>https://www.example.com/</code> or <code>https://www.example.com/~alice/</code>. This provides some protection for sites that host multiple-user content in separated directories on the same origin. However, the path restriction is not considered a hard security boundary, as only origins are. Sites are encouraged to use different origins to securely isolate segments of the site if appropriate.
21322132

21332133
Servers can remove the path restriction by setting a [=Service-Worker-Allowed=] header on the service worker script.
21342134
</section>

docs/v1/index.bs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,26 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
20042004
[=/Service workers=] enable this by allowing {{Cache|Caches}} to [=/fetch=] and cache off-origin items. Some restrictions apply, however. First, unlike same-origin resources which are managed in the {{Cache}} as {{Response}} objects whose corresponding [=Response/responses=] are <a>basic filtered response</a>, the objects stored are {{Response}} objects whose corresponding [=Response/responses=] are either <a>CORS filtered responses</a> or <a>opaque filtered responses</a>. They can be passed to {{FetchEvent/respondWith(r)|event.respondWith(r)}} method in the same manner as the {{Response}} objects whose corresponding [=Response/responses=] are <a>basic filtered responses</a>, but cannot be meaningfully created programmatically. These limitations are necessary to preserve the security invariants of the platform. Allowing {{Cache|Caches}} to store them allows applications to avoid re-architecting in most cases.
20052005
</section>
20062006

2007+
<section>
2008+
<h3 id="path-restriction">Path restriction</h3>
2009+
2010+
*This section is non-normative.*
2011+
2012+
In addition to the [[#origin-restriction|origin restriction]], service workers are restricted by the [=url/path=] of the service worker script. For example, a service worker script at <code>https://www.example.com/~bob/sw.js</code> can be registered for the [=service worker registration/scope url=] <code>https://www.example.com/~bob/</code> but not for the scope <code>https://www.example.com/</code> or <code>https://www.example.com/~alice/</code>. This provides some protection for sites that host multiple-user content in separated directories on the same origin. However, the path restriction is not considered a hard security boundary, as only origins are. Sites are encouraged to use different origins to securely isolate segments of the site if appropriate.
2013+
2014+
Servers can remove the path restriction by setting a [=Service-Worker-Allowed=] header on the service worker script.
2015+
</section>
2016+
2017+
<section>
2018+
<h3 id="script-request">Service worker script request</h3>
2019+
2020+
*This section is non-normative.*
2021+
2022+
To further defend against malicious registration of a service worker on a site, this specification requires that:
2023+
* The [=Service-Worker=] header is present on service worker script requests, and
2024+
* Service worker scripts are served with a [=JavaScript MIME type=].
2025+
</section>
2026+
20072027
<section>
20082028
<h3 id="implementer-concerns">Implementer Concerns</h3>
20092029

@@ -2305,7 +2325,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
23052325
1. Asynchronously complete these steps with a [=network error=].
23062326
1. Let |serviceWorkerAllowed| be the result of [=extracting header list values=] given \`<code>Service-Worker-Allowed</code>\` and |response|'s [=response/header list=].
23072327

2308-
Note: See the definition of the Service-Worker-Allowed header in Appendix B: Extended HTTP headers.
2328+
Note: See the definition of the [=Service-Worker-Allowed=] header in Appendix B: Extended HTTP headers.
23092329

23102330
1. Set |httpsState| to |response|'s [=response/HTTPS state=].
23112331
1. Set |referrerPolicy| to the result of <a>parse a referrer policy from a <code>Referrer-Policy</code> header</a> of |response|.
@@ -2317,10 +2337,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
23172337
1. Set |maxScopeString| to "<code>/</code>" concatenated with the strings, except the last string that denotes the script's file name, in |job|'s [=job/script url=]'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
23182338
1. Else:
23192339
1. Let |maxScope| be the result of <a lt="URL parser">parsing</a> |serviceWorkerAllowed| with |job|'s [=job/script url=].
2320-
1. Set |maxScopeString| to "<code>/</code>" concatenated with the strings in |maxScope|'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
2340+
1. If |maxScope|'s [=url/origin=] is |job|'s [=job/script url=]'s [=url/origin=], then:
2341+
1. Set |maxScopeString| to "<code>/</code>" concatenated with the strings in |maxScope|'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
23212342
1. Let |scopeString| be "<code>/</code>" concatenated with the strings in |scopeURL|'s [=url/path=] (including empty strings), separated from each other by "<code>/</code>".
2322-
1. If |scopeString| starts with |maxScopeString|, do nothing.
2323-
1. Else:
2343+
1. If |maxScopeString| is null or |scopeString| does not start with |maxScopeString|, then:
23242344
1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}.
23252345
1. Asynchronously complete these steps with a <a>network error</a>.
23262346
1. Set |updatedResourceMap|[|request|'s [=request/url=]] to |response|.

0 commit comments

Comments
 (0)