SlideShare a Scribd company logo
1 of 40
Download to read offline
Content-Security-Policy
Browser Serving Your Web Application Security
Part 2
About me
HI I’M PHILIPPE
I’m a Senior Application
Security Analyst at Lightspeed.
Long-time internet developer,
author, screen caster, podcaster
and speaker. I’m specializes in
PHP, Symfony, Kuzzle, security,
code quality, performance, real
time and geolocation.
Sécurité PHP 5 et MySQL 5
OWASP Montreal
PHP Quebec
Table Top Game Developer
Pen & Paper RPG Writer
Purpose of the presentation
Improve the code of your website
Protect your site against certain attacks
Protect your users from certain attacks
This is part 2 of Browser Serving Your Web Application Security
What is it?
Added layer of security that helps to detect and mitigate certain types of attacks,
including Cross Site Scripting (XSS) and data injection attacks.
Available as :
HTTP Header

Meta Element

3 level of specification
Specification 1.0 Recommendation
http://w3c.org/TR/CSP1
Specification 2.0 Recommendation
http://w3c.org/TR/CSP2
Specification 3.0 Working Draft
http://w3c.org/TR/CSP3
Compatibility
Android Chrome Edge Firefox Internet Explorer Opera Safari
Recommendation 1 4.4+ 25+ 12+ 23+ 11+ 7+
Recommendation 2 53+ 40+ 15+ 31+ (partial) 27+ 10+
Working Draft 3 59+ 59+ 58+ 48+
Server Side Examples
#apache
<IfModule mod_headers.c>
Header set Content-Security-Policy "default-src 'self';" # alway set header
Header setifempty Content-Security-Policy "default-src 'self';" # set header if empty
</IfModule>
#nginx
map $upstream_http_content_security_policy $csp {
'' default-src 'self';
}
server {
location / {
add_header Content-Security-Policy $csp;
}
}
Server Side Examples
#iis
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Content-Security-Policy" value="default-src 'self';" />
</customHeaders>
</httpProtocol>
</system.webServer>
PHP Code Example
<?php
header(“Content-Security-Policy: default-src ‘self’;”, true);
HTML Example
<meta http-equiv="Content-Security-Policy" content="default-src https:">
Logic Structure
Content-Security-Policy: <policy-directive>; <policy-directive>;...


policy-directive:
[<fetch-directive> <fetch-value>[ <fetch-value>]|
<document-directive> <document-value>[ <document-value>]|
<navigation-directive> [<navigation-value>[ <navigation-value>]]|
<report-directive> <report-value>]
Fetch Directives
Content-Security-Policy: <policy-directive>; <policy-directive>;...


policy-directive:
[<fetch-directive> <fetch-value>[ <fetch-value>]|
<document-directive> <document-value>[ <document-value>]|
<navigation-directive> [<navigation-value>[ <navigation-value>]]|
<report-directive> <report-value>]
Fetch Directives
Directives CSP 1 CSP 2 CSP 3 Comments
default-src ✓ ✓ ✓ Default Policy. Override by more specific directives.
child-src ✗ ✓ ✓ Do not use; use frame-src and worker-src instead.
connect-src ✓ ✓ ✓ Restrict URL loaded in scripts (AJAX, WebSocket,
EvenSource)
font-src ✓ ✓ ✓ @font-face
frame-src ✓ ✗ ✓ <frame> and <iframe>
img-src ✓ ✓ ✓ Favicons; <img>; url() and image() in CSS
manifest-src ✗ ✗ ✓ Application manifest
Fetch Directives
Directives CSP 1 CSP 2 CSP 3 Comments
default-src ✓ ✓ ✓  
media-src ✓ ✓ ✓ <audio>, <video>, <track>
object-src ✓ ✓ ✓ <object>, <embed> or <applet>
script-src ✓ ✓ ✓ Javascript and XSLT
style-src ✓ ✓ ✓ CSS files
worker-src ✗ ✗ ✓
Fetch Directives Values
Content-Security-Policy: <policy-directive>; <policy-directive>;...


policy-directive:
[<fetch-directive> <fetch-value>[ <fetch-value>]|
<document-directive> <document-value>[ <document-value>]|
<navigation-directive> [<navigation-value>[ <navigation-value>]]|
<report-directive> <report-value>]
Fetch Directives Values
Values CSP 1 CSP 2 CSP 3 Comments
* ✓ ✓ ✓ Any URL except “data:”, “blob:” or “filesystem:” schemes
'self' ✓ ✓ ✓ Same origin (same scheme, host and port)
'none' ✓ ✓ ✓ Prevents loading resources from any source
uri ✓ ✓ ✓ media.example.com, *.cdn.example.com
'unsafe-inline' ✓ ✓ ✓ default-src, script-src and style-src
'unsafe-eval' ✓ ✓ ✓ default-src and script-src
Examples
default-src 'self';
script-src 'self';
script-src 'self' www.google-analytics.com ajax.googleapis.com;
default-src 'none'; script-src 'self'; connect-src 'self'; img-
src 'self'; style-src 'self';
default-src 'self'; img-src *; object-src media1.example.com
media2.example.com *.cdn.example.com; script-src
trustedscripts.example.com
default-src 'unsafe-inline' 'unsafe-eval'
Fetch Directives Values
Schemes CSP 1 CSP 2 CSP 3 Comments
https: ✓ ✓ ✓
http: ✓ ✓ ✓ Should not be used anymore. All sites should be HTTPS.
data: ✓ ✓ ✓ Insecure. Do not used if possible.
mediastream: ✗ ✓ ✓ Media Capture and Streams API
blob: ✗ ✓ ✓ Represents a file-like object of immutable, raw data.
filesystem: ✗ ✓ ✓ Not Standard API FileSystem
Examples
default-src https: 'unsafe-inline' 'unsafe-eval'
default-src *; script-src https://example.com/js/;”
default-src 'self'; img-src *; media-src toto.local http://
tata.local; script-src scripts.local
Fetch Directives Values
Values CSP 1 CSP 2 CSP 3 Comments
'nonce-<base64-value>'
✗ ✓ ✓ Nonce must be generate on each connection
<hash-source>
✗ ✓ ✓ sha256, sha384 or sha512 hash. Like SRI.
'strict-dynamic' ✗ ✓ ✓
Examples
script-src 'sha256-qznLcsROx4GACP2dm0UCKCzCG-HiZ1guq6ZZDob_Tng='
script-src 'nonce-EDNnf03nceIOfn39fn3e9h3sdfa'
<script nonce=EDNnf03nceIOfn39fn3e9h3sdfa>
//Some inline code I cant remove yet, but need to asap.
</script>
Document Directives
Content-Security-Policy: <policy-directive>; <policy-directive>;...


policy-directive:
[<fetch-directive> <fetch-value>[ <fetch-value>]|
<document-directive> <document-value>[ <document-value>]|
<navigation-directive> [<navigation-value>[ <navigation-value>]]|
<report-directive> <report-value>]
Document Directives
Directive CSP 1 CSP 2 CSP 3 Comments
base-uri ✗ ✓ ✓ <base>
disown-opener ✗ ✗ ✓
plugin-types ✗ ✓ ✓ <object>, <embed> and <applet>
sandbox ✓ ✓ ✓ <iframe>
block-all-mixed-content ✗ ✗ ✓ Don’t use with upgrade-insecure-requests
require-sri-for ✗ ✗ ✓
upgrade-insecure-requests ✗ ✗ ✓ Don’t use with block-all-mixed-content
Examples
base-uri 'self'; object-src 'none'
plugin-types application/x-shockwave-flash;
plugin-types application/x-java-applet;
default-src 'self'; require-sri-for script style
block-all-mixed-content
upgrade-insecure-requests; default-src https:
Navigation Directives
Content-Security-Policy: <policy-directive>; <policy-directive>;...


policy-directive:
[<fetch-directive> <fetch-value>[ <fetch-value>]|
<document-directive> <document-value>[ <document-value>]|
<navigation-directive> [<navigation-value>[ <navigation-value>]]|
<report-directive> <report-value>]
Navigation Directives
Directives CSP 1 CSP 2 CSP 3 Comments
form-action ✗ ✓ ✓ <form> action
frame-ancestors ✗ ✓ ✓ <frame> <iframe> <object> <embed> <applet>
Examples
default-src 'self'; frame-ancestors 'none'
form-action 'none'
default-src https://cdn.example.net; child-src 'none'; object-src
'none'
default-src 'self'; frame-ancestors 'self'
frame-ancestors my-trusty-site.com
Sandbox Value
Content-Security-Policy: <policy-directive>; <policy-directive>;...


policy-directive:
[<fetch-directive> <fetch-value>[ <fetch-value>]|
<document-directive> <document-value>[ <document-value>]|
<navigation-directive> [<navigation-value>[ <navigation-value>]]|
<report-directive> <report-value>]
document-directive: [sandbox|...]
Sandbox Values
Values CSP 1 CSP 2 CSP 3 Comments
allow-forms ✓ ✓ ✓ Allows to submit forms.
allow-modals ✓ ✓ ✓ Allows to open modal windows.
allow-orientation-lock ✓ ✓ ✓
Allows to disable the ability to lock the
screen orientation.
allow-pointer-lock ✓ ✓ ✓ Allows to use the Pointer Lock API.
allow-popups ✓ ✓ ✓ Allows popups.
allow-popups-to-escape-sandbox ✗ ✗ ✓
Allows a sandboxed document to open
new windows without forcing the
sandboxing flags upon them.
Sandbox Values
Values CSP 1 CSP 2 CSP 3 Comments
allow-presentation ✓ ✓ ✓
Allows to have control over whether
an iframe can start a presentation
session.
allow-same-origin ✓ ✓ ✓
Allows to be treated as being from its
normal origin.
allow-scripts ✓ ✓ ✓ Allows to run scripts.
allow-top-navigation ✓ ✓ ✓ Allows to navigate.
Examples
default-src *; sandbox allow-scripts
sandbox allow-forms allow-same-origin
default-src https:; connect-src https:; font-src https: data:;
frame-src https:; img-src https: data:; media-src https:;
object-src https:; script-src 'unsafe-inline' 'unsafe-eval'
https:; style-src 'unsafe-inline' https:;
Report Directives
Content-Security-Policy: <policy-directive>; <policy-directive>;...


policy-directive:
[<fetch-directive> <fetch-value>[ <fetch-value>]|
<document-directive> <document-value>[ <document-value>]|
<navigation-directive> [<navigation-value>[ <navigation-value>]]|
<report-directive> <report-value>]
Report Directives
Directives CSP 1 CSP 2 CSP 3 Comments
report-uri ✓ ✓ ✓ Deprecated. But replacement not supported yet.
report-to ✗ ✗ ✓
Replace report-uri, but not supported. If a browser
support report-to, it will be used instead of report-uri.
Meta/Header
• Content-Security-Policy-Report-Only
https://report-uri.com/
Examples
Content-Security-Policy "default-src 'self'; report-uri http://
example.org/csp-report.php"
http://evil.example.com/image.png
Response
{
"csp-report": {
"document-uri": "http://example.org/page.html",
"referrer": "http://evil.example.com/haxor.html",
"blocked-uri": "http://evil.example.com/image.png",
"violated-directive": "default-src 'self'",
"original-policy": "default-src 'self'; report-uri http://
example.org/csp-report.cgi"
}
}
EXAMPLE
Report-To: { "group": "csp-endpoint",
"max-age": 10886400,
"endpoints": [
{ "url": "https://example.com/csp-reports" }
]
},
{ "group": "hpkp-endpoint",
"max-age": 10886400,
"endpoints": [
{ "url": "https://example.com/hpkp-reports" }
]
}
Content-Security-Policy: ...; report-to csp-endpoint
Subresource Integrity
About SRI
Protect Imported Files Integrities
Verify extracted files are delivered without unexpected manipulation.
Uses a cryptographic hash.
<script>, <link>
Base64 of
Sha256
Sha384
sha512
Examples
<script src="https://example.com/example-framework.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/
uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
crossorigin="anonymous"></script>
<link rel="stylesheet” href="https://site53.example.net/style.css"
integrity="sha384-+/M6kredJcxdsqkczBUjMLvqyHb1K/
JThDXWsBVxMEeZHEaMKEOEct339VItX1zB"
crossorigin="anonymous">
cat example-framework.js | openssl dgst -sha384 -binary | openssl enc -base64 -A
THANK YOU
This presentation was created using Keynote. The
iconography is provided by Keynote and Font Awesome.
Unless otherwise noted, all photographs are used by
permission under a Creative Commons license. Please refer
to the Photo Credits slide for more information.
Content-Security-Policy - Browser Serving Your Web
Application Security Part 2
Copyright © 2018 Philippe Gamache
This work is licensed under Creative Commons Attribution-
ShareAlike 4.0 International. For uses not covered under this
license, please contact the author.
If you want to talk more, feel free to contact me.
pres.csp@ph-il.ca
@philoupedia
philippegamache
Philippe Gamache

More Related Content

What's hot

Securing your AngularJS Application
Securing your AngularJS ApplicationSecuring your AngularJS Application
Securing your AngularJS ApplicationPhilippe De Ryck
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesSpin Lai
 
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...Matt Raible
 
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 201910 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019Matt Raible
 
Cryptography with Zend Framework
Cryptography with Zend FrameworkCryptography with Zend Framework
Cryptography with Zend FrameworkEnrico Zimuel
 
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudJavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudArun Gupta
 
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac DawsonCODE BLUE
 
New Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit CreationNew Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit CreationKen Belva
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020Matt Raible
 
Quality of Life, Multiple Lines of Defense
Quality of Life, Multiple Lines of DefenseQuality of Life, Multiple Lines of Defense
Quality of Life, Multiple Lines of DefenseMichal Špaček
 
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)nyccamp
 
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLUlf Wendel
 
Video.js - How to build and HTML5 Video Player
Video.js - How to build and HTML5 Video PlayerVideo.js - How to build and HTML5 Video Player
Video.js - How to build and HTML5 Video Playersteveheffernan
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionNeat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionMikhail Egorov
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesMikhail Egorov
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onMatt Raible
 
Web security: Securing Untrusted Web Content in Browsers
Web security: Securing Untrusted Web Content in BrowsersWeb security: Securing Untrusted Web Content in Browsers
Web security: Securing Untrusted Web Content in BrowsersPhú Phùng
 
Html5 localstorage attack vectors
Html5 localstorage attack vectorsHtml5 localstorage attack vectors
Html5 localstorage attack vectorsShreeraj Shah
 

What's hot (20)

Securing your AngularJS Application
Securing your AngularJS ApplicationSecuring your AngularJS Application
Securing your AngularJS Application
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best Practices
 
Secure java script-for-developers
Secure java script-for-developersSecure java script-for-developers
Secure java script-for-developers
 
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
 
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 201910 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
 
Cryptography with Zend Framework
Cryptography with Zend FrameworkCryptography with Zend Framework
Cryptography with Zend Framework
 
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudJavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
 
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson
 
New Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit CreationNew Methods in Automated XSS Detection & Dynamic Exploit Creation
New Methods in Automated XSS Detection & Dynamic Exploit Creation
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
 
Quality of Life, Multiple Lines of Defense
Quality of Life, Multiple Lines of DefenseQuality of Life, Multiple Lines of Defense
Quality of Life, Multiple Lines of Defense
 
21 05-2018
21 05-201821 05-2018
21 05-2018
 
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
 
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
 
Video.js - How to build and HTML5 Video Player
Video.js - How to build and HTML5 Video PlayerVideo.js - How to build and HTML5 Video Player
Video.js - How to build and HTML5 Video Player
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionNeat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protection
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-on
 
Web security: Securing Untrusted Web Content in Browsers
Web security: Securing Untrusted Web Content in BrowsersWeb security: Securing Untrusted Web Content in Browsers
Web security: Securing Untrusted Web Content in Browsers
 
Html5 localstorage attack vectors
Html5 localstorage attack vectorsHtml5 localstorage attack vectors
Html5 localstorage attack vectors
 

Similar to Content-Security-Policy 2018.0

Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaultsMatias Korhonen
 
HTTP_Header_Security.pdf
HTTP_Header_Security.pdfHTTP_Header_Security.pdf
HTTP_Header_Security.pdfksudhakarreddy5
 
Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Francois Marier
 
Csp and http headers
Csp and http headersCsp and http headers
Csp and http headersdevObjective
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs SilverlightMatt Casto
 
Browser Wars 2019 - Implementing a Content Security Policy
Browser Wars 2019 - Implementing a Content Security PolicyBrowser Wars 2019 - Implementing a Content Security Policy
Browser Wars 2019 - Implementing a Content Security PolicyGeorge Boobyer
 
Rails and Content Security Policies
Rails and Content Security PoliciesRails and Content Security Policies
Rails and Content Security PoliciesMatias Korhonen
 
Browser Serving Your Web Application Security - Madison PHP 2017
Browser Serving Your Web Application Security - Madison PHP 2017Browser Serving Your Web Application Security - Madison PHP 2017
Browser Serving Your Web Application Security - Madison PHP 2017Philippe Gamache
 
Browser Serving Your Web Application Security - NorthEast PHP 2017
Browser Serving Your Web Application Security - NorthEast PHP 2017Browser Serving Your Web Application Security - NorthEast PHP 2017
Browser Serving Your Web Application Security - NorthEast PHP 2017Philippe Gamache
 
Whatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the processWhatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the processguest3379bd
 
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...PROIDEA
 
Flash Security, OWASP Chennai
Flash Security, OWASP ChennaiFlash Security, OWASP Chennai
Flash Security, OWASP Chennailavakumark
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTimothy Oxley
 
14. html 5 security considerations
14. html 5 security considerations14. html 5 security considerations
14. html 5 security considerationsEoin Keary
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013Bastian Grimm
 

Similar to Content-Security-Policy 2018.0 (20)

Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaults
 
HTTP_Header_Security.pdf
HTTP_Header_Security.pdfHTTP_Header_Security.pdf
HTTP_Header_Security.pdf
 
Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)Defeating Cross-Site Scripting with Content Security Policy (updated)
Defeating Cross-Site Scripting with Content Security Policy (updated)
 
Csp and http headers
Csp and http headersCsp and http headers
Csp and http headers
 
Csp and http headers
Csp and http headersCsp and http headers
Csp and http headers
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs Silverlight
 
Browser Wars 2019 - Implementing a Content Security Policy
Browser Wars 2019 - Implementing a Content Security PolicyBrowser Wars 2019 - Implementing a Content Security Policy
Browser Wars 2019 - Implementing a Content Security Policy
 
Rails and Content Security Policies
Rails and Content Security PoliciesRails and Content Security Policies
Rails and Content Security Policies
 
Browser Serving Your Web Application Security - Madison PHP 2017
Browser Serving Your Web Application Security - Madison PHP 2017Browser Serving Your Web Application Security - Madison PHP 2017
Browser Serving Your Web Application Security - Madison PHP 2017
 
Browser Serving Your Web Application Security - NorthEast PHP 2017
Browser Serving Your Web Application Security - NorthEast PHP 2017Browser Serving Your Web Application Security - NorthEast PHP 2017
Browser Serving Your Web Application Security - NorthEast PHP 2017
 
Whatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the processWhatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the process
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
 
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
 
Flash Security, OWASP Chennai
Flash Security, OWASP ChennaiFlash Security, OWASP Chennai
Flash Security, OWASP Chennai
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
14. html 5 security considerations
14. html 5 security considerations14. html 5 security considerations
14. html 5 security considerations
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
 
Attacking HTML5
Attacking HTML5Attacking HTML5
Attacking HTML5
 
The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013
 

More from Philippe Gamache

Cryptographie 101 Pour les programmeurs (PHP)
Cryptographie 101 Pour les programmeurs (PHP)Cryptographie 101 Pour les programmeurs (PHP)
Cryptographie 101 Pour les programmeurs (PHP)Philippe Gamache
 
Multi Factor Authetification - ZendCon 2017
Multi Factor Authetification - ZendCon 2017Multi Factor Authetification - ZendCon 2017
Multi Factor Authetification - ZendCon 2017Philippe Gamache
 
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017 OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017 Philippe Gamache
 
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017Philippe Gamache
 
Kaizen ou l'amélioration continue
Kaizen ou l'amélioration continueKaizen ou l'amélioration continue
Kaizen ou l'amélioration continuePhilippe Gamache
 
Entreprise Security API - OWASP Montreal
Entreprise Security API - OWASP MontrealEntreprise Security API - OWASP Montreal
Entreprise Security API - OWASP MontrealPhilippe Gamache
 
Entreprise Security API - ConFoo 2011
Entreprise Security API - ConFoo 2011Entreprise Security API - ConFoo 2011
Entreprise Security API - ConFoo 2011Philippe Gamache
 
Strong authetification - ConFoo 2011
Strong authetification - ConFoo 2011Strong authetification - ConFoo 2011
Strong authetification - ConFoo 2011Philippe Gamache
 
Une application en une heure avec symfony - Collège de Mainsonneuve
Une application en une heure avec symfony - Collège de MainsonneuveUne application en une heure avec symfony - Collège de Mainsonneuve
Une application en une heure avec symfony - Collège de MainsonneuvePhilippe Gamache
 
Laboratoire sécurité : audit de code PHP - Conférence PHP Québec 2009
Laboratoire sécurité : audit de code PHP - Conférence PHP Québec 2009Laboratoire sécurité : audit de code PHP - Conférence PHP Québec 2009
Laboratoire sécurité : audit de code PHP - Conférence PHP Québec 2009Philippe Gamache
 
One hour application - PHP Quebec Conference 2009
One hour application - PHP Quebec Conference 2009One hour application - PHP Quebec Conference 2009
One hour application - PHP Quebec Conference 2009Philippe Gamache
 
Une application en deux heure - PHP Québec Janvier 2009
Une application en deux heure - PHP Québec Janvier 2009Une application en deux heure - PHP Québec Janvier 2009
Une application en deux heure - PHP Québec Janvier 2009Philippe Gamache
 
Audit de code PHP - PHP Code Audit - HackFest.ca 2009
Audit de code PHP - PHP Code Audit - HackFest.ca 2009Audit de code PHP - PHP Code Audit - HackFest.ca 2009
Audit de code PHP - PHP Code Audit - HackFest.ca 2009Philippe Gamache
 
Auditing and securing PHP applications - FRHACK 2009
Auditing and securing PHP applications - FRHACK 2009Auditing and securing PHP applications - FRHACK 2009
Auditing and securing PHP applications - FRHACK 2009Philippe Gamache
 

More from Philippe Gamache (15)

Cryptographie 101 Pour les programmeurs (PHP)
Cryptographie 101 Pour les programmeurs (PHP)Cryptographie 101 Pour les programmeurs (PHP)
Cryptographie 101 Pour les programmeurs (PHP)
 
Mentor et votre équipe
Mentor et votre équipeMentor et votre équipe
Mentor et votre équipe
 
Multi Factor Authetification - ZendCon 2017
Multi Factor Authetification - ZendCon 2017Multi Factor Authetification - ZendCon 2017
Multi Factor Authetification - ZendCon 2017
 
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017 OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017
 
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017
OWASP Top 10 Proactive Controls 2016 - PHP Québec August 2017
 
Kaizen ou l'amélioration continue
Kaizen ou l'amélioration continueKaizen ou l'amélioration continue
Kaizen ou l'amélioration continue
 
Entreprise Security API - OWASP Montreal
Entreprise Security API - OWASP MontrealEntreprise Security API - OWASP Montreal
Entreprise Security API - OWASP Montreal
 
Entreprise Security API - ConFoo 2011
Entreprise Security API - ConFoo 2011Entreprise Security API - ConFoo 2011
Entreprise Security API - ConFoo 2011
 
Strong authetification - ConFoo 2011
Strong authetification - ConFoo 2011Strong authetification - ConFoo 2011
Strong authetification - ConFoo 2011
 
Une application en une heure avec symfony - Collège de Mainsonneuve
Une application en une heure avec symfony - Collège de MainsonneuveUne application en une heure avec symfony - Collège de Mainsonneuve
Une application en une heure avec symfony - Collège de Mainsonneuve
 
Laboratoire sécurité : audit de code PHP - Conférence PHP Québec 2009
Laboratoire sécurité : audit de code PHP - Conférence PHP Québec 2009Laboratoire sécurité : audit de code PHP - Conférence PHP Québec 2009
Laboratoire sécurité : audit de code PHP - Conférence PHP Québec 2009
 
One hour application - PHP Quebec Conference 2009
One hour application - PHP Quebec Conference 2009One hour application - PHP Quebec Conference 2009
One hour application - PHP Quebec Conference 2009
 
Une application en deux heure - PHP Québec Janvier 2009
Une application en deux heure - PHP Québec Janvier 2009Une application en deux heure - PHP Québec Janvier 2009
Une application en deux heure - PHP Québec Janvier 2009
 
Audit de code PHP - PHP Code Audit - HackFest.ca 2009
Audit de code PHP - PHP Code Audit - HackFest.ca 2009Audit de code PHP - PHP Code Audit - HackFest.ca 2009
Audit de code PHP - PHP Code Audit - HackFest.ca 2009
 
Auditing and securing PHP applications - FRHACK 2009
Auditing and securing PHP applications - FRHACK 2009Auditing and securing PHP applications - FRHACK 2009
Auditing and securing PHP applications - FRHACK 2009
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Content-Security-Policy 2018.0

  • 1. Content-Security-Policy Browser Serving Your Web Application Security Part 2
  • 2. About me HI I’M PHILIPPE I’m a Senior Application Security Analyst at Lightspeed. Long-time internet developer, author, screen caster, podcaster and speaker. I’m specializes in PHP, Symfony, Kuzzle, security, code quality, performance, real time and geolocation. Sécurité PHP 5 et MySQL 5 OWASP Montreal PHP Quebec Table Top Game Developer Pen & Paper RPG Writer
  • 3. Purpose of the presentation Improve the code of your website Protect your site against certain attacks Protect your users from certain attacks This is part 2 of Browser Serving Your Web Application Security
  • 4. What is it? Added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. Available as : HTTP Header
 Meta Element

  • 5. 3 level of specification Specification 1.0 Recommendation http://w3c.org/TR/CSP1 Specification 2.0 Recommendation http://w3c.org/TR/CSP2 Specification 3.0 Working Draft http://w3c.org/TR/CSP3
  • 6. Compatibility Android Chrome Edge Firefox Internet Explorer Opera Safari Recommendation 1 4.4+ 25+ 12+ 23+ 11+ 7+ Recommendation 2 53+ 40+ 15+ 31+ (partial) 27+ 10+ Working Draft 3 59+ 59+ 58+ 48+
  • 7. Server Side Examples #apache <IfModule mod_headers.c> Header set Content-Security-Policy "default-src 'self';" # alway set header Header setifempty Content-Security-Policy "default-src 'self';" # set header if empty </IfModule> #nginx map $upstream_http_content_security_policy $csp { '' default-src 'self'; } server { location / { add_header Content-Security-Policy $csp; } }
  • 8. Server Side Examples #iis <system.webServer> <httpProtocol> <customHeaders> <add name="Content-Security-Policy" value="default-src 'self';" /> </customHeaders> </httpProtocol> </system.webServer>
  • 11. Logic Structure Content-Security-Policy: <policy-directive>; <policy-directive>;... 
 policy-directive: [<fetch-directive> <fetch-value>[ <fetch-value>]| <document-directive> <document-value>[ <document-value>]| <navigation-directive> [<navigation-value>[ <navigation-value>]]| <report-directive> <report-value>]
  • 12. Fetch Directives Content-Security-Policy: <policy-directive>; <policy-directive>;... 
 policy-directive: [<fetch-directive> <fetch-value>[ <fetch-value>]| <document-directive> <document-value>[ <document-value>]| <navigation-directive> [<navigation-value>[ <navigation-value>]]| <report-directive> <report-value>]
  • 13. Fetch Directives Directives CSP 1 CSP 2 CSP 3 Comments default-src ✓ ✓ ✓ Default Policy. Override by more specific directives. child-src ✗ ✓ ✓ Do not use; use frame-src and worker-src instead. connect-src ✓ ✓ ✓ Restrict URL loaded in scripts (AJAX, WebSocket, EvenSource) font-src ✓ ✓ ✓ @font-face frame-src ✓ ✗ ✓ <frame> and <iframe> img-src ✓ ✓ ✓ Favicons; <img>; url() and image() in CSS manifest-src ✗ ✗ ✓ Application manifest
  • 14. Fetch Directives Directives CSP 1 CSP 2 CSP 3 Comments default-src ✓ ✓ ✓   media-src ✓ ✓ ✓ <audio>, <video>, <track> object-src ✓ ✓ ✓ <object>, <embed> or <applet> script-src ✓ ✓ ✓ Javascript and XSLT style-src ✓ ✓ ✓ CSS files worker-src ✗ ✗ ✓
  • 15. Fetch Directives Values Content-Security-Policy: <policy-directive>; <policy-directive>;... 
 policy-directive: [<fetch-directive> <fetch-value>[ <fetch-value>]| <document-directive> <document-value>[ <document-value>]| <navigation-directive> [<navigation-value>[ <navigation-value>]]| <report-directive> <report-value>]
  • 16. Fetch Directives Values Values CSP 1 CSP 2 CSP 3 Comments * ✓ ✓ ✓ Any URL except “data:”, “blob:” or “filesystem:” schemes 'self' ✓ ✓ ✓ Same origin (same scheme, host and port) 'none' ✓ ✓ ✓ Prevents loading resources from any source uri ✓ ✓ ✓ media.example.com, *.cdn.example.com 'unsafe-inline' ✓ ✓ ✓ default-src, script-src and style-src 'unsafe-eval' ✓ ✓ ✓ default-src and script-src
  • 17. Examples default-src 'self'; script-src 'self'; script-src 'self' www.google-analytics.com ajax.googleapis.com; default-src 'none'; script-src 'self'; connect-src 'self'; img- src 'self'; style-src 'self'; default-src 'self'; img-src *; object-src media1.example.com media2.example.com *.cdn.example.com; script-src trustedscripts.example.com default-src 'unsafe-inline' 'unsafe-eval'
  • 18. Fetch Directives Values Schemes CSP 1 CSP 2 CSP 3 Comments https: ✓ ✓ ✓ http: ✓ ✓ ✓ Should not be used anymore. All sites should be HTTPS. data: ✓ ✓ ✓ Insecure. Do not used if possible. mediastream: ✗ ✓ ✓ Media Capture and Streams API blob: ✗ ✓ ✓ Represents a file-like object of immutable, raw data. filesystem: ✗ ✓ ✓ Not Standard API FileSystem
  • 19. Examples default-src https: 'unsafe-inline' 'unsafe-eval' default-src *; script-src https://example.com/js/;” default-src 'self'; img-src *; media-src toto.local http:// tata.local; script-src scripts.local
  • 20. Fetch Directives Values Values CSP 1 CSP 2 CSP 3 Comments 'nonce-<base64-value>' ✗ ✓ ✓ Nonce must be generate on each connection <hash-source> ✗ ✓ ✓ sha256, sha384 or sha512 hash. Like SRI. 'strict-dynamic' ✗ ✓ ✓
  • 21. Examples script-src 'sha256-qznLcsROx4GACP2dm0UCKCzCG-HiZ1guq6ZZDob_Tng=' script-src 'nonce-EDNnf03nceIOfn39fn3e9h3sdfa' <script nonce=EDNnf03nceIOfn39fn3e9h3sdfa> //Some inline code I cant remove yet, but need to asap. </script>
  • 22. Document Directives Content-Security-Policy: <policy-directive>; <policy-directive>;... 
 policy-directive: [<fetch-directive> <fetch-value>[ <fetch-value>]| <document-directive> <document-value>[ <document-value>]| <navigation-directive> [<navigation-value>[ <navigation-value>]]| <report-directive> <report-value>]
  • 23. Document Directives Directive CSP 1 CSP 2 CSP 3 Comments base-uri ✗ ✓ ✓ <base> disown-opener ✗ ✗ ✓ plugin-types ✗ ✓ ✓ <object>, <embed> and <applet> sandbox ✓ ✓ ✓ <iframe> block-all-mixed-content ✗ ✗ ✓ Don’t use with upgrade-insecure-requests require-sri-for ✗ ✗ ✓ upgrade-insecure-requests ✗ ✗ ✓ Don’t use with block-all-mixed-content
  • 24. Examples base-uri 'self'; object-src 'none' plugin-types application/x-shockwave-flash; plugin-types application/x-java-applet; default-src 'self'; require-sri-for script style block-all-mixed-content upgrade-insecure-requests; default-src https:
  • 25. Navigation Directives Content-Security-Policy: <policy-directive>; <policy-directive>;... 
 policy-directive: [<fetch-directive> <fetch-value>[ <fetch-value>]| <document-directive> <document-value>[ <document-value>]| <navigation-directive> [<navigation-value>[ <navigation-value>]]| <report-directive> <report-value>]
  • 26. Navigation Directives Directives CSP 1 CSP 2 CSP 3 Comments form-action ✗ ✓ ✓ <form> action frame-ancestors ✗ ✓ ✓ <frame> <iframe> <object> <embed> <applet>
  • 27. Examples default-src 'self'; frame-ancestors 'none' form-action 'none' default-src https://cdn.example.net; child-src 'none'; object-src 'none' default-src 'self'; frame-ancestors 'self' frame-ancestors my-trusty-site.com
  • 28. Sandbox Value Content-Security-Policy: <policy-directive>; <policy-directive>;... 
 policy-directive: [<fetch-directive> <fetch-value>[ <fetch-value>]| <document-directive> <document-value>[ <document-value>]| <navigation-directive> [<navigation-value>[ <navigation-value>]]| <report-directive> <report-value>] document-directive: [sandbox|...]
  • 29. Sandbox Values Values CSP 1 CSP 2 CSP 3 Comments allow-forms ✓ ✓ ✓ Allows to submit forms. allow-modals ✓ ✓ ✓ Allows to open modal windows. allow-orientation-lock ✓ ✓ ✓ Allows to disable the ability to lock the screen orientation. allow-pointer-lock ✓ ✓ ✓ Allows to use the Pointer Lock API. allow-popups ✓ ✓ ✓ Allows popups. allow-popups-to-escape-sandbox ✗ ✗ ✓ Allows a sandboxed document to open new windows without forcing the sandboxing flags upon them.
  • 30. Sandbox Values Values CSP 1 CSP 2 CSP 3 Comments allow-presentation ✓ ✓ ✓ Allows to have control over whether an iframe can start a presentation session. allow-same-origin ✓ ✓ ✓ Allows to be treated as being from its normal origin. allow-scripts ✓ ✓ ✓ Allows to run scripts. allow-top-navigation ✓ ✓ ✓ Allows to navigate.
  • 31. Examples default-src *; sandbox allow-scripts sandbox allow-forms allow-same-origin default-src https:; connect-src https:; font-src https: data:; frame-src https:; img-src https: data:; media-src https:; object-src https:; script-src 'unsafe-inline' 'unsafe-eval' https:; style-src 'unsafe-inline' https:;
  • 32. Report Directives Content-Security-Policy: <policy-directive>; <policy-directive>;... 
 policy-directive: [<fetch-directive> <fetch-value>[ <fetch-value>]| <document-directive> <document-value>[ <document-value>]| <navigation-directive> [<navigation-value>[ <navigation-value>]]| <report-directive> <report-value>]
  • 33. Report Directives Directives CSP 1 CSP 2 CSP 3 Comments report-uri ✓ ✓ ✓ Deprecated. But replacement not supported yet. report-to ✗ ✗ ✓ Replace report-uri, but not supported. If a browser support report-to, it will be used instead of report-uri. Meta/Header • Content-Security-Policy-Report-Only https://report-uri.com/
  • 34. Examples Content-Security-Policy "default-src 'self'; report-uri http:// example.org/csp-report.php" http://evil.example.com/image.png
  • 35. Response { "csp-report": { "document-uri": "http://example.org/page.html", "referrer": "http://evil.example.com/haxor.html", "blocked-uri": "http://evil.example.com/image.png", "violated-directive": "default-src 'self'", "original-policy": "default-src 'self'; report-uri http:// example.org/csp-report.cgi" } }
  • 36. EXAMPLE Report-To: { "group": "csp-endpoint", "max-age": 10886400, "endpoints": [ { "url": "https://example.com/csp-reports" } ] }, { "group": "hpkp-endpoint", "max-age": 10886400, "endpoints": [ { "url": "https://example.com/hpkp-reports" } ] } Content-Security-Policy: ...; report-to csp-endpoint
  • 38. About SRI Protect Imported Files Integrities Verify extracted files are delivered without unexpected manipulation. Uses a cryptographic hash. <script>, <link> Base64 of Sha256 Sha384 sha512
  • 39. Examples <script src="https://example.com/example-framework.js" integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/ uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" crossorigin="anonymous"></script> <link rel="stylesheet” href="https://site53.example.net/style.css" integrity="sha384-+/M6kredJcxdsqkczBUjMLvqyHb1K/ JThDXWsBVxMEeZHEaMKEOEct339VItX1zB" crossorigin="anonymous"> cat example-framework.js | openssl dgst -sha384 -binary | openssl enc -base64 -A
  • 40. THANK YOU This presentation was created using Keynote. The iconography is provided by Keynote and Font Awesome. Unless otherwise noted, all photographs are used by permission under a Creative Commons license. Please refer to the Photo Credits slide for more information. Content-Security-Policy - Browser Serving Your Web Application Security Part 2 Copyright © 2018 Philippe Gamache This work is licensed under Creative Commons Attribution- ShareAlike 4.0 International. For uses not covered under this license, please contact the author. If you want to talk more, feel free to contact me. pres.csp@ph-il.ca @philoupedia philippegamache Philippe Gamache