A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mikewest/signature-based-sri below:

WICG/signature-based-sri: Signature-based Resource Loading Restrictions

Explainer: Signature-based Integrity

TL;DR: It would be nice if web developers could verify the provenance of resources they depend upon, establishing the technical foundations upon which they can increase confidence in the integrity of their dependencies. We offer brittle, content-based integrity mechanisms today which can (in theory) but do not (in practice) enable this capability. This proposal explores an alternative.

Users rely on web developers to build sites and applications that enable everything from simple information sharing to rich interactive experiences. Web developers often do so by composing multiple subcomponents from a number of sources, building upon others' work and services. This is a fantastic model in general, but it requires a level of trust in all of the dependencies that a given site might grow to require, and certainty that only those trusted components are allowed to execute in a given site's context. It would be unfortunate indeed if an attacker could sneak their code into a high-value site, creating harmful consequences for developers and users both.

The web platform offers developers a few tools which provide more-or-less fine-grained control over script execution in order to impose technical boundaries that can prevent some forms of attack:

These existing mechanisms are effective, but they also turn out to be somewhat onerous for both development and deployment. Policies that restrict sources of content need to be quite granular in order to meaningfully mitigate attacks, which makes robust policies difficult to deploy at scale (see "CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security Policy for more on this point). Hash-based solutions, on the other hand, are brittle, requiring both pages and their dependencies to update in lockstep to avoid breakage. This is possible in some deployments, but ~impossible in others where HTTP responses might be quite dynamic.

It would be ideal if we had more options.

We've discussed mixing signatures into SRI on and off for quite some time. Signatures are different in kind than hashes, providing the ability to make assertions about a resource's provenance, but not its content. This kind of guarantee can similarly remove the necessity to trust intermediaries, and provides developers with a useful addition to URL-based and content-based restrictions.

This proposal introduces signature-based integrity checks by first asking servers to begin signing resources using a narrow profile of HTTP Message Signatures (RFC9421) that's verifiable by user agents. Developers who depend on those servers' resources can then begin requiring that the user agent accept only those resources signed by a given key.

For example: a developer might wish to load https://amazing.example/widget.js in order to make use of that component's functionality. Happily, https://amazing.example/ is run by security-minded folks who have integrated signing into their build process, so the server might respond with the following headers:

HTTP/1.1 200 OK
Accept-Ranges: none
Vary: Accept-Encoding
Content-Type: text/javascript; charset=UTF-8
Access-Control-Allow-Origin: *
Identity-Digest: sha-512=:[base64-encoded digest of `console.log("Hello, world!");`]:
Signature-Input: sig1=("identity-digest";sf); alg="Ed25519"; keyid="[base64-encoded public key]"; tag="sri"
Signature: sig1=:[base64-encoded result of Ed25519([response metadata], [private key])]:

console.log("Hello, world!");

Three headers are particularly interesting here: Identity-Digest, Signature-Input, and Signature. Let's look at each:

Users' agents will download https://amazing.example/widget.js, and perform two checks before handing it back to the page for possible execution:

  1. The signature components specified in Signature-Input are reconstructed on the client into a form standardized in RFC9421, and the signature specified in the Signature header is verified over that reconstruction. If the signature doesn't validate, the resource is rejected.

  2. The digest specified in the Integrity-Digest header is verified to match a digest calculated over the decoded response body. If the digests don't match, the resource is rejected.

The resource is then handed back to the page for execution with the guarantee that all the signatures on a resource are internally consistent. Developers can then choose to execute the resource iff it can be verified using a specific public key, restricting themselves only to resources with this proof of provenance:

<script src="https://amazing.example/widget.js"
        crossorigin="anonymous"
        integrity="ed25519-[base64-encoded public key]"></script>

That's it. This seems like the simplest possible approach, and has some interesting properties:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4