59
HTTPS

CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

  • Upload
    proidea

  • View
    22

  • Download
    1

Embed Size (px)

Citation preview

Page 1: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTPS

Page 2: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Jim Manico@manicode

Page 3: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

3

Page 4: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

4

Page 5: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

5

Page 6: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

6

Page 7: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

7

They use crypto. I saw the padlock in the browser.

Oh, no!

Page 8: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

8

“Any unencrypted traffic, visible to an adversary, is not just an information leak, but an attack vector they can use to exploit your systems.”

Nick Weaver

Page 9: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

What is SSL/HTTPS/TLS?

What’s another way of looking at the benefits of SSL/TLS?

• Confidentiality: Spy cannot view your data• Integrity: Spy cannot change your data• Authenticity: Server your are visiting is the

right one, backed up by the Certificate Authority System

Page 10: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

TLS Protocol Workflow

• TLS Uses Both Symmetric and Asymmetric Encryption

• SSL Exchanges Symmetric Keys Encrypted With Asymmetric Keys, then falls back to Symmetric encryption

• Why? Symmetric encryption is MUCH faster. Assmetric is slower but stronger.

Page 11: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

SSL/TLS Protocol Versions

SSL v1, v2, v3 — Broken. Do not use! TLS 1.0 - "ok"!TLS 1.1 - No known practical attacks!TLS 1.2 - Best available

Page 12: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

#1 Most Important Thing on Getting SSL Right

Update your OS to latest patch level

If you are using Apache 1.3, WTF• Just focus on getting up to date with Apache

2.2/2.4• This will update your OpenSSL library, fixing

numerous problems

Courtesy of @ngalbreath

Page 13: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

MobilityIoE

E-Commerce Privacy

Snowden

Trajectory and Growth of EncryptionSSL growing ~30% annually.

Entering the Fifth wave of transition (IoE).

1998 2002 2006 2010 20140.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

Source: Netcraft

Mill

ions

of C

ertifi

cate

s (C

A)

Page 14: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Relevant Attacks on TLS Protocol• 2011 BEAST

• Upgrade to TLS 1.1• Use RC4 for older protocols. Mitigated by browsers.

• 2012 CRIME• Stop using TLS compression

• 2013 BREACH• Vendors disabled HTTP compression in client and server side• Mask sensitive tokens, randomize them per request

• 2014 Heartbleed• Abuse the heart beat feature in OpenSSL to retrieve chucks of memory

for the server• 2015 Freak, Logjam

• Downgrade/refactoring attacks

Page 15: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

CA #fail Sept 2011

Page 16: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTPSCA #fail Feb 2012

Page 17: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTPSCA #fail December 2012

Page 18: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTPSCA #fail December 2013

Page 19: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTPSRegistrar #fail December 2012

Page 20: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

OpenSSL #fail: Heartbleed 2014

Page 21: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

How Heartbleed Works

Page 22: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Logjam

Page 23: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Logjam

Page 24: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTPS Developer #fail

• Posting passwords or sensitive data over HTTP• Loading mixed content• Using protocol relative URLS• Using weak version of SSL (TLS 1.0+ is GOOD)• Using weak ciphers• Terminating SSL early in your infrastructure• Trusting the CA system• Using old OS's or old HTTP Servers

Page 25: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Trust Security Decisions to Browsers Vendors, Users and other client Entities? #fail

Page 26: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

BROWSER/OS HTTPS SINS: Feb 2014

Page 27: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Apple goto #fail SSL bug

Major iOS/OSX SSL implementation bug

http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-1266

"...does not check the signature in a TLS Server Key Exchange message...."

"...allows man-in-the-middle attackers to spoof SSL servers by (1) using an arbitrary private key for the signing step or (2) omitting the signing step."

Page 28: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

goto fail Apple SSL bug

static OSStatusSSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams, uint8_t *signature, UInt16 signatureLen){

OSStatus err;...

if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)goto fail;

if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)goto fail;

 goto fail;if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)

goto fail;...

fail:SSLFreeBuffer(&signedHashes);SSLFreeBuffer(&hashCtx);return err;

}

Page 29: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Browsers let users do the ultimate security decision

It worked yesterday,

so…

