Content Security Policy Header
What does it protect against?
- This header protects the user against XSS Attacks where malicious users try to call their own scripts from somewhere else on the internet in your site
What it does
- This header forces you to list all of the sources for content that you will use on your site that are outside of your domain
Notes
default-src
: if we don't allow it explicitly somewhere else don't load the source
script-src
: a list of domains or exact url of scripts that are allowed on your site
object-src
: valid source for <object>
, <embed>
, and <applet>
style-src
: valid source for styles
img-src
: valid source for images
media-src
: valid source for video/audio
frame-src
: valid source for frames
font-src
: valid source for fonts
script-nonce
: Definition
report-uri
: The CSP will create a report for all blocked content and other helpful information and send it to the uri specified. The only issue with this iss the information will be public so attackers can see it
Examples
Content-Security-Policy: default-src 'self'; block-all-mixed-content;
- This blocks everything and is only to be used on static sites