105
Security and Privacy on the Web in 2015 François Marier @fmarier mozilla

Security and Privacy on the Web in 2015

Embed Size (px)

Citation preview

Page 1: Security and Privacy on the Web in 2015

Security and Privacyon the Web in 2015

François Marier @fmarier mozilla

Page 2: Security and Privacy on the Web in 2015

FirefoxSecurity & Privacy

Page 3: Security and Privacy on the Web in 2015

Web Platform

Page 4: Security and Privacy on the Web in 2015

Web Platform

Page 5: Security and Privacy on the Web in 2015

Content Security Policyaka CSP

Page 6: Security and Privacy on the Web in 2015

Content Security Policyaka CSP

mechanism for preventing XSS

Page 7: Security and Privacy on the Web in 2015

telling the browser what externalcontent is allowed to load

Page 8: Security and Privacy on the Web in 2015

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

Tweet!

What's on your mind?

Page 9: Security and Privacy on the Web in 2015

without CSP

Page 10: Security and Privacy on the Web in 2015

Hi you!John Doe - just moments ago

p0wnedOk

Page 11: Security and Privacy on the Web in 2015

with CSP

Page 12: Security and Privacy on the Web in 2015

Hi you!John Doe - just moments ago

Page 13: Security and Privacy on the Web in 2015

Content-Security-Policy:

script-src 'self'

https://cdn.example.com

Page 14: Security and Privacy on the Web in 2015

inline scripts are blocked unlessunsafe-inline is specified

Page 15: Security and Privacy on the Web in 2015

script-srcobject-srcstyle-srcimg-srcmedia-srcframe-srcfont-src

connect-src

Page 16: Security and Privacy on the Web in 2015

$ curl --head https://twitter.comHTTP/1.1 200 OKcontent-length: 58347content-security-policy: …report-uri https://twitter.com/csp_report

violation reports:

Page 17: Security and Privacy on the Web in 2015

"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'", "effective-directive": "img-src", "original-policy":

"default-src 'self';report-uri http://example.org/..."

}

Page 19: Security and Privacy on the Web in 2015

support for inline scripts

Content-Security-Policy:

script-src 'sha256-YWIzOW...'

Page 20: Security and Privacy on the Web in 2015
Page 21: Security and Privacy on the Web in 2015

Strict Transport Securityaka HSTS

Page 22: Security and Privacy on the Web in 2015

Strict Transport Securityaka HSTS

mechanism for preventingHTTPS to HTTP downgrades

Page 23: Security and Privacy on the Web in 2015

telling the browser that your siteshould never be reached over HTTP

Page 24: Security and Privacy on the Web in 2015
Page 25: Security and Privacy on the Web in 2015

GET banque.fr 301→

GET https://banque.fr 200→

no HSTS, no sslstrip

Page 26: Security and Privacy on the Web in 2015

GET banque.fr → 200

no HSTS, with sslstrip

Page 27: Security and Privacy on the Web in 2015

what does HSTS look like?

Page 28: Security and Privacy on the Web in 2015

$ curl -i https://example.comHTTP/1.1 200 OKCache-Control: privateContent-Type: text/html; charset=utf-8Strict-Transport-Security: max-age=31536000...

Page 29: Security and Privacy on the Web in 2015

with HSTS, with sslstrip

GET https://banque.fr 200→

Page 30: Security and Privacy on the Web in 2015

silent client-side redirectsHTTP → HTTPS

Page 31: Security and Privacy on the Web in 2015

no HTTP traffic forsslstrip to tamper with

Page 32: Security and Privacy on the Web in 2015

except for the veryfirst connection

Page 33: Security and Privacy on the Web in 2015

https://hstspreload.appspot.com/

Page 34: Security and Privacy on the Web in 2015
Page 35: Security and Privacy on the Web in 2015

coming up in 2015

Page 37: Security and Privacy on the Web in 2015
Page 38: Security and Privacy on the Web in 2015
Page 39: Security and Privacy on the Web in 2015

https://ajax.googleapis.com

/ajax/libs/jquery/1.8.0/

jquery.min.js

Page 40: Security and Privacy on the Web in 2015

how common is this?

Page 41: Security and Privacy on the Web in 2015
Page 42: Security and Privacy on the Web in 2015

what would happen if thatserver were compromised?

Page 43: Security and Privacy on the Web in 2015
Page 44: Security and Privacy on the Web in 2015

Bad Things™

steal sessionsleak confidential dataredirect to phishing sitesenlist DDoS zombies

Page 45: Security and Privacy on the Web in 2015

simple solution

Page 46: Security and Privacy on the Web in 2015

instead of this:

<scriptsrc=”https://ajax.googleapis.com...”>

Page 47: Security and Privacy on the Web in 2015

<scriptsrc=”https://ajax.googleapis.com...”integrity=”sha256-1z4uG/+cVbhShP...”>

do this:

Page 48: Security and Privacy on the Web in 2015

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

Page 49: Security and Privacy on the Web in 2015

limitation:won't work for scriptsthat change all the time

Page 50: Security and Privacy on the Web in 2015

https://ajax.googleapis.com

/ajax/libs/jquery/1.8.0/

jquery.min.js

Page 51: Security and Privacy on the Web in 2015

there's a little something missing...

Page 52: Security and Privacy on the Web in 2015

<script

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

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

crossorigin=”anonymous”>

complete example:

Page 54: Security and Privacy on the Web in 2015

“a web browser permits scripts contained in a firstweb page to access data in a second web page,but only if both web pages have the same origin”

