-
Notifications
You must be signed in to change notification settings - Fork 83
Inline event handlers not whitelisted by hashes? #13
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
From @hillbrad on September 8, 2015 17:39 I would suggest that the Chrome-specific console text here is a bit Part of the difficulty here is that as a <script> block, one <script> is Maybe nonces are better for this use case, if we do need it? And I'm not sure we do need it. On the application deployer side, where On Tue, Sep 8, 2015 at 8:54 AM Paweł Krawczyk [email protected]
|
|
From @kravietz on September 8, 2015 18:41 Thanks, these are very helpful notes. I have already filed a Chrome bug report about this message, but wanted to confirm here what should be the correct browser's policy. As for inline event handlers I do see quite a lot of them, especially if you include a Google AdSense code. While perhaps the correct approach should be to rewrite AdSense code not to use inline handlers, right now it is a real problem if you want to enable CSP on real world websites. |
From @hillbrad on September 8, 2015 18:49 Do those event handlers have to be inline? Is there a reason the necessary On Tue, Sep 8, 2015 at 11:41 AM Paweł Krawczyk [email protected]
|
From @kravietz on September 8, 2015 18:52 I'm sure they don't have to but in case of embedding a third party code such as Google AdSense you don't have much influence on how it's written. A workaround I came up with is to load AdSense code in a IFRAME from an URL that has a separate, more liberal CSP. |
From @kravietz on September 10, 2015 5:46 As for identifying context for whitelisting inline handlers I think it would be quite easy thing to do. For example for such handler:
This might be whitelisted with the following hash expression:
|
FWIW, this was a very specific choice we made in the design because there are quite a few corner cases around inline handlers. Of course, I can't recall any of them right now :-) |
Based on some feedback from folks implementing CSP, it would make things much easier to deploy if we allowed hashes to whitelist inline handlers. The risk boils down to an attacker taking a whitelisted action, and moving it to another element or handler. Honestly, that seems low-risk enough to not worry too much about the syntactical strangeness that |
Also, Firefox is apparently already doing this for style (and script?) according to https://code.google.com/p/chromium/issues/detail?id=546106. @dveditz, WDYT? |
👎 I think there is a very real security risk here. A developer attempting to whitelist an inline script/style for a particular use may not be aware that it could be abused to apply malicious behaviour/styling to another element. And even if they were aware of this, it would be difficult to evaluate all the ways that this behaviour/styling could be used maliciously on every other element on the page. |
@michaelficarra: Would you be less sad if the developer had to opt-into this behavior with something like |
@mikewest Yes. Or something longer 😉. |
"Do those event handlers have to be inline? Is there a reason the necessary elements can't be tagged by id or class and the event handlers added imperatively by a script block?" – I have stumbled across this issue because I wish to use The best thing I can come up with is Anyway, just saying this might be useful for that scenario, unless there's also a way I can add my CSP nonce to the |
I have sent an e-mail on public-webappsec but in case someone follows this thread more closely, I will also leave a comment here. I have put together an explainer for this and I would like to hear your thoughts. https://docs.google.com/document/d/1_nYS4gWYO2Oh8rYDyPglXIKNsgCRVhmjHqWlTAHst7c/edit?usp=sharing |
It's my understanding that without |
Another example of a library with inline event handler: https://git.shibboleth.net/view/?p=java-opensaml2.git;a=blob;f=src/main/resources/templates/saml2-post-binding.vm;h=b2f175013a1d0e953724ff1fe667a1eea6a19ed5;hb=HEAD#l15 |
This source expression allows hashes to match both event handlers and inline style attributes. Closes w3c/webappsec-csp#13. Closes w3c/webappsec-csp#40.
From @kravietz on September 8, 2015 15:54
Reading through section 7.15 of the latest CSP2 editor's draft it seems like you can't whitelist an inline event handler with its SHA256 hash. Is this intended exclusion?
Just to provide a bit of background, the following script will only result in one pop-up, from the whitelisted
alert
in the<script>
tag:The inline handler
alert
will not be shown and Chrome will display the following error message:Which on the other hand suggests that a hash could be used to whitelist it (but this may be just a Chrome catch-all message).
Copied from original issue: w3c/webappsec#468
The text was updated successfully, but these errors were encountered: