← Back to context

Comment by easyThrowaway

11 days ago

A certificate-based approach for scripts residing on different domains, for example, so you can be sure it hasn't been tampered with.

A javascript file served from example-a.com should be able to run on example-b.org only if it has been signed with the same TLS key used for example-a.com .

CSP allows you to configure your loaded JS with a complementary hash check. If you're the one who puts the script on your page, in theory, it should be safe for as long as remains the same.

How would that actually look in reality?

  • Same approach as a domain cert - scripts served through CORS should sport their own public signature specific to the origin domain to be checked against by the browser before the execution. If the file has been tampered it should be immediately apparent.