same-origin policy

Page 55: Security and Privacy on the Web in 2015

example.com/index.html

Page 56: Security and Privacy on the Web in 2015

example.com/index.html

example.com/data.js:

var secret = 42;

Page 57: Security and Privacy on the Web in 2015

example.com/index.html

example.com/data.js:

var secret = 42;

evil.net/widget.js:

exfiltrate(secret);

Page 58: Security and Privacy on the Web in 2015

example.com/index.html

example.com/data.js:

var secret = 42;

evil.net/widget.js:

exfiltrate(secret);

Page 59: Security and Privacy on the Web in 2015

on the server:

Access-Control-Allow-Origin: *

Page 60: Security and Privacy on the Web in 2015

on the server:

Access-Control-Allow-Origin: *

on the client:

crossorigin=”anonymous”

Page 61: Security and Privacy on the Web in 2015

<script

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

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

crossorigin=”anonymous”>

complete example:

Page 62: Security and Privacy on the Web in 2015

<link rel="stylesheet"

href="style.css"

integrity="sha256-PgMdguwx/O..."

crossorigin=”anonymous”>

complete example:

Page 63: Security and Privacy on the Web in 2015

SRIhash.org

Page 64: Security and Privacy on the Web in 2015
Page 66: Security and Privacy on the Web in 2015
Page 67: Security and Privacy on the Web in 2015

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 69: Security and Privacy on the Web in 2015

No ReferrerNo Referrer When DowngradeOrigin OnlyOrigin When Cross OriginUnsafe URL

Page 70: Security and Privacy on the Web in 2015

No ReferrerNo Referrer When DowngradeOrigin OnlyOrigin When Cross OriginUnsafe URL

Page 71: Security and Privacy on the Web in 2015

No ReferrerNo Referrer When DowngradeOrigin OnlyOrigin When Cross OriginUnsafe URL

Page 72: Security and Privacy on the Web in 2015

No ReferrerNo Referrer When DowngradeOrigin OnlyOrigin When Cross OriginUnsafe URL

Page 73: Security and Privacy on the Web in 2015

No ReferrerNo Referrer When DowngradeOrigin OnlyOrigin When Cross OriginUnsafe URL

Page 74: Security and Privacy on the Web in 2015

Content-Security-Policy: referrer origin;

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

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

Page 75: Security and Privacy on the Web in 2015

Content-Security-Policy: referrer origin;

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

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

Page 76: Security and Privacy on the Web in 2015

Content-Security-Policy: referrer origin;

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

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

Page 77: Security and Privacy on the Web in 2015

(initial implementations)

Page 78: Security and Privacy on the Web in 2015

HTTPS

Page 79: Security and Privacy on the Web in 2015

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

Page 81: Security and Privacy on the Web in 2015
Page 82: Security and Privacy on the Web in 2015

mass surveillance ofall Internet traffic

is no longer theoretical

Page 83: Security and Privacy on the Web in 2015

strong encryption ofall Internet traffic

is no longer optional

Page 84: Security and Privacy on the Web in 2015

“If we only use encryption when we're working with important data, then encryption signals that data's importance. If only dissidents use encryption in a country, that country's authorities have an easy way of identifying them. But if everyone uses it all of the time, encryption ceases to be a signal. The government can't tell the dissidents from the rest of the population. Every time you use encryption, you're protecting someone who needs to use it to stay alive.”

-Bruce Schneier

Page 87: Security and Privacy on the Web in 2015

$ apt-get install letsencrypt

$ letsencrypt example.com

Page 88: Security and Privacy on the Web in 2015

automatically prove domain ownership

download a free-as-in-beer certificate

monitor and renew it before it expires

Page 89: Security and Privacy on the Web in 2015

automatically prove domain ownership

download a free-as-in-beer certificate

monitor and renew it before it expires

Page 90: Security and Privacy on the Web in 2015

automatically prove domain ownership

download a free-as-in-beer certificate

monitor and renew it before it expires

Page 91: Security and Privacy on the Web in 2015

HTTPS is not enough

you need to do it properly

Page 92: Security and Privacy on the Web in 2015

RC4

Page 93: Security and Privacy on the Web in 2015

SHA-1

RC4

Page 94: Security and Privacy on the Web in 2015

SHA-11024-bit certificates

RC4

Page 95: Security and Privacy on the Web in 2015

SHA-11024-bit certificates

RC4 weak DH parameters

Page 100: Security and Privacy on the Web in 2015

https://people.mozilla.org/~fmarier/mixed-content.html

<html><head> <script src="http://people.mozilla.org/~fmarier/mixed-content.js"> </script></head><body> <img src="http://fmarier.org/img/francois_marier.jpg"></body></html>

Page 101: Security and Privacy on the Web in 2015
Page 102: Security and Privacy on the Web in 2015

turn on full mixed-content blocking in development

Page 103: Security and Privacy on the Web in 2015

Start by enabling HTTPS and HSTS

Use SRI for your external scripts

Set a more restrictive Referrer policy

Consider enabling CSP

Watch out for mixed content

Page 104: Security and Privacy on the Web in 2015

Questions?feedback:

[email protected]@w3.org

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

Page 105: Security and Privacy on the Web in 2015

photo credits:

tinfoil: https://www.flickr.com/photos/laurelrusswurm/15129449047

explosion: https://www.flickr.com/photos/-cavin-/2313239884/

snowden: https://www.flickr.com/photos/gageskidmore/16526354372