The effects of a “fail open/soft fail” policy• 30-70% of the users click through warnings*• Completely defeats the purpose of encryption• No good way to change browser behavior, until recently

* http://www.cs.berkeley.edu/~devdatta/papers/alice-in-warningland.pdf

Page 30: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Chrome will begin to mark HTTP sites as insecure

30

HTTP will soon be downgraded as insecure in Chrome.As of December 2014, Chromes Canary release (alpha release) includes an option to mark HTTP websites as insecure. This will go live in 2015.

Page 31: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Excuses to avoid supporting HTTPS

Aren't certificates expensive/difficult to obtain?

A few providers currently provide free/cheap/bundled certificates right now. The "Let's Encrypt" project will make it easy to obtain free certs for as many (sub)domains as desired, starting in summer 2015.

Isn't SSL/TLS slow?Not really (for almost all sites, if they are following good practices). https://istlsfastyet.com/

Doesn't HTTPS break caching? Filtering?If you're a site operator concerned about site load, there are various secure CDN options available. For environments that need tight control of internet access, there are several client-side/network solutions.

thegameoffitness.com

S

Page 32: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Improving HTTPS

HSTS (Strict Transport Security)http://www.youtube.com/watch?v=zEV3HOuM_VwStrict-Transport-Security: max-age=31536000

Certificate Pinninghttps://www.owasp.org/index.php/Pinning_Cheat_Sheet

Forward Secrecyhttps://whispersystems.org/blog/asynchronous-security/

Mozilla Recommended TLS Security Configurationshttps://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_configurations

Mozilla SSL Configuration Generatorhttps://mozilla.github.io/server-side-tls/ssl-config-generator/

NIST Guidelines on selection, configuration and use of TLShttp://www.nist.gov/manuscript-publication-search.cfm?pub_id=915295

Page 33: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTP Strict Transport Security (HSTS)

• Released in November 2012• Mitigates

• Soft fail – tolerance to errors• MitM attack using DNS trickery• Browser default behavior of trying HTTP first• Mixed content

• Protects the user, not the website• HTTP specific and must own the domain

Strict-Transport-Security: max-age=31536000; includeSubDomains

Page 34: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTP Strict Transport Security (HSTS)

Tips• Won’t work with self signed certs• Won’t work with IP• Won’t work with plaintext connection• Will work in all ports• Deploy with a short duration value first. Increase it later.

To Revoke HSTS

Strict-Transport-Security: max-age=0

Page 35: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTP Strict Transport Security (HSTS)

Security Considerations• Include in all subdomains, even when using includeSubDomains

• Lack of includeSubDomains is a privacy violation for users• Activated during the first use

• Browsers can preload HSTS… for now. • Back to first use scenario once retention period expires

• Can be forced to first use scenario by spoofing NTP• Does not necessarily secure cookies

• Redirect to a made-up subdomain may reveal cookies (assuming no https)• Continue to use secure cookies

Page 36: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTP Strict Transport Security (HSTS)

Supported Browsers*Minimum Browser Support HSTS

Internet Explorer 12 <- Cheeky BastardsFirefox 29Opera 12Safari 7Android Browser 4.4 (KitKat)Chrome

* http://caniuse.com/#feat=stricttransportsecurity

Page 37: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HSTS – Preload ListIf you own a site that you would like to see included in the preloaded Chromium HSTS list, start sending the HSTS header and then contact: [email protected] Current HSTS Chrome preload list http://src.chromium.org/viewvc/chrome/trunk/src/net/http/transport_security_state_static.jsonMore info at: http://dev.chromium.org/sts A site is included in the Firefox preload list if the following hold:

• It is in the Chromium list (with force-https).• It sends an HSTS header.• The max-age sent is at least 10886400 (18 weeks).

Page 38: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

38

Too much trust in Certificate Authorities

Page 39: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Certificate PinningWhat is Pinning?

• Pinning is a key continuity scheme • Detect when an imposter with a fake but CA validated certificate attempts to act like

the real server

2 Types of pinning• Carry around a copy of the server’s public key; • Great if you are distributing a dedicated client-server application since you know the

server’s certificate or public key in advance

Note of the server’s public key on first use• Trust-on-First-Use, TOFU pinning• Useful when no a priori knowledge exists, such as SSH or a Browser

https://www.owasp.org/index.php/Pinning_Cheat_Sheet

Page 40: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Browser-Based TOFU PinningBrowser-Based TOFU Pinning

• Trust on First Use

HTTP Public Key Pinning IETF Draft• http://tools.ietf.org/html/draft-ietf-websec-key-pinning-11 • Freezes the certificate by pushing a fingerprint of (parts of) the certificate chain

to the browser

Example:

Public-Key-Pins: pin-sha256="4n972HfV354KP560yw4uqe/baXc=";pin-sha256="qvTGHdzF6KLavt4PO0gs2a6pQ00=";pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";max-age=10000; includeSubDomains

Page 41: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Pinning – Considerations

• Always have a backup pin and a spare certificate from a different CA• Avoids a self inflicted DoS• Consider setting the pin in days if trust on first use (TOFU, aka key

continuity)• Certificates should have overlapping validity periods

• For Mobile Apps, consider adding the pinning during install instead of TOFU• Out of band pinning decreases chances of attacker tainting pin

• Pinning makes it harder to Pen Test• May need to use iOS SSL Kill Switch and Android SSL Bypass Tool • May need to disable it altogether

Page 42: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

HTTP Public Key Pinning extension (HPKP)

• HTTP Public Key Pinning IETF Draft• http://tools.ietf.org/html/draft-ietf-websec-key-pinning-11 • Freezes the certificate by pushing a fingerprint

of (parts of) the certificate chain to the browser • Upcoming standard proposed by Google• Similar to HSTS (max-age, includeSubDomains)

Public-Key-Pins: max-age=12000; pin-sha256="ABC..."; pin-sha256="DEF...";includeSubDomains

Pin-sha256: base64 encoded SPKI. Include two.

Deployment tips• Use Public-Key-Pin-Report-Only instead.• User directive report-uri="http://site.com/pkp-fail-report”

• Sends JSON using HTTP post with status in case of failure.

Page 43: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Pinning in Play (Chrome)

Page 44: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Pinning can and has been evaded

Locally Installed Authorities can MITM while evading Pinning!

"Researchers revealed that a vulnerability in Superfish software, which came pre-loaded on many Lenovo laptops, could let hackers impersonate shopping, banking and other websites and steal users' credit card numbers and other personal data."

- CBS News, February 2015

Even the hard-coded Pinning of Google services in Chrome were evaded• SuperFish installs its own root CA certificate in Windows systems.• It then generates certificates on the fly for each attempted SSL connection to inject

advertisements.• The private key of the Superfish pair was discovered allowing reuse.

Rapid research on this incident from the security community• Robert Graham series of blog posts• General Info on Superfish• http://blog.erratasec.com/2015/02/some-notes-on-superfish.htm• Extracting Superfish certs:

http://blog.erratasec.com/2015/02/extracting-superfish-certificate.html • Exploiting Superfish:• http://blog.erratasec.com/2015/02/exploiting-superfish-certificate.html

Page 45: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

45

Certificate revocation doesn’t always work

Page 46: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Revocation does not work

• It takes at least 10 days for the revocation Information to fully propagate• Browser soft fail policy makes revocation ineffective• OCSP request can be intercepted (more on this than later) • Most browsers ignore revocation for all certificates but EV certificates

• List includes Chrome, Firefox, Chrome on Android, iOS on Safari…IE and Opera do the right think checking OCSP and CRL when appropriate

• Revocation checks can be enable in some browsers. In Firefox, set security.ocsp.required to true

• Important certificates (e.g., intermediate CAs), rely on a proprietary revocation channel (CRISets) that feeds off of Cert Revocation Lists (CRL) information

Page 47: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Certificate Revocation Lists (CRLs) do not scale

GoDaddy CRL Size

0

5000

10000

15000

20000

25000

30000

35000

40000

45000

158Kb

41Mb

2007 2013* Does not include data after heartbleed.

Page 48: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

An alternative to certificate revocation lists (CRL)Online Certificate Status Protocol (OCSP)

Cert Auth

Web Server

App Talks to Server

Port 80 to OCSP:

Request status for

webserver

Port 80 to Client: Status OK. Signed by

OCSP Responder

Does the usual… Not shown here for simplicity sake.

No Privacy

OCSP Responder

Page 49: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Attacks against OCSP

Cert Auth

OCSP Responder

Web Server

App Talks to Server

Port 80 to OCSP:

Request status for

webserver

Does the usual… Not shown here

for simplicity sake.

MitM

Port 80 to Client: Status OK. Signed by OCSP

Responder

Page 50: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

OCSP Request

OCSP Request

Attacks against OCSP

Cert Auth

OCSP Responder

Web Server

Port 80 to OCSP:

Request status for

webserver

Does the usual… Not shown here

for simplicity sake.

MitM

Page 51: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Cach

es O

SCP

data

an

d st

aple

s in

cert

re

spon

se

Faster, Safer and more PrivateOCSP Stapling

Cert Auth

Web Server

App Talks to Server Does the usual… Not shown here

for simplicity sake.

Port

80

OCSP Responder

Page 52: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

TLS and Cipher Suites

Page 53: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Problems with OLD SSL ciphers

• If you use older SSL ciphers ....• ... every time anyone makes a SSL connection to your server, that

message is encrypted with (basically) the same private server key

Perfect forward secrecy: Peers in a conversation instead negotiate secrets through an ephemeral (temporary) key exchange. With Perfect Forward Secrecy, recording ciphertext traffic doesn’t help an attacker even if the private server key is stolen!

From https://whispersystems.org/blog/asynchronous-security/

Page 54: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Perfect Forward Secrecy (PFS)

• Mitigates passive attacks by dynamically negotiating different keys each time• Capturing private key no longer becomes an issue• Protect against unforseeable threats to private keys, such as Heartbleed

• Diffie Hellman is the most popular algorithm

Steps

1. Publicly agree on two numbers with specific mathematical properties…

2. Each side choose a secret number and never send it over the network

3. A third number is calculated by each side independently.

4. The calculated result is the same number, which was never sent over the network

Page 55: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

SSL/TLS Example Ciphers

Forward Secrecy:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (0xc027) TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013) TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030) TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (0xc028) TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014)

NOT Forward SecrecyTLS_RSA_WITH_AES_128_GCM_SHA256 (0x9c)TLS_RSA_WITH_AES_128_CBC_SHA256 (0x3c)TLS_RSA_WITH_AES_128_CBC_SHA (0x2f)TLS_RSA_WITH_AES_256_GCM_SHA384 (0x9d)TLS_RSA_WITH_AES_256_CBC_SHA256 (0x3d)

Page 56: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Cipher Suite Explained

TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

TLS_RSA_WITH_AES_128_CBC_SHA

Key Exchange

Common Options:

Key Exchange + AuthN

KX

RSA

ECDHE

DHE

AuthN

RSA

ECDSA

DSS

Encryption

AES

RC4

3DES

MAC

SHA256

SHA1

MD5

PRF

SHA256

SHA384

Protocol*

AuthN

Encryption

Encryption Len Mode PRF

Len Mode MAC

Cipher

Legend

Popular

Phase out

NIST std.

SymmetricAsymmetric

Page 57: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Time to Retire RSA?

• Doesn't support forward secrecy• Uses server key to encrypt the pre-master key created by the customer

• Weakness: Server key (part of the cert) is typically very long lived• RSA (RC4, and DH) are not listed in Suite B, NSA and NIST approved list• Keys grow significantly larger

57

Protection Target Symmetric DH or RSA ECC

05 years protection against agencies 80 1024 160

20 years protection against agencies 112 2048 224

30 years protection against agencies 128 3072 256

Increased defense from quantum computers 256 15360 512

NIST Recommended Key Sizes

Page 58: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

1. Implement

1. HSTS: Make your browser fail close if things are not okay

2. Pinning: Because you cannot trust all CAs in the world

3. Forward Secrecy: mitigate passive attacks

4. OCSP Stamping: better privacy, more efficient and safer

2. Move away from RC4 and RSA: listen to the madman…

A Call To Action

Page 59: CONFidence 2015: Advanced HTTPS Defense Strategies - Jim Manico

Thank You!