Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Rename digest to integrity as digest is wrong #5

Closed
annevk opened this issue Nov 21, 2024 · 6 comments
Closed

Rename digest to integrity as digest is wrong #5

annevk opened this issue Nov 21, 2024 · 6 comments

Comments

@annevk
Copy link

annevk commented Nov 21, 2024

That's the publicly used name in Fetch and HTML. I think we should stay consistent with that.

(But also, it seems you want to include more than just the digest (and the examples do). The cryptographic hash function is not part of the digest.)

@annevk
Copy link
Author

annevk commented Nov 21, 2024

I think by essentially reporting the integrity metadata it will also be forward-compatible with Signature-Based-SRI.

@yoavweiss
Copy link
Owner

In the CSP PR the replaces this, I initially went with "hash". I can switch that to "integrity" if you feel that's better.

I'd also appreciate your thoughts on that PR in terms of the format of the "hash"/"integrity". Currently it's just the "sha-256" output of applying algorithm to bytes, without an indication of the algorithm used.

@annevk
Copy link
Author

annevk commented Nov 26, 2024

Maybe I misunderstood. Say the HTML says this and baz, foo, and bar are valid hashes:

<script src=... integrity="unsupported-baz sha512-foo sha256-bar">

What string do we report?

@yoavweiss
Copy link
Owner

The current algorithm effectively calculates the the hash of the script contents using "sha-256" and reports that.

So in your example, assuming that the asset actually loads (and passes the integrity checks), we'd report "sha256-bar" (according to the current algorithm).
The same is also true if the same script contents had no "integrity" attribute.

@annevk
Copy link
Author

annevk commented Nov 26, 2024

I misunderstood what this is doing. I thought this was exclusively for SRI failures.

@yoavweiss
Copy link
Owner

Closing as this is no longer relevant. Thanks!

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

2 participants