Complex Security Policy? A Longitudinal Analysis of Deployed Content Security Policies
Network and Distributed System Security Symposium (NDSS '20)
Sebastian Roth, Timothy Barron, Stefano Calzavara, Nick Nikiforakis & Ben Stock
Complex Security Policy? A Longitudinal Analysis of Deployed - - PowerPoint PPT Presentation
Complex Security Policy? A Longitudinal Analysis of Deployed Content Security Policies Sebastian Roth , Timothy Barron, Stefano Calzavara, Nick Nikiforakis & Ben Stock Network and Distributed System Security Symposium (NDSS '20) Cross-Site
Network and Distributed System Security Symposium (NDSS '20)
Sebastian Roth, Timothy Barron, Stefano Calzavara, Nick Nikiforakis & Ben Stock
2 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Cross-Site Scripting (XSS)
2 . H T T P G E T R e q u e s t v u l n . c
3 . H T T P R e s p
s e
https://vuln.com?pl=<script src=evil.com>
3 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Content Security Policy (CSP)
2 . H T T P G E T R e q u e s t v u l n . c
3 . H T T P R e s p
s e w i t h C S P H e a d e r
https://vuln.com?pl=<script src=evil.com>
4 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Content Security Policy (CSP)
script-src https://ad.com https://company.com 'unsafe-inline'
<html> <body> <!-- ad.com includes company.com --> <script src="https://ad.com/someads.js"> </script> <script> // ... meaningful inline script </script> </body> </html>
script-src https://company.com 'nonce-d90e0153c074f6c3fcf53' script-src 'nonce-d90e0153c074f6c3fcf53' 'strict-dynamic'
<html> <body> <script nonce="d90e0153c074f6c3fcf53"> let script = document.createElement("script"); script.src = "http://ad.com/ad.js"; document.body.appendChild(script); </script> </body> </html> <html> <body> <!-- ad.com includes company.com --> <script nonce="d90e0153c074f6c3fcf53" src="https://ad.com/someads.js"> </script> <script nonce="d90e0153c074f6c3fcf53"> // ... meaningful inline script </script> </body> </html>
'12 '14 '16
– CSP adoption is far behind expectations – Many deployed policies are insecure Ø Why is CSPs adoption so low? Ø For what purpose is CSP used in the wild? Ø What are the problems of deploying a CSP?
Research Questions
5 NDSS 2020 – Sebastian Roth – Complex Security Policy?
6 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Methodology
Dataset Construction Data Collection Analytics
10k sites over time. Intersection of the Alexa Top sites of each month 2012 – 2018
and their Use-Cases
& Developer opinions
Data against Common Crawl
200 400 600 800 1000 2014 2015 2016 2017 2018 CSP Adoption Script Content Control
Use-Case 1: Script Content Control
7 NDSS 2020 – Sebastian Roth – Complex Security Policy?
150 300 450 2014 2015 2016 2017 2018 Script Content Control 'unsafe-inline' http: || https: || *
Use-Case 1: Script Content Control
8 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Used ‘unsafe- inline‘ in CSP Has inline event-handlers 378 180 (48%)
Airbnb’s journey to secure their CSP
12-2017
01-2018
03-2018
11-2014
03-2015
05-2015
Script Content Control – Example
9 NDSS 2020 – Sebastian Roth – Complex Security Policy?
They needed 3 ½ years to deploy a non-trivially bypassable CSP
200 400 600 800 1000 2014 2015 2016 2017 2018 CSP Adoption Script Content Control TLS Enforement
Use-Case 2: TLS Enforcement
10 NDSS 2020 – Sebastian Roth – Complex Security Policy?
100 200 300 400 500 2016 2017 2018 TLS Enforcement Upgrade Insecure Requests Block All Mixed Content Whitelist HTTPS schema
Use-Case 2: TLS Enforcement
11 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Use-Case 2: TLS Enforcement
12 NDSS 2020 – Sebastian Roth – Complex Security Policy?
sites from the Archive and extracted the 3rd party URLs
– Mixed Content on 4,785 sites from the Alexa Top 10k – For 89% of them, all HTTP resources are upgradeable
Yes!
Wanna see more Kittens?
13 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Framing based attacks
https://kittenpics.org/
Framing Control – X-Frame-Options
14 NDSS 2020 – Sebastian Roth – Complex Security Policy?
X-Headers are not standardized! Leads to security problems:
... as well as functionality problems
200 400 600 800 1000 2014 2015 2016 2017 2018 CSP Adoption Script Content Control TLS Enforement Framing Control
Use-Case 3: Framing Control
15 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Use-Case 3: Framing Control
16 NDSS 2020 – Sebastian Roth – Complex Security Policy?
How does CSP frame-ancestors fix these problems:
CSP frame-ancestors is a well-defined standard in CSP since 2014. Thus, all “modern” browsers support it.
Applies to all of a frame's ancestors not only the top-most frame.
frame-ancestors supports wildcards and multiple source-expressions
frame-ancestors www.foo.com ‘self’ *.partner.com
500 1000 1500 2000 2500 3000 3500 2012 2013 2014 2015 2016 2017 2018 X-Frame-Options CSP frame-ancestors Both
Use-Case 3: Framing Control
17 NDSS 2020 – Sebastian Roth – Complex Security Policy? XFO Deprecated
Framing Control – Developer Study
18 NDSS 2020 – Sebastian Roth – Complex Security Policy?
CSP frame-ancestors via email.
cannot be used in isolation!
Developer Study
19 NDSS 2020 – Sebastian Roth – Complex Security Policy?
[...] adding CSP [...] already placed on the roadmap in August of last year. We ran into some trouble with properly enabling the policies, as they ended up effectively killing the website.
CSP destroys Web applications
Developer Study
20 NDSS 2020 – Sebastian Roth – Complex Security Policy?
CSP is a complex beast [...]. Some of our partner are iframing
header, that we did not want to deal with CSP.
Misconceptions about CSP
10 20 30 40 Yes No I don't know No answer
Do you believe CSP is a viable
resilience against XSS attacks?
Framing Control – Developer Study
21 NDSS 2020 – Sebastian Roth – Complex Security Policy?
10 20 30 40 Yes No I don't know No answer
Would your site work out of the box if you deployed a script-content restricting CSP today (disallow eval, inline scripts, and event handlers)?
Complex Security Policy?
22 NDSS 2020 – Sebastian Roth – Complex Security Policy?
23 NDSS 2020 – Sebastian Roth – Complex Security Policy?
How to go back in time?
Also stores original HTTP headers prefixed with X-Archive-Orig-
Appendix – Developer Study
24 NDSS 2020 – Sebastian Roth – Complex Security Policy?
We have a small team. Do we want to update our version of python or do we want to add CSP? Do we want to move to the new LTS version of Ubuntu or CSP? […] CSP always loose.
Building a CSP requires massive effort
Appendix – Developer Study
25 NDSS 2020 – Sebastian Roth – Complex Security Policy?
[…] many first and third party integrations […] having a generic CSP policy that adds value and which is suitable for our entire estate is something that is very difficult to achieve.
CSP is too complex to deploy
10 20 30 Yes No No answer
Did you know about the frame- ancestors directive and its improved protection capabilities compared to X-Frame-Options before our notification?
Developer Study
26 NDSS 2020 – Sebastian Roth – Complex Security Policy?
5 10 15 Yes No No answer
Did you know that frame-ancestors can be deployed independently of any other part of CSP before our notification?
5 10 15 20 25 Pentest / Consultant Tools we use Own decision Other
Why have you implemented the X-Frame-Options header?
Appendix – Developer Study
27 NDSS 2020 – Sebastian Roth – Complex Security Policy?
GitHub’s journey to secure their CSP
11-2013
05-2014
10-2014
Appendix – Good CSP Deployment
28 NDSS 2020 – Sebastian Roth – Complex Security Policy?
They never ever used any dangerous source expression!
=> ALLOW-FROM fails insecurely for Chrome & Co. *
Appendix – Partial support
29 NDSS 2020 – Sebastian Roth – Complex Security Policy? * Meanwhile, since Firefox 70, ALLOW-FROM is no longer supported.
Appendix – Double Framing
30 NDSS 2020 – Sebastian Roth – Complex Security Policy?
https://using-same-origin.com https://attacker.com https://using-same-origin.com
X-Frame-Options: SAMEORIGIN
=> In legacy browsers XFO is only checked against top-most frame.
31 NDSS 2020 – Sebastian Roth – Complex Security Policy?
Appendix – Related Work
USENIX ‘17 CCS ‘16 TWEB ‘18