51
WHEN THE CDN GOES BANANAS SUBRESOURCE INTEGRITY

When the CDN goes bananas

Embed Size (px)

Citation preview

Page 1: When the CDN goes bananas

WHEN THE CDN GOES BANANASSUBRESOURCE INTEGRITY

Page 2: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

me_irl

• Gabor Szathmari • Information Security

Professional Hacker Freelancer

• Privacy Advocate

Page 3: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

I WILL BE TALKING ABOUT• JavaScript hosted by third-parties

• Some scary bits

• The Solution: Subresource Integrity

‣ What it does

‣ Tooling

Page 4: When the CDN goes bananas

THIRD-PARTY CODE ON MODERN WEBSITES

Page 5: When the CDN goes bananas

ANALYTICS

Page 6: When the CDN goes bananas

A/B TESTING

Page 7: When the CDN goes bananas

HEATMAPS

Page 8: When the CDN goes bananas

TAG MANAGERS

Page 9: When the CDN goes bananas

PRIVATE CDN

Page 10: When the CDN goes bananas

PUBLIC CDN

Page 11: When the CDN goes bananas
Page 12: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

MODERN WEBSITES• Third-party JavaScript

(heatmaps, user tracking, analytics …)

• Public CDNs (jsDelivr, ajax.googleapis.com, ajax.aspnetcdn.com …)

• Private CDNs (S3, Akamai, CloudFront, Fastly …)

Page 13: When the CDN goes bananas

“YOU KNOW WHAT THEY SAY: LOVE* IS BLIND”

* <script src=“”>

Page 14: When the CDN goes bananas
Page 15: When the CDN goes bananas
Page 16: When the CDN goes bananas

WHAT CAN GO WRONG?

Page 17: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

MODERN WEBSITES• Third-party JavaScript

(heatmaps, user tracking, analytics …)

• Public CDNs (jsDelivr, ajax.googleapis.com, ajax.aspnetcdn.com …)

• Private CDNs (S3, Akamai, CloudFront, Fastly …)

HACKED

Page 18: When the CDN goes bananas

window.location.href="https://www.reddit.com/r/badmemes"

Page 19: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

🙀 🙀 🙀• https://www.maxcdn.com/blog/bootstrapcdn-security-post-mortem/

• https://blog.pagefair.com/2015/halloween-security-breach/

• https://citizenlab.org/2015/04/chinas-great-cannon/

• http://securityaffairs.co/wordpress/31480/cyber-crime/afghanistan-cdn-network-hacked.html

• https://medium.com/@FredericJacobs/the-reuters-compromise-by-the-syrian-electronic-army-6bf570e1a85b

Page 20: When the CDN goes bananas

REUTERS.COM SEA.SY

Page 21: When the CDN goes bananas

HTTP://CDN.TABOOLA.COM/LIBTRC/REUTERS-NETWORK/LOADER.JS

Page 22: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

WHAT IS THE DAMAGE?• Unwanted redirection

• Website defacement

• Click fraud

• Exploit kits (ransomware)

• Cookie stealing, session hijacking

• Keylogging

• UI redressing (password stealing, OTP stealing)

Page 23: When the CDN goes bananas
Page 24: When the CDN goes bananas

WHAT CAN WE DO?

Page 25: When the CDN goes bananas

SUBRESOURCE INTEGRITY AKA. SRI

Page 26: When the CDN goes bananas

PROTECTS JAVASCRIPTINTEGRITY

Page 27: When the CDN goes bananas

PROTECTS CSS INTEGRITY

Page 28: When the CDN goes bananas

<scriptsrc="https://cdn.jsdelivr.net/jquery/2.1.4/jquery.min.js"integrity="sha256-ImQv...="crossorigin="anonymous"></script>

Page 29: When the CDN goes bananas

"TRUST, BUT VERIFY”

Page 30: When the CDN goes bananas

“Я НЕМНОГО ЧАЙНИКА”

Page 31: When the CDN goes bananas

<SCRIPT SRC=“HTTPS://MAXCDN.BOOTSTRAPCDN.COM/..

./BOOTSTRAP.MIN.JS” INTEGRITY=“SHA512-I3A1A…”

Page 32: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

BROWSER SUPPORT

Page 33: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

Page 34: When the CDN goes bananas

TOOLING

Page 35: When the CDN goes bananas

MANUAL HASHING

Page 36: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

OPENSSL• openssl dgst -sha256 -binary jquery.min.js | openssl base64 -A

• openssl dgst -sha384 -binary jquery.min.js | openssl base64 -A

• openssl dgst -sha512 -binary jquery.min.js | openssl base64 -A

Page 37: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

OPENSSL• $ curl -s https://code.jquery.com/jquery-2.2.3.min.js | openssl dgst -sha512 -binary | openssl base64 -A SFaNb3xC08k/Wf6CRM1J+O/vv4YWyrPBSdy0o+1nqKzf+uLrIBnaeo8aYoAAOd31nMNHwX8zwVwTMbbCJjA8Kg==

• <script src=“https://code.jquery.com/jquery-2.2.3.min.js” integrity=“sha512-SFaNb3xC08k/Wf…” […]

Page 38: When the CDN goes bananas

HOSTED TOOLS

Page 39: When the CDN goes bananas

SRIHASH.ORG

REPORT-URI.IO

JSDELIVR.COM

Page 40: When the CDN goes bananas

CMS

Page 41: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

PLUGINS• WordPress

https://wordpress.org/plugins/wp-sri/ • Drupal

https://www.drupal.org/project/advagg

Page 42: When the CDN goes bananas

WORKFLOW INTEGRATION

Page 43: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

WORKFLOW INTEGRATION

Page 44: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

WORKFLOW INTEGRATION

Page 45: When the CDN goes bananas

SCAN YOUR WEBSITE FOR SRI USAGE

Page 46: When the CDN goes bananas

SRITEST.IO

Page 47: When the CDN goes bananas

SRITEST.IO

Page 48: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

TOOLING• Manual • Hosted • CMS Plugins • Workflow Integration • sritest.io

Page 49: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

SUMMARY• Modern websites rely on JS/CSS • Hosted on CDNs / at third-parties • SRI protects from unexpected JS/CSS

changes • Tooling is available

Page 50: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

FURTHER READING• https://www.owasp.org/index.php/

3rd_Party_Javascript_Management_Cheat_Sheet • http://j.mp/cdn-goes-bananas • http://j.mp/new-sri2-features

‣ Enforce SRI with CSP

‣ Violation Reporting

Page 51: When the CDN goes bananas

WHEN THE CDN GOES BANANAS

THANK YOU• @gszathmari • PGP: keybase.io/gszathmari