New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 638957 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Buried. Ping if important.
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

Chromium blocks 'unsafe-inline' event handler upon execution, not upon setting

Reported by ap...@pokeinthe.io, Aug 18 2016

Issue description

Chrome Version       : 52.0.2743.116 (64-bit)
OS Version: OS X 10.11
URLs (if applicable) : http://output.jsbin.com/togusapobi / http://output.jsbin.com/wutojesugi
Other browsers tested:
  Add OK or FAIL after other browsers where you have tested this issue:
       Safari: FAIL
   Firefox 48: OK
     IE 7/8/9: N/A
         Edge: OK

What steps will reproduce the problem?
1. Set Content-Security-Policy to block 'unsafe-inline'
2. Add an event handler to an attribute via setAttribute('onclick') or via onclick attribute added to DOM node

What is the expected result?

In Firefox and Edge, this code will be successfully blocked on being set:

document.querySelector('button').setAttribute('onclick', 'alert(1)')

As will this inline event handler:

<button onclick="alert(1);">yay</button>

What happens instead of that?

WebKit-based browsers block it upon execution, in violation of the CSP specification:

>  When an event handler content attribute is set, execute the following steps:
>  
>    If the Should element's inline behavior be blocked by Content Security Policy? algorithm returns "Blocked" when executed upon the attribute's element, "script attribute", and the attribute's value, then abort these steps. [CSP]
 

Comment 1 by mkwst@chromium.org, Aug 18 2016

Components: Blink>SecurityFeature
Labels: OS-Android OS-Chrome OS-Linux OS-Windows
Owner: mkwst@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 3 by est...@chromium.org, Nov 10 2017

Labels: Hotlist-EnamelAndFriendsFixIt

Comment 4 by est...@chromium.org, Feb 18 2018

Labels: -Hotlist-EnamelAndFriendsFixIt

Sign in to add a comment