The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

66
The Security of SSL Itsik Mantin F5 ASM Team April 2014

Transcript of The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

Page 1: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

The Security of SSL

Itsik Mantin F5 ASM Team

April 2014

Page 2: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

2

Outline

• Crypto Background

• SSL/TLS

• Attacks on SSL

Page 3: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

3

https://www.isecpartners.com/media/106031/ssl_attacks_survey.pdf

Page 4: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

4

Outline

• Crypto Background

• SSL/TLS

• Attacks on SSL

Page 5: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

5

Encryption

Authentication

Cryptography Functions

EncEnc DecDecmplaintext

EKencryption key

DKdecryption key

c=EK(m)ciphertext

DK(c) = m

EavesdroppingAdversary

SignSign VerVerm Plaintext

SKSignature key

VKVerification key

m, sSigned message

TamperingAdversary

Check(m, s)True/False

Page 6: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

6

Symmetric vs. Asymmetric Cryptography

Symmetric-Key Encryption

Message Authentication Code

Asymmetric-Key Encryption

Digital Signature

Symmetric

Asymmetric

Encryption Authentication

Encryption Key = Decryption Key

Signature Key = Verification Key≠≠

SymmetricAsymmetric

Page 7: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

7

HMAC (from hash function)

CBC-MAC (from block cipher)

CMAC (ditto)

RSA (1024+ bit keys)

El-Gamal (same as RSA)

Elliptic Curve Cryptography (200+ bit keys)

RSA (1024+ bit keys)

El-Gamal (same as RSA)

Elliptic Curve Cryptography (200+ bit keys)

Algorithms

Symmetric

Asymmetric

EncryptionAuthentication

Page 8: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

8

Key ExpansionKey Expansion

Block Ciphers and Stream Ciphers

Key Expansion Diffusion

Key[16]

Data In[16]

Round Key[16]

State [16]

Data Out[16]

State [16]

Key Expansion

Key[16] Data In

[]

Key Stream[] Data Out

[]

State [16]

IV[16]Key

[16]

Block Ciphers Stream Ciphers

Page 9: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

9

Block Cipher• Divide input bit stream into n-bit sections, encrypt only that

section

• In a good block cipher, each output bit is a function of all n input bits and all k key bits

Page 10: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

10

Using Block/Stream Ciphers

• Mode of operation: How to encrypt more/less than blocksize bytes?

• ECB/CBC/OFB/CTR/…• GCM (authenticryption)

Block Ciphers

• Key Derivation: How to encrypt multiple messages (NEVER USE SAME KEY TWICE)

• Combine secret key with modifier IV (serial/random/timestamp) to get one-time keys

Stream Ciphers

Page 11: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

11

Encryption Mode (ECB)

• Electronic Code Book (ECB) mode for block ciphers of a long digital sequence

Page 12: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

12

ECB Leak

Page 13: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

13

Encryption Mode (CBC)

• Cipher Block Chaining (CBC) mode for block ciphers • Identical Plaintext prefix Identical Ciphertext prefix

Page 14: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

14

SSL Ciphers

• “100% Secure”• Time complexity of best attack:

2126.1 (!!!)• In all conventional attack models

AES

• Stream cipher (Never use same key twice)• Significant statistical weaknessesRC4

• Not recommendedDES/TDES, Camellia, RC2

Page 15: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

15

Conventional Attack Models

• Attacker knows some plaintexts and their encryption (under same key)Known Plaintext Attack

• Attacker chooses plaintexts and sees their encryption (under same key)Chosen Plaintext Attack

• Attacker chooses ciphertexts and see their decryption (under same key)Chosen Ciphertext Attack

• Same + attacker can change the chosen ciphertexts after seeing some corresponding plaintexts

Adaptive Chosen Ciphertext Attack

Plaintext

Ciphertext

Ciphertext

Plaintext

Page 16: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

16

Crytptanalysis Rule #1

(ALMOST) ANY LEAK OFSECRET INFO CAN BE

AGGREGATED INTO ANEFFECTIVE ATTACK

Page 17: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

17

Asymmetric Key Cryptography

• Sender/receiver have different “power”• Decryption > Encryption• Signature > Verification

Idea

• What: Encryptor cannot Decrypt• Used when: Browser encrypts data for

www.amazon.com• Algorithms: RSA, ECC, El-Gamal• Keys: 400 bits – 2048 bits

Encryption

• What: Verifier cannot Sign• Used when: You-name-it• Algorithms: same as encryption• Keys: same as encryption

Authentication

• Diffie-HellmanKey Exchange

Page 18: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

18

Public Key Cryptosystem

Network

Plain Text Cipher Text Cipher Text

D

Plain Text

PublicKey Secret

Key

E

• Inductive trust:• I trust public keys I have (CA keys)• I trust public keys verifiable by public keys I have

(CA keys; web server key)(aka Chain of Trust)

Trusting public keys

Page 19: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

19

Certificate

an entity’s description (name, type, etc.)

+ entity’s public key

+ expiration date, serial number, etc.

+ CA’s name

+ a signature issued by a CA

Page 20: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

20

Certificates

• Only Trusted Certificate Authorities (CAs) are ”allowed” to create/modify certificates

• Certificates allows:

• Clients to authenticate servers

• Servers to authenticate clients (when used)

• Key exchange without Public Key Server

• Chain-of-trust

• Certificate Revocation List

Page 21: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

21

Security Rule #1

THE CHAIN IS AS STRONGAS ITS WEAKEST LINK

Page 22: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

22

Outline

• Crypto Background

• SSL/TLS

• Attacks on SSL

Page 23: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

23

What is SSL?

Page 24: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

24

SSL and TLS

• Developed by Netscape for https communication• SSL 3.0 (RFC 6101) released in 1996. SSL

• TLS 1.0 (RFC 2246, 1999) enhances SSL3.0.TLS 1.1 (4346, 2006) mitigates CBC attacks

• TLS 1.2 (5246, 2008) removes weak algorithms and backward compatibility flaws

TLS

• Most servers implement SSL3.0 and TLS1.0• TLS1.1 and TLS1.2 have <35% adoption in servers• Latest versions of browsers support TLS1.1/2

(sometimes disabled by default)Adoption

Page 25: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

25

SSL Objectives

• Web server Identification• (Client identification)• Data protection (Encryption and Signature)

Guarantees

• Eavesdropping passive attackers• Active Man-in-the-Middle attackersEven in case of

Page 26: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

26

Man-in-the-Middle

SSL ClientSSL Client SSL ServerSSL Server

BrowserWeb Application

[email protected]!

[email protected]!

DNSPoisoning

ACTIVE

Page 27: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

27

SSL HowStuffWorks (file transfer)

Page 28: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

28

SSL Certificates

Page 29: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

29

Server Identification Security

Verify certificate

chain-of-trust (CA flag,

continuity)

Verify Certificate

Authenticity (signature)

Verify host identityHash Function

Digital signature

Authenticator

Algorithms

Page 30: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

30

Page 31: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

32

Record Protocol Security

MAC Encryption

Authenticator

Algorithms

Page 32: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

33

Outline

• Crypto Background

• SSL/TLS

• Attacks on SSL

Page 33: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

34

Hash Collision Attack - Background

• Efficient MD5 collision finding algorithm• Many Collisions are found• Including Structured Collisions

2004

• Collisions found for X509 certificates with different CA Flag2008

Page 34: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

35

Hash Collision Attack

CERTA

Sig

• Build site certificate CERTA and CA certificate CERTB with same hash

• Ask CA to sign CERTA

• And thus get signature on CERTB

CERTGOOGLE, CERTB

• Verify CERTCA

• Verify CERTB

• Verify B is a CA• Verify CERTGOOGLE

• Trust connection

NEVER USE MD5!!!!!

Hello Google!!!

CertificateAuthority (CA)

CERTA

CERTBCERTA

CERTBCERTGOOGLE

CERTCA

CERTCA

CERTCA

Page 35: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

36

“Validating SSL Certificates in Non-Browser Software”or Host Verification Attack

CERTDEVIL

Sig

HOST=GOOGLE, CERTDEVIL

• Verify CERTDEVIL

• NEVER COMPARE HOST TO CERTUSE HOST NAME

VERIFICATION!!!!!

Hello Google!!!

CERTDEVIL

CERTDEVIL

CERTDEVIL

Page 36: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

37

The Most Dangerous Code in the World: Validating SSL Certificates in Non-Browser Software (Boneh et-al)

• Faulty authenticators (not browsers)

• OpenSSL: Hostname verification must be managed by the application itself, or by data-transport wrapper (ex. cURL)

• “The primary cause of these vulnerabilities is the developers’ misunderstanding of the numerous options, parameters, and return values of SSL libraries.”

• Paper shows applications that depend on standard SSL libraries such as JSSE, OpenSSL, GnuTLS, etc. often accomplish SSL Certificate Validation incorrectly or not at all.

• See http://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf

Page 37: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

38

SSL Security

Verify certificate chain-of-trust (CA

flag, continuity)

Verify Certificate

Authenticity (signature)

Verify host identity

Hash Function

Digital signature

MAC Encryption

Black-box Assumption

Page 38: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

39

Recent SSL Attacks

Padding Oracle

Browser Exploit Against SSL/TLS (BEAST)

Compression Ratio Info-leak Made Easy (CRIME)

Time Info-leak Made Easy (TIME)

LUCKY13

RC4Browser Reconnaissance and

Exfiltration via Adaptive Compression of Hypertext

(BREACH)

Page 39: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

40

HSR Model

Plaintext

Ciphertext

Ciphertext

Plaintext

Plaintext is a combination of secret info and known info (under same key)

(Header + Secret + Random)

NO ALGORITHM GUARANTEES ANY SECURITY IN THE HSR MODEL

Page 40: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

41

HSR Attack

Chosen/Known The Secret Random (unknown)

S*H* R C*

S*H0 R0

S*H1 R1

S*H2 R2

S*H255 R255

C0

C1

C2

C255

16 bytes

1 byte

S*[0]=x if C*==CX

Requires:* SAME KEY* SAME SECRET S*

* HSR

Page 41: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

42

Padding Oracle Attack

Dummy CiphertextOK/NOK

• Oracle “tells” the attacker whether or not a plaintext is properly structured (usually padded)

• FACT: NO ALGORITHM GUARANTEES ANY SECURITY IN THE PADDING ORACLE MODEL

Target Ciphertext

Dummy CiphertextOK/NOK

Dummy CiphertextOK/NOK

Page 42: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

43

The Attack Setup

(1) Login

(3) Request

(2) SessionCookie

DNS Poisoning, or open (malicious) WifiCross-Site Scripting (XSS)

Non-https Response

HttpOnlyApplication Server

User

Page 43: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

44

BEAST (Browser Exploit Against SSL/TLS)

• The CBC IV for each record (except first) is the previous records' last ciphertextFact

• Man in the Middle (MiiM)• Man in the Browser (MiiB)• Fixed key, fixed secretRequires• HSR attack with known/predicted IVThe attack• Arrange for known plaintext (after XOR with predicted

chaining value) H to be combined with one character of unknown data in one block

How it works

Page 44: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

45

BEAST Countermeasures

• Same origin policySOP

• Uses GCM mode of operation (authenticryption)TLS 1.1/1.2

• Send empty MAC record + MACRandomize IV

• Use RC4Key refresh

Page 45: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

46

CRIME (Compression Ratio Info-leak Made Easy)

• Compression ratio depends on similarity of data “segments”

• Thus ‘ababab’ compresses better than ‘ababac’ (DEFLATE/gzip)

• Encryption algorithms don’t claim to hide data lengthFact

• Man in the Middle (MiiM)• Man in the Browser (MiiB)• Fixed key, fixed secretRequires

• Advanced HSR attackThe attack

Page 46: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

47

Page 47: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

48

CRIME (Compression Ratio Info-leak Made Easy)• Attacker crafts the known message part (H)

Use H of the form “ABC*ABC”“ABCDABC”“ABCEABC”“ABCFABC”….

• Following compression, the size indicates the “similarity” of H to S

• If S starts with “X”, “ABCXABC” will give better compression ratio

• Attacker keeps request length close to packet boundaries

• Regardless of cipher (!!!) AES/RC4

How it works

• Disable compressionCountermeasure

Page 48: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

49

TIME (Time Info-leak Made Easy)

• Compression ratio depends on similarity of data “segments”

• Thus ‘ababab’ compresses better than ‘ababac’ (DEFLATE/gzip)

• Encryption algorithms don’t claim to hide data length

Facts

• Man in the Browser (MiiB)• Fixed key, fixed secretRequires

• Client-only CRIME (compression-based HSR)• May work also on compressed responses

(assuming user input reflection)The attack

Page 49: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

50

TIME (Time Info-leak Made Easy)

• Attacker sends HSR compressed messages to server• Attacker concludes compressed message size (number of

packets) through time of response• Attacker keeps messages length (requests/responses)

close to packet boundaries

How it works

• Disabling compression• Server-side countermeasures

Countermeasure

Page 50: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

51

Server-Side Countermeasures

• Adding garbage value to the compressed responseLength Hiding

• Use one-time random values to mask secretsMasking Secrets

• Rate-Limiting, statistics collectionMonitoring

Page 51: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

52

BREACH (Browser Reconnaissance and Exfiltration via Adaptive Compression of Hypertext)

• Responses may include secret info• Responses may also include request info (reflection, e.g.,

in forms)• HSR!!!

Fact• Man in the Browser (MiiB)• Fixed key, fixed secretRequires• Compression-based HSR on the responseThe attack• Attacker sends crafted inputs to server• Server embeds crafted inputs with secret data in

response and then compresses the response• Attacker concludes secret data info from compressed

message size

How it works

• Disabling compression• Server-side countermeasuresCountermeasure

Page 52: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

53

LUCKY13

Padding Oracle Attack

MAC verification is used to prevent padding oracle attack

MAC verification is done only on properly padded messages

Timing analysis indicates padding success

Padding Oracle Attack

Page 53: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

54

LUCKY13

• A target ciphertext• Access to the server• Fixed secret (no assumption on key)Requires• Attacker builds many dummy ciphertexts (from the target

ciphertext), sends to the server and measures response time

• Complexity: 223 (8 million) TLS sessions(!!)

How it works

• Seems to be impracticalCounterm

easure

Page 54: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

55

2012/2013

• As a result of the CRIME/BEAST attacks, experts started to recommend using RC4 instead of AES

• As a stream cipher, RC4 never uses the same key twice

RC4?????

Page 55: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

56

RC4 Weaknesses

• Known to be problematic• Leaks key info into the stream (WEP)• Second byte bias: double probability for being 0• First hundreds of bytes are biased.• Distinguishers of less than a million keystreams

RC4 Initialization

• Throw away the first generated hundreds of bytes• Not done in SSL

The Common Practice

• When encrypting the same message with many RC4 keys, message parts leak (in particular the first bytes)

Message Exposure Attack

Page 56: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

57

RC4 Attack on SSL

• Man in the Middle (MiiM)• Make the browser send many messages, e.g., MiiB• Fixed secret (no assumption on key)Requires• Statistical attack on the plaintext• Works also for varying key!The attack

• MiiB initiates many messages• MiiM collects statistics until plaintext is recoveredHow it works

• Use AESCountermeasu

re

Page 57: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

58

Summary

Target Example Based on TimelinePadding Oracle Steal request

payloadSession cookie Padding Oracle

modelSomewhere in the 1990’s

Browser Exploit Against SSL/TLS (BEAST)

Steal request payload

Session cookie HSR model Described in 2002 (led to TLS1.1), demonstrated in 2011

Compression Ratio Info-leak Made Easy (CRIME)

Steal request payload

Session cookie HSR model Described in 2002, demonstrated in 2011

Time Info-leak Made Easy (TIME)

Steal response payload

CSRF tokenSession Cookie

HSR model Demonstrated in 2012

LUCKY13 Steal request payload

Session cookie Padding Oracle model

Demonstrated in 2012

RC4 Steal request payload

Session cookie Cryptographic weakness

Demonstrated in 2013

Browser Reconnaissance and Exfiltration via Adaptive Compression of Hypertext (BREACH)

Steal response payload

CSRF token Demonstrated in 2013

Page 58: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

59

Heartbleed

Page 59: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

60

SSL Heartbeats

• RFC6520

• used to keep a connection alive without the need to constantly renegotiate the SSL session

Page 60: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

61

The Vulnerability

• Attackers can grab 64K chunks of memory contentsWhat?

• In openssl memory region near the SSL heartbeatWhere?

• As long as the server accepts heartbeat messages, i.e., ANYTIME!!!!

• As many times as the attacker likes!!!!When?

• Not in application layer • Attacker leaves no trailsWhat else?

Page 61: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

62

Vulnerable Info (from worse to worst)

• Private dataSensitive Data

• Session cookies• Session identifiers• Usernames and Passwords

Access control data

• Encryption keys• Record protection keysShort-lived Keys

• Private crypto keysHoly grail

Page 62: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

63

How?

Page 63: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

64

CVE-2014-0160

● Bug was introduced into OpenSSL version 1.0.1 code (beginning of 2012)

● Non-affected versions: <= 1.0.0● Affected version 1.0.1 through 1.0.1f● Bug discovered in April 2014● Patched in 1.0.1g

Page 64: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

65

Recovery is a Headache

● Update openssl version (easy)● Replace all secret info that could have been exposed (how?)

● Certificates private keys● User passwords

Page 65: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

66

References

• Attacks On Ssl: A Comprehensive Study Of Beast, Crime, Time, Breach, Lucky 13 & Rc4 Biaseshttps://www.isecpartners.com/media/106031/ssl_attacks_survey.pdf

• The Most Dangerous Code in the World: Validating SSL Certificates in Non-Browser Softwarehttp://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf

• TLS (Wikipedia)http://en.wikipedia.org/wiki/Transport_Layer_Security

• Heartbleed: http://heartbleed.com/

• Padding Oracle Attack (Wikipedia):http://en.wikipedia.org/wiki/Padding_oracle_attack

• RC4 (Wikipedia)http://en.wikipedia.org/wiki/RC4

Page 66: The Security of SSL Itsik Mantin F5 ASM TeamApril 2014.

Q & A

Find me in Linkedin http://www.linkedin.com/in/imantin