Content Security Policy
Content Security Policy
What is it?
• Directives define the rules the browser must follow for various types
of resources.
• The main ones we will most often work with are:
• default-src, script-src, style-src, img-src, font-src
• But there’s plenty more…
• base-uri, frame-src, object-src, media-src, connect-src, form-action,
frame-ancestors, child-src, plugin-types, upgrade-insecure-requests,
worker-src, sandbox
What are source lists?
• Source lists are sets of strings which identify content that can be fetched and
potentially embedded or executed. For example, you may load styles from
your site, and fonts from Google.
• Sources can follow various formats:
• example.com – Allows resources from the specified domain name.
• *.example.com – Allows resources from any subdomain under
example.com.
• https://cdn.com – Only resources over HTTPS matching the given domain.
• https: – Allows loading resources only over HTTPS on any domain.
• data: – Allows resources via the data scheme (eg Base64 encoded images).
What is ‘self’ all about?