114
François Marier @fmarier Getting Browsers to Improve the Security of Your Webapp

Getting Browsers to Improve the Security of Your Webapp

Embed Size (px)

Citation preview

Page 1: Getting Browsers to Improve the Security of Your Webapp

François Marier @fmarier

Getting Browsers to Improvethe Security of Your Webapp

Page 2: Getting Browsers to Improve the Security of Your Webapp

externalresources

usercontent

cookies encryption

Page 3: Getting Browsers to Improve the Security of Your Webapp

externalresources

Page 4: Getting Browsers to Improve the Security of Your Webapp

Subresource integrity

mechanism for preventingtampering of static assets

Page 5: Getting Browsers to Improve the Security of Your Webapp
Page 6: Getting Browsers to Improve the Security of Your Webapp
Page 7: Getting Browsers to Improve the Security of Your Webapp

https://ajax.googleapis.com/ajax

/libs/jquery/1.9.1/jquery.min.js

Page 8: Getting Browsers to Improve the Security of Your Webapp

what would happen if thatserver were compromised?

Page 9: Getting Browsers to Improve the Security of Your Webapp
Page 10: Getting Browsers to Improve the Security of Your Webapp

Bad Things™

steal sessionsleak confidential dataredirect to phishing sitesenlist DDoS zombies

Page 11: Getting Browsers to Improve the Security of Your Webapp

simple solution

Page 12: Getting Browsers to Improve the Security of Your Webapp

instead of this:

<script

src=”https://ajax.googleapis.com...”>

integrity=”sha256-1z4uG/+cVbhShP...”

crossorigin=”anonymous”>

Page 13: Getting Browsers to Improve the Security of Your Webapp

<script

src=”https://ajax.googleapis.com...”>

integrity=”sha256-1z4uG/+cVbhShP...”

crossorigin=”anonymous”>

do this:

Page 14: Getting Browsers to Improve the Security of Your Webapp

guarantee:script won't changeor it'll be blocked

Page 15: Getting Browsers to Improve the Security of Your Webapp

rel=”noopener”

mechanism for disabling thewindow.opener object

Page 16: Getting Browsers to Improve the Security of Your Webapp

My Account

● Change my address● Change my billing card● Reset my password● Delete my account

● Watch some cute kittens!

Page 17: Getting Browsers to Improve the Security of Your Webapp

My Account

● Change my address● Change my billing card● Reset my password● Delete my account

● Watch some cute kittens!

kittens!!!!!!!!

Page 18: Getting Browsers to Improve the Security of Your Webapp

<a href=”...” target=”_blank”>

Page 19: Getting Browsers to Improve the Security of Your Webapp

window.opener.location

Page 20: Getting Browsers to Improve the Security of Your Webapp

window.opener.location

Page 21: Getting Browsers to Improve the Security of Your Webapp

window.opener.location =

'http://stealmypasswd.org';

Page 22: Getting Browsers to Improve the Security of Your Webapp

My Account

● Change my address● Change my billing card● Reset my password● Delete my account

● Watch some cute kittens!

kittens!!!!!!!!

Page 23: Getting Browsers to Improve the Security of Your Webapp

Session Expired

Username:

Password:

Log back in!

kittens!!!!!!!!

Page 24: Getting Browsers to Improve the Security of Your Webapp

Session Expired

Username:

Password:

Log back in!

esnowden

**********

Page 25: Getting Browsers to Improve the Security of Your Webapp

My Account

● Change my address● Change my billing card● Reset my password● Delete my account

● Watch some cute kittens!

Page 26: Getting Browsers to Improve the Security of Your Webapp

solutions

Page 27: Getting Browsers to Improve the Security of Your Webapp

<a href=”...” target=”_blank”>

Page 28: Getting Browsers to Improve the Security of Your Webapp

<a href=”...” target=”_blank” rel=”noopener”>

Page 29: Getting Browsers to Improve the Security of Your Webapp

window.opener == null

Page 30: Getting Browsers to Improve the Security of Your Webapp

Referrer Policy

mechanism for trimmingthe Referer header

Page 31: Getting Browsers to Improve the Security of Your Webapp
Page 32: Getting Browsers to Improve the Security of Your Webapp

http://example.com/search?q=serious+medical+condition

Click here for the cheapest

insurance around!

Bla bla bla, bla bla, bla bla bla bla. Bla bla bla, bla bla, bla bla bla bla. Bla bla bla, bla bla, bla bla bla bla.

Bla bla bla, bla bla, bla bla bla bla. Bla bla bla, bla bla, bla bla bla bla. Bla bla bla, bla bla, bla bla bla bla. Bla bla bla, bla bla, bla bla bla bla. Bla bla bla, bla bla, bla bla bla bla. Bla bla bla, bla bla, bla bla bla bla. Bla bla bla, bla bla, bla bla bla bla.

Page 34: Getting Browsers to Improve the Security of Your Webapp

Referrer-Policy: no-referrer

<meta name="referrer" content="origin">

<a href="http://example.com" referrer="origin">

Page 35: Getting Browsers to Improve the Security of Your Webapp

Referrer-Policy: no-referrer

<meta name="referrer" content="no-referrer">

<a href="http://example.com" referrer="origin">

Page 36: Getting Browsers to Improve the Security of Your Webapp

Referrer-Policy: no-referrer

<meta name="referrer" content="no-referrer">

<a href="http://example.com" referrerPolicy="no-referrer">

Page 37: Getting Browsers to Improve the Security of Your Webapp

no-referrer

no-referrer-when-downgrade

same-origin

strict-origin

strict-origin-when-cross-origin

Page 38: Getting Browsers to Improve the Security of Your Webapp

no-referrer

no-referrer-when-downgrade

same-origin

strict-origin

strict-origin-when-cross-origin

Page 39: Getting Browsers to Improve the Security of Your Webapp

no-referrer

no-referrer-when-downgrade

same-origin

strict-origin

strict-origin-when-cross-origin

Page 40: Getting Browsers to Improve the Security of Your Webapp

no-referrer

no-referrer-when-downgrade

same-origin

strict-origin-when-cross-origin

Page 41: Getting Browsers to Improve the Security of Your Webapp

no-referrer

no-referrer-when-downgrade

same-origin

strict-origin-when-cross-origin

https://developer.mozilla.org/docs/Web/HTTP/Headers/Referrer-Policy

Page 42: Getting Browsers to Improve the Security of Your Webapp

usercontent

Page 43: Getting Browsers to Improve the Security of Your Webapp

Sandboxed iframes

mechanism for restrictingembedded documents

Page 44: Getting Browsers to Improve the Security of Your Webapp

<iframe src=”resume.html”>

Page 45: Getting Browsers to Improve the Security of Your Webapp

window.parent

Page 46: Getting Browsers to Improve the Security of Your Webapp

seriousapp.com

seriousappusercontent.com

Page 47: Getting Browsers to Improve the Security of Your Webapp

<iframe src=”resume.html” sandbox=””>

Page 48: Getting Browsers to Improve the Security of Your Webapp

scripts

popups

forms

Page 49: Getting Browsers to Improve the Security of Your Webapp

scripts

popups

forms

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox

Page 50: Getting Browsers to Improve the Security of Your Webapp

X-Content-Type-Options

mechanism for disablingcontent type sniffing

Page 51: Getting Browsers to Improve the Security of Your Webapp

PDF

Page 52: Getting Browsers to Improve the Security of Your Webapp

Review Papers

● Witty-Title.pdf● Serious-Sounding-Topic.pdf● Series-of-buzzwords.pdf● Celebrity-Paper.pdf● Half-Ass-Paper.pdf

Page 53: Getting Browsers to Improve the Security of Your Webapp

%PDF-1.5<html><body> <script> ... </script></body></html>

Page 54: Getting Browsers to Improve the Security of Your Webapp

%PDF-1.5<html><body> <script> ... </script></body></html>

Page 55: Getting Browsers to Improve the Security of Your Webapp

<form action=”review.cgi”><input type=”hidden”

name=”paper-id”value=”42”>

<input type=”hidden”name=”score”value=”100”>

</form>

Page 56: Getting Browsers to Improve the Security of Your Webapp

X-Content-Type-Options: nosniff

Page 57: Getting Browsers to Improve the Security of Your Webapp

Content Security Policyaka CSP

mechanism for preventing XSS

Page 58: Getting Browsers to Improve the Security of Your Webapp

telling the browser the contentthat is allowed to load

Page 59: Getting Browsers to Improve the Security of Your Webapp

Hi y'all<script>alert('p0wned');</script>!

Tweet!

What's on your mind?

Page 60: Getting Browsers to Improve the Security of Your Webapp

without CSP

Page 61: Getting Browsers to Improve the Security of Your Webapp

Hi y'all!John Doe - just moments ago

p0wnedOk

Page 62: Getting Browsers to Improve the Security of Your Webapp

with CSP

Page 63: Getting Browsers to Improve the Security of Your Webapp

Hi y'all!John Doe - just moments ago

Page 64: Getting Browsers to Improve the Security of Your Webapp

Content-Security-Policy:

script-src 'self'

https://cdn.example.com

Page 65: Getting Browsers to Improve the Security of Your Webapp

script-srcobject-srcstyle-srcimg-src

media-srcfont-src

connect-src...

Page 66: Getting Browsers to Improve the Security of Your Webapp

script-srcobject-srcstyle-srcimg-src

media-srcfont-src

connect-src...

https://developer.mozilla.org/docs/Web/HTTP/CSP

Page 67: Getting Browsers to Improve the Security of Your Webapp

cookies

Page 68: Getting Browsers to Improve the Security of Your Webapp
Page 69: Getting Browsers to Improve the Security of Your Webapp

1234

Page 70: Getting Browsers to Improve the Security of Your Webapp

Set-Cookie: sessionid=1234

Page 71: Getting Browsers to Improve the Security of Your Webapp

1234

Page 72: Getting Browsers to Improve the Security of Your Webapp

1234

Page 73: Getting Browsers to Improve the Security of Your Webapp

document.cookie

Page 74: Getting Browsers to Improve the Security of Your Webapp

Cookie options

mechanism for restrictingthe scope of cookies

Page 75: Getting Browsers to Improve the Security of Your Webapp

Set-Cookie: sessionid=1234;httponly

Page 76: Getting Browsers to Improve the Security of Your Webapp

document.cookie == null

Page 77: Getting Browsers to Improve the Security of Your Webapp

Set-Cookie: sessionid=1234;secure

Page 78: Getting Browsers to Improve the Security of Your Webapp

1234

Page 79: Getting Browsers to Improve the Security of Your Webapp
Page 80: Getting Browsers to Improve the Security of Your Webapp

good, but not great

Page 81: Getting Browsers to Improve the Security of Your Webapp

1234

Page 82: Getting Browsers to Improve the Security of Your Webapp

Set-Cookie: sessionid=1234

Page 83: Getting Browsers to Improve the Security of Your Webapp

1234

Page 84: Getting Browsers to Improve the Security of Your Webapp

666

Page 85: Getting Browsers to Improve the Security of Your Webapp

666

Page 86: Getting Browsers to Improve the Security of Your Webapp

Cookie prefixes

mechanism for enforcingcookie restrictions

Page 87: Getting Browsers to Improve the Security of Your Webapp

Set-Cookie: __Secure-sessionid=1234;secure

Page 88: Getting Browsers to Improve the Security of Your Webapp

__Secure-sessionid=666

Page 89: Getting Browsers to Improve the Security of Your Webapp
Page 90: Getting Browsers to Improve the Security of Your Webapp

encryption

Page 91: Getting Browsers to Improve the Security of Your Webapp

HTTPS

mechanism for securinginformation in transit

Page 92: Getting Browsers to Improve the Security of Your Webapp

if you're not using it, now is the time to start :)

Page 94: Getting Browsers to Improve the Security of Your Webapp

HTTPS is not enough

you need to do it properly

Page 95: Getting Browsers to Improve the Security of Your Webapp

RC4

Page 96: Getting Browsers to Improve the Security of Your Webapp

SHA-1

RC4

Page 97: Getting Browsers to Improve the Security of Your Webapp

SHA-11024-bit certificates

RC4

Page 98: Getting Browsers to Improve the Security of Your Webapp

SHA-11024-bit certificates

RC4 weak DH parameters

Page 100: Getting Browsers to Improve the Security of Your Webapp

https://mozilla.github.io/server-side-tls/ssl-config-generator/

Page 101: Getting Browsers to Improve the Security of Your Webapp

https://www.ssllabs.com/ssltest/

Page 102: Getting Browsers to Improve the Security of Your Webapp

Strict Transport Securityaka HSTS

mechanism for preventingHTTPS to HTTP downgrades

Page 103: Getting Browsers to Improve the Security of Your Webapp

telling the browser that your siteshould never be reached over HTTP

Page 104: Getting Browsers to Improve the Security of Your Webapp
Page 105: Getting Browsers to Improve the Security of Your Webapp

GET bank.com 301→

GET https://bank.com 200→

no HSTS, no sslstrip

Page 106: Getting Browsers to Improve the Security of Your Webapp

GET bank.com → 200

no HSTS, with sslstrip

Page 107: Getting Browsers to Improve the Security of Your Webapp

what does HSTS look like?

Page 108: Getting Browsers to Improve the Security of Your Webapp

Strict-Transport-Security: max-age=31536000

Page 109: Getting Browsers to Improve the Security of Your Webapp

with HSTS, with sslstrip

GET https://bank.com 200→

Page 110: Getting Browsers to Improve the Security of Your Webapp

no HTTP traffic forsslstrip to tamper with

Page 111: Getting Browsers to Improve the Security of Your Webapp

https://hstspreload.org/

Page 112: Getting Browsers to Improve the Security of Your Webapp

referrer policysubresource integrity

noopener

cookie prefixescookie options

sandboxed iframesx-content-type-optionscontent security policy

httpsstrict transport

security

Page 113: Getting Browsers to Improve the Security of Your Webapp

Questions?

feedback:

[email protected]@fmariermozilla.dev.security

© 2017 François Marier <[email protected]>This work is licensed under aCreative Commons Attribution-ShareAlike 4.0 License.

Page 114: Getting Browsers to Improve the Security of Your Webapp

photo credits:

explosion: https://www.flickr.com/photos/-cavin-/2313239884/kittens: https://www.flickr.com/photos/londonlooks/5693093073cookie: https://www.flickr.com/photos/amagill/34754258/