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

Support subresource integrity for service workers #1680

Open
hlandau opened this issue May 18, 2023 · 2 comments
Open

Support subresource integrity for service workers #1680

hlandau opened this issue May 18, 2023 · 2 comments

Comments

@hlandau
Copy link

hlandau commented May 18, 2023

I think it would be valuable to support SRI for service worker JS files.

Reasoning: There's a lot of controversy about web-based crypto applications. Namely, that they're never truly secure because they can be compromised by changing the code shipped to the client implementing the crypto, and there's a lack of visibility for client-side code updates on the web.

If a service worker could be constrained to have a specific hash, that service worker could, in turn, implement a site-specific content verification policy. It could, for example, chainload another service worker file after verifying a cryptographic signature, so it wouldn't prevent frequent updates. Applications would be free to define policies around those updates that quell any concerns about the visibility of future updates to a codebase. As an arbitrary example, signatures from multiple unrelated parties could be required. Having verified a service worker implementing such a trust policy, the use of such a service worker would be verified simply via its hash. Thus adding SRI for service workers has the potential to create a programmable root of trust for an entire website. In particular, service workers are designed to have great longevity as things a browser remembers.

I could envisage someone developing an addon that ships a preloaded list of service worker SRI pins for popular origins providing cryptographic applications. People could update their list of pins based on what they're willing to trust, which would make code updates more visible for high-security web applications.

These aren't the only use cases; if you don't find them compelling, there are others. Because a service worker has extremely powerful control over an origin, and is remembered for long periods, a compromised service worker file is potentially one of the most disastrous things that could happen to a site. I'd therefore argue that extending SRI to service workers would in general be quite valuable.

Proposed API: Add an integrity field to the options object passed to ServiceWorkerContainer.register().

Originally proposed in the SRI repo but moving it here as this appears to be the correct repository for discussion. This is also related to #822 but proposes a different, and arguably much simpler solution for a related set of use cases.

@JamesTheAwesomeDude
Copy link

JamesTheAwesomeDude commented Oct 4, 2023

Because a service worker has extremely powerful control over an origin, and is remembered for long periods, a compromised service worker file is potentially one of the most disastrous things that could happen to a site.

It's for that very reason that SW pinning via a mechanism like SRI seems like it would only enable such an attack to persist after I've got my website back—anything which protects a web app against takeover by its future owner also necessarily "protects" a web app against re-takeover by its rightful owner after a compromise.

After all, what's the *technical* difference between these?

  • A site administrator (E2EE webmail operator) who wants his site to robustly continue serious function (confidential and integritous cryptographic processing) for many hours in the face of adversarial (government) takeover
  • A "site administrator" (black-hat adversary) who wants "his" (my) site to robustly continue "serious function" (displaying seriously offensive imagery) for many hours in the face of "adversarial" (legitimate) takeover

I could envisage someone developing an addon that ships a preloaded list of service worker SRI pins for popular origins providing cryptographic applications.

If you're proposing we use WebExtensions as failsafe-canaries/breakers/SPoF-custodians for high-stakes web applications, aren't there ways to achieve that under the ecosystem as it currently exists, without implementing any new browser functionality proposals? (e.g. auditing ServiceWorker installations before they occur)

@alvarolm
Copy link

alvarolm commented Jul 12, 2024

I share the same concerns.

I hadn't thought about web extensions, but sadly they seem to be supported on Firefox only, and might be deprecated at any time as it doesn't count with much support.

#1720

Within the same line it also worries me the fact that pin sets for certificate pinning are safeguarded by the browsers vendors, we are losing control, as developers and web users it's all pretty sad, I'm starting to lose faith in the w3c and other organizations pushing web standards

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

No branches or pull requests

3 participants