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

integrity="sha...-..." for unpkg URL would be nice #261

Closed
guettli opened this issue Dec 11, 2020 · 4 comments
Closed

integrity="sha...-..." for unpkg URL would be nice #261

guettli opened this issue Dec 11, 2020 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@guettli
Copy link
Sponsor Contributor

guettli commented Dec 11, 2020

Hi,

I don't know if this does a lot of trouble in your release process, but wouldn't it be more secure to add a hash value to the URL you show in the docs?

For example bootstrap uses this:

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" 
    integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" 
    crossorigin="anonymous"></script>

I don't know if crossorigin="anonymous" makes sense.

Background: if the unpkg server got hacked, they could inject evil code into my application (but I guess you know this).

@1cg
Copy link
Contributor

1cg commented Dec 12, 2020

good idea

Is there an easy way to get the sha code?

@guettli
Copy link
Sponsor Contributor Author

guettli commented Dec 15, 2020

There is this online service:

https://www.srihash.org/

<script src="https://unpkg.com/htmx.org@1.0.2" integrity="sha384-uG2fggOnt72f9yU5g6r04wPKVnlrpuTRachw1fB6euaHlWgObEcF9zSrDBuBMZ9H" crossorigin="anonymous"></script>

Of course, this is some work to update it for every release, maybe there is a way to automate this.

@bencroker bencroker added enhancement New feature or request documentation Improvements or additions to documentation and removed enhancement New feature or request labels Jan 4, 2021
@bencroker
Copy link
Sponsor Collaborator

Great suggestion @guettli!! I think using https://www.srihash.org/ when each new version is released is reasonable.

Using crossorigin="anonymous" is required, as it tells the browser to fetch the script without sending user-credentials.

Subresource Integrity is not supported by IE11, but my guess is that IE will simply ignore it, which is fine.

Associated docs:
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin

@bencroker
Copy link
Sponsor Collaborator

Added in 2499401.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants