-
Notifications
You must be signed in to change notification settings - Fork 2
URL hash is hashing the wrong thing #8
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
Comments
Sorry for the confusion, One of the uses cases for url hashes is to generate a working CSP from the html of the page itself, without knowing where the page will deploy. Our main goal is to make the deployment of a reasonably secure CSP easier, so supporting relative URLs in this manner will allow that. The current idea to get the relative URL is not to use it from page source, but to extract it from the <document URL, resource URL> pair. Assuming both URLs are well formed and normalized, the algorithm to do this is fairly straightforward:
This returns This should avoid layering violations since it's not using the attribute directly from the HTML. Would something like this work? |
I don't think so. There are endless variations you can spell these kind of paths. E.g., |
I think any path will need to be normalized with something like Remove Dot Segments algorithm (https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4) before being hashed. Both the browser and the CSP generator tool will need to do this. I previously looked into HTTP archive data to see if normalization could be achieved easily. I don't have the exact numbers right now, but there were fewer than 100 resources from the top 1000 URLs that couldn't be normalized this way. |
'sha256-SHA256("script.js")'
is one of the examples. Presumably this function call is to be replaced by the actual hash? This isn't clear from the explainer.Either way, the input cannot be
script.js
as that is the input to the URL parser and that won't be there when Fetch calls into CSP. Requiring that to survive would be a layering violation and a very objectionable one at that.The text was updated successfully, but these errors were encountered: