'unsafe-inline'
A CSP keyword that allows all inline scripts or styles, which removes most of the protection CSP offers against XSS.
It lets any injected inline script run, defeating the main purpose of the policy.
In more detail
Use nonces or hashes instead. Browsers ignore 'unsafe-inline' when a nonce or hash is also present, which keeps older browsers working.
Related terms
- Content Security Policy — An HTTP response header that tells the browser which sources of scripts and other content a page may load, limiting what injected markup can do.
- nonce — A value meant to be used only once, such as a unique number given to a cipher or a random token that marks trusted scripts in a web page.
- 'unsafe-eval' — A CSP keyword that allows code to be built from strings at runtime with eval() and similar functions.
Taught in
- Content Security Policy (CSP), Trusted Types And XSS Defenses — Frontend Architecture & Web Platform