I have a page where I set the content security script -src as follows:
script-src 'self' *.uservoice.com *.intuit.com ajax.googleapis.com localhost:*
When I load the page with a hard-coded inline script, I created myself for testing, it blocks, as expected:
An inline script was denied because it violates the following Content Security Policy: "script -src 'self' * .uservoice.com * .intuit.com ajax.googleapis.com localhost: *". Either the unsafe-built-in keyword, a hash ('sha256 -...'), or nonce ('nonce -...') is required to enable inline execution.
However, when I insert a new script tag dynamically, the script is not blocked, for example, it is still running:
$("body").append("<script>alert('xss');</script>")
I use Chrome as a browser for testing. I was hoping this script would also be blocked, as this would really help prevent xss. Is there something I can change to block this type of script injection?
javascript google-chrome xss content-security-policy
user3152280
source share