w3c / ServiceWorker

Service Workers
https://w3c.github.io/ServiceWorker/
Other
3.63k stars 314 forks source link

Allow `None` as value for `Service-Worker-Allowed`. #1165

Open surma opened 7 years ago

surma commented 7 years ago

In a multi-tenant system, where untrusted users have control over subdirectories, it would be nice to disable ServiceWorkers completely for paths outside the “user’s jail”.

Here’s an example:

/
|
+- /users
   |
   +- /userA
   +- /userB
   +- ...
+- /data
+- ...

A simple oversight like a missing trailing slash (/users/userA instead of /users/userA/) could allow installing a ServiceWorker outside the user’s jail.

Currently, you can kinda disable ServiceWorker by setting a non-sensical value for the Service-Worker-Allowed header, but I’d prefer a more semantic None (or similar).

jakearchibald commented 6 years ago

The problem here is that None is a valid path.

All service worker script fetches have a Service-Worker: script header, so servers can return an invalid response in return.