Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Security and Privacy on the Web in 2015

Security and Privacy on the Web in 2015

In the last few years, a number of new security features have become available to web developers (e.g. Content Security Policy, Strict Transport Security) and a few more are coming up this year (e.g. Referrer Policy, Subresource Integrity). In addition to getting familiar with these, a number of recent high-profile bugs in the SSL/TLS protocol and implementations have forced developers to learn more about TLS ciphers and to start worrying about mixed content on their pages.

As a browser vendor and a member of the W3C WebAppSec working group, Mozilla is busy extending the web platform to provide the tools and features that developers and users need in 2015. This talk will give an overview of the security and privacy landscape on the web as well as pointers to what developers need to know to secure their applications.

https://2015.rmll.info/security-and-privacy-on-the-web-in-2015?lang=en

Francois Marier

July 07, 2015
Tweet

More Decks by Francois Marier

Other Decks in Programming

Transcript

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

    View full-size slide

  2. Firefox
    Security & Privacy

    View full-size slide

  3. Web Platform

    View full-size slide

  4. Web Platform

    View full-size slide

  5. Content Security Policy
    aka CSP

    View full-size slide

  6. Content Security Policy
    aka CSP
    mechanism for preventing XSS

    View full-size slide

  7. telling the browser what external
    content is allowed to load

    View full-size slide

  8. Hi you<br/>alert('p0wned');<br/>!
    Tweet!
    What's on your mind?

    View full-size slide

  9. Hi you!
    John Doe - just moments ago
    p0wned
    Ok

    View full-size slide

  10. Hi you!
    John Doe - just moments ago

    View full-size slide

  11. Content-Security-Policy:
    script-src 'self'
    https://cdn.example.com

    View full-size slide

  12. inline scripts are blocked unless
    unsafe-inline is specified

    View full-size slide

  13. script-src
    object-src
    style-src
    img-src
    media-src
    frame-src
    font-src
    connect-src

    View full-size slide

  14. $ curl --head https://twitter.com
    HTTP/1.1 200 OK
    content-length: 58347
    content-security-policy: …
    report-uri https://twitter.com/csp_report
    violation reports:

    View full-size slide

  15. "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/..."
    }

    View full-size slide

  16. support for inline scripts
    Content-Security-Policy:
    script-src 'sha256-YWIzOW...'

    View full-size slide

  17. Strict Transport Security
    aka HSTS

    View full-size slide

  18. Strict Transport Security
    aka HSTS
    mechanism for preventing
    HTTPS to HTTP downgrades

    View full-size slide

  19. telling the browser that your site
    should never be reached over HTTP

    View full-size slide

  20. GET banque.fr 301

    GET https://banque.fr 200

    no HSTS, no sslstrip

    View full-size slide

  21. GET banque.fr → 200
    no HSTS, with sslstrip

    View full-size slide

  22. what does HSTS look like?

    View full-size slide

  23. $ curl -i https://example.com
    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Type: text/html; charset=utf-8
    Strict-Transport-Security: max-age=31536000
    ...

    View full-size slide

  24. with HSTS, with sslstrip
    GET https://banque.fr 200

    View full-size slide

  25. silent client-side redirects
    HTTP → HTTPS

    View full-size slide

  26. no HTTP traffic for
    sslstrip to tamper with

    View full-size slide

  27. except for the very
    first connection

    View full-size slide

  28. https://hstspreload.appspot.com/

    View full-size slide

  29. coming up in 2015

    View full-size slide

  30. https://ajax.googleapis.com
    /ajax/libs/jquery/1.8.0/
    jquery.min.js

    View full-size slide

  31. how common is this?

    View full-size slide

  32. what would happen if that
    server were compromised?

    View full-size slide

  33. Bad Things™
    steal sessions
    leak confidential data
    redirect to phishing sites
    enlist DDoS zombies

    View full-size slide

  34. simple solution

    View full-size slide

  35. instead of this:
    src=”https://ajax.googleapis.com...”>

    View full-size slide

  36. src=”https://ajax.googleapis.com...”
    integrity=”sha256-1z4uG/+cVbhShP...”>
    do this:

    View full-size slide

  37. guarantee:
    script won't change
    or it'll be blocked

    View full-size slide

  38. limitation:
    won't work for scripts
    that change all the time

    View full-size slide

  39. https://ajax.googleapis.com
    /ajax/libs/jquery/1.8.0/
    jquery.min.js

    View full-size slide

  40. there's a little something missing...

    View full-size slide

  41. src=”https://ajax.googleapis.com...”
    integrity=”sha256-1z4uG/+cVbhShP...”
    crossorigin=”anonymous”>
    complete example:

    View full-size slide

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

    View full-size slide

  43. example.com/index.html

    View full-size slide

  44. example.com/index.html
    example.com/data.js:
    var secret = 42;

    View full-size slide

  45. example.com/index.html
    example.com/data.js:
    var secret = 42;
    evil.net/widget.js:
    exfiltrate(secret);

    View full-size slide

  46. example.com/index.html
    example.com/data.js:
    var secret = 42;
    evil.net/widget.js:
    exfiltrate(secret);

    View full-size slide

  47. on the server:
    Access-Control-Allow-Origin: *

    View full-size slide

  48. on the server:
    Access-Control-Allow-Origin: *
    on the client:
    crossorigin=”anonymous”

    View full-size slide

  49. src=”https://ajax.googleapis.com...”
    integrity=”sha256-1z4uG/+cVbhShP...”
    crossorigin=”anonymous”>
    complete example:

    View full-size slide

  50. href="style.css"
    integrity="sha256-PgMdguwx/O..."
    crossorigin=”anonymous”>
    complete example:

    View full-size slide

  51. 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.

    View full-size slide

  52. No Referrer
    No Referrer When Downgrade
    Origin Only
    Origin When Cross Origin
    Unsafe URL

    View full-size slide

  53. No Referrer
    No Referrer When Downgrade
    Origin Only
    Origin When Cross Origin
    Unsafe URL

    View full-size slide

  54. No Referrer
    No Referrer When Downgrade
    Origin Only
    Origin When Cross Origin
    Unsafe URL

    View full-size slide

  55. No Referrer
    No Referrer When Downgrade
    Origin Only
    Origin When Cross Origin
    Unsafe URL

    View full-size slide

  56. No Referrer
    No Referrer When Downgrade
    Origin Only
    Origin When Cross Origin
    Unsafe URL

    View full-size slide

  57. Content-Security-Policy: referrer origin;


    View full-size slide

  58. Content-Security-Policy: referrer origin;


    View full-size slide

  59. Content-Security-Policy: referrer origin;


    View full-size slide

  60. (initial implementations)

    View full-size slide

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

    View full-size slide

  62. mass surveillance of
    all Internet traffic
    is no longer theoretical

    View full-size slide

  63. strong encryption of
    all Internet traffic
    is no longer optional

    View full-size slide

  64. “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

    View full-size slide

  65. ps://gigaom.com/2015/02/19/dont-let-att-mislead-you-about-its-29-privacy-fee/

    View full-size slide

  66. $ apt-get install letsencrypt
    $ letsencrypt example.com

    View full-size slide

  67. automatically prove domain ownership
    download a free-as-in-beer certificate
    monitor and renew it before it expires

    View full-size slide

  68. automatically prove domain ownership
    download a free-as-in-beer certificate
    monitor and renew it before it expires

    View full-size slide

  69. automatically prove domain ownership
    download a free-as-in-beer certificate
    monitor and renew it before it expires

    View full-size slide

  70. HTTPS is not enough
    you need to do it properly

    View full-size slide

  71. SHA-1
    1024-bit certificates
    RC4

    View full-size slide

  72. SHA-1
    1024-bit certificates
    RC4 weak DH parameters

    View full-size slide

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


    src="http://people.mozilla.org/~fmarier/mixed-content.js">






    View full-size slide

  74. turn on full mixed-content blocking in development

    View full-size slide

  75. 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

    View full-size slide

  76. Questions?
    feedback:
    [email protected]
    mozilla.dev.security
    [email protected]
    © 2015 François Marier
    This work is licensed under a
    Creative Commons Attribution-ShareAlike 4.0 License.

    View full-size slide

  77. 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

    View full-size slide