-
Notifications
You must be signed in to change notification settings - Fork 5
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
How to decode potential JavaScript #7
Comments
Looking at this again and in particular https://html.spec.whatwg.org/#fetch-a-classic-script I think the simplest option here is that we pass the encoding along with the request and then we need to abstract or duplicate these steps (and maybe improve them while we're at it, especially getting the
And then if script's record is null parsing failed. @domenic does that seem right to you? |
I don't have the full context on what security guarantees we're trying to preserve here (is it bad to leak information about the |
Basically every usage of "Content-Type metadata" in HTML could be improved by using the new MIME type getter, I think. |
One risk here is that the attacker has control over the encoding, so this technically gives them more opportunity to find a way to get something parsed as JavaScript. In practice it still seems hard to parse as JavaScript as the majority of significant bytes are in the ASCII range. |
I included a fix for this in whatwg/fetch#1442 which I think works. The HTML side will need to set it on requests, but that's a very straightforward change. And while it is unfortunate that the fallback encoding is in the hands of the attacker, this is no different from the status quo. |
I forgot that the response itself also carries encoding-related information. whatwg/fetch#1447 tackles the first part of that. Once that lands it should be easy to call from Fetch's ORB PR. |
We might not always have an encoding, e.g.,
fetch(..., { mode: "no-cors" })
. Is it reasonable to always use UTF-8 for this check?The text was updated successfully, but these errors were encountered: