Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Facilitate Subresource Integrity #2

Open
Brunty opened this issue May 29, 2018 · 8 comments
Open

Facilitate Subresource Integrity #2

Brunty opened this issue May 29, 2018 · 8 comments

Comments

@Brunty
Copy link

Brunty commented May 29, 2018

To allow SRI reliably, it'd be nice to have access to versioned scripts (and CORS headers) if we're to implement this in a way that helps reduce the risk of XSS on sites that are relying on the CDN.

Steps:

Add a version to the CDN URL:

Currently it's:

<script src="https://cdn.passprotect.io/passprotect.min.js"></script>

A URL such as https://cdn.passprotect.io/1.0.0/passprotect.min.js would then allow us to rely on a specific version (which means that SRI won't break when changes are made)

Add CORS header:

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Set the header on the resource to:

Access-Control-Allow-Origin: *

Add SRI to the docs:

There may be a way of automating this into the docs when changes are made, the command to generate an integrity hash is:

openssl dgst -sha256 -binary file.js | openssl base64 -A

The docs can then show the integrity hash to use like so:

<script src="https://cdn.passprotect.io/1.0.0/passprotect.min.js" integrity="sha256-x4T57/ClC7dEno+EBaTKYKIhHjXDl39zoxv2u8QxQ88=" crossorigin="anonymous"></script>

More info in great blog posts from Scott Helme https://scotthelme.co.uk/subresource-integrity/ https://scotthelme.co.uk/tag/sri/

@MatthewHerbst
Copy link

Small nit: Mozilla is now pushing sha384 instead as their recommended default since apparently the NSA no longer recommends sha256: mozilla/srihash.org@ea93c4c

@Brunty
Copy link
Author

Brunty commented May 29, 2018

@MatthewHerbst good call 👍

@rdegges
Copy link
Contributor

rdegges commented May 30, 2018

Will go ahead and implement this =) I'll try to get it done this week.

This has been part of the plan all along, was sorta rushing to get this out ASAP for timing, but excited to get some new stuff in here =)

@pbulteel
Copy link

Has this been implemented yet? If so, the documentation needs to be updated.

@rdegges
Copy link
Contributor

rdegges commented Jun 29, 2018

Not yet -- I'm working on it today, actually. I've been sorta tied down finishing a work deadline and am just getting back to making upgrades to PassProtect now and through the next 2 weeks =)

@rleeden
Copy link

rleeden commented Sep 11, 2018

Hi, any update on this? Would be nice to implement this.

@miketabor
Copy link

Having SRI added would be a big win.

@ohbobva
Copy link

ohbobva commented Jan 17, 2019

Agreed. Looking forward to it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants