I've implemented a content security policy on a page by setting the script-src directive as follows:
script-src 'self' *.uservoice.com *.intuit.com ajax.googleapis.com localhost:*
Upon testing with a hard-coded inline script, it was correctly blocked due to CSP restrictions:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' *.uservoice.com *.intuit.com ajax.googleapis.com localhost:* ". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
Surprisingly, when I dynamically insert a new script tag like this, it still executes without being blocked:
$("body").append("<script>alert('xss');</script>")
My testing browser is Chrome. It raises concerns for me that this type of script injection isn't being prevented. Is there anything I can adjust in my settings to block these scripts as well?