Yeah.
Looks like the script-nonce
was removed from the spec, instead script-src 'nonce-ABCD4321';
is supposed to be the new syntax. From what I can tell, the new syntax isn't supported in Chrome 32 but is supported by Chrome 33 Beta.
See http://jsbin.com/iyukAwA/3 for example test page.
EDIT1: It looks like Blink patch https://chromium.googlesource.com/chromium/blink/+/adbf3bb0338931076b7c7bd002b043def760cc61
removes script-nonce
support and adds script-src 'nonce-xxx';
support.
EDIT3: Latest spec.
EDIT2: I absolutely require inline script and css because my web app has in-page code to detect if included script or css source files fail to load (e.g. due to unreliable mobile connection). In Chrome, creating the meta element dynamically works:
<script>
var meta = document.createElement('meta');
meta.httpEquiv = 'Content-Security-Policy';
meta.content = "default-src 'none'; connect-src 'self'; img-src 'self'; style-src 'self';";
document.getElementsByTagName('head')[0].appendChild(meta);
</script>
</head>
From Content Security Policy 1.1 - W3C Working Draft 04 June 2013 :
Example 4: A website that relies on inline script elements wishes to ensure that script is only executed from its own origin, and those elements it intentionally inserted inline:
Content-Security-Policy: script-src 'self' 'nonce-$RANDOM';
The inline script elements would then only execute if they contained a matching nonce attribute:
<script nonce="$RANDOM">...</script>
EDIT5: http://jsbin.com/ArusOCu/1 has example of document.onsecuritypolicyviolation(event) logging. e.g.
document.onsecuritypolicyviolation = function (evt) {
console.log('Bzzp! Security violation on', evt.documentURI);
}
EDIT5 - MORE: Chrome 33 Beta generated the following event details:
blockedURI: ""
columnNumber: 0
currentTarget: document
documentURI: "http://jsbin.com/ArusOCu/1"
effectiveDirective: "script-src"
lineNumber: 0
originalPolicy: "default-src 'none'; script-src http://static.jsbin.com 'unsafe-eval' 'nonce-12345678'; connect-src 'self'; style-src http: 'unsafe-inline';"
referrer: ""
sourceFile: ""
statusCode: 200
target: document
timeStamp: 1390192192606
type: "securitypolicyviolation"
violatedDirective: "script-src http://static.jsbin.com 'unsafe-eval' 'nonce-12345678'"
__proto__: SecurityPolicyViolationEvent
[removed base Event parameters]
and the docs say that the following properties are required:
readonly attribute DOMString documentURI;
readonly attribute DOMString referrer;
readonly attribute DOMString blockedURI;
readonly attribute DOMString violatedDirective;
readonly attribute DOMString effectiveDirective;
readonly attribute DOMString originalPolicy;
readonly attribute DOMString sourceFile;
readonly attribute long lineNumber;
readonly attribute long columnNumber;