69
Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities Juraj Somorovsky

Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

  • Upload
    others

  • View
    17

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Scalable Scanning and Automatic Classification of TLS Padding Oracle

Vulnerabilities

Juraj Somorovsky

Page 2: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

22

Secure Sockets Layer (SSL), SSLv2

SSLv3

Transport Layer Security

TLS 1.1

TLS 1.2

TLS 1.3

Wagner, Schneier: Analysis of SSLv3

Bleichenbacher’s attack

Padding oracle attack

BEAST, CRIME, BREACH, Lucky 13

1995

2000

2005

2010

2015

TLS History

Padding oracleattack

Page 3: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

3

Paddingoracle attacks

Provablysecure crypto Constant-time

implementations

Man-in-the-Middleattacks

Page 4: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

4

Padding oracleattacks

Page 5: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

About this talk

• Return Of Bleichenbacher’s Oracle Threat (ROBOT). Hanno Böck, Juraj Somorovsky, Craig Young. USENIX Security 2018

• Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod Aviram, Craig Young, Janis Fliegenschmidt, Jörg Schwenk, Yuval Shavitt. USENIX Security 2019

Page 6: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Bleichenbacher’s (padding oracle) attack

2. How we started – Attack on Facebook

3. Performing the scans

4. Responsible disclosure

5. What did we learn

Overview – ROBOT

Designed by Ange Albertini

6

Page 7: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

TLS Protocol (High Level Overview)

1. TLS Handshake• Selection of algorithm, version, extensions

• Key exchange: RSA, (EC)DH, (EC)DHE

2. Encrypted and authenticated data transport

7

Page 8: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

TLS RSA Handshake

8

ClientHello

ServerHello

Certificate

ServerHelloDone

ChangeCipherSpec

(Client-) Finished

ChangeCipherSpec

(Server-) Finished

ClientKeyExchange

RSA encrypted premaster secret

ClientKeyExchange

Page 9: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

RSA PKCS#1 v1.5

• Used to pad and encrypt the premaster secret:• To pad it to the RSA key length

• To add randomization

• Example for TLS 1.2:

9

00 02 [non-zero padding] 00 03 03 [secret]

Encryption block type

0x00 Delimiter

TLS 1.2 version(Yes, very intuitive)

[non-zero padding] [secret]

Page 10: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Bleichenbacher’s Attack

• 1998: Adaptive chosen-ciphertext attack

• Exploits strict RSA PKCS#1 v1.5 padding validation

10

C1

valid/invalid

M = Dec(C)

C2

valid/invalid

Ciphertext C

Starts with 00 02 ?

Page 11: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Bleichenbacher’s Attack

• The attack needs some math (not going into details here)

• “Million message attack” (but could also be faster)

Questions:

11

Page 12: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Creating Bleichenbacher’s Oracle

12

ClientHello

ServerHello

Certificate

ServerHelloDone

ClientKeyExchange’

Server

Decrypt

Error

ChangeCipherSpec

(Client-) Finished:

Bad Record

MAC Alert/

Modified ciphertext

Page 13: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

TLS Countermeasure

13

ClientHello

ServerHello

Certificate

ServerHelloDone

Alert

ChangeCipherSpec

(Client-) Finished:

If the attacker can distinguish valid /invalid PKCS#1 messages, he wins

ClientKeyExchange’

Page 14: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Bleichenbacher’s (padding oracle) attack

2. How we started – Attack on Facebook

3. Performing the scans

4. Responsible disclosure

5. What did we learn

Overview – ROBOT

Designed by Ange Albertini

14

Page 15: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Hanno Found a Weird Behavior of Facebook

15

ClientHello

ServerHello

Certificate

ServerHelloDone

Server

Illegal

Parameter

ChangeCipherSpec

(Client-) Finished:

Bad Record

MAC Alert/

ClientKeyExchange’

Page 16: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Can We Exploit It?

• Idea: It would be funny to sign a message with Facebook’s private key• Yes, signing is possible as well

• Millions of queries needed…would Facebook block us?

• Successful after several tries:

“We hacked Facebook with a

Bleichenbacher Oracle (JS/HB).”

• Facebook fixed

16

Page 17: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Facebook: New Attempt

17

ClientHello

ServerHello

Certificate

ServerHelloDone

Server

ChangeCipherSpec

(Client-) Finished:

/

ClientKeyExchange’

Page 18: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Facebook Fixed Again

• This is interesting. So how about other servers?

18

Page 19: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Bleichenbacher’s (padding oracle) attack

2. How we started – Attack on Facebook

3. Performing the scans

4. Responsible disclosure

5. What did we learn

Overview – ROBOT

Designed by Ange Albertini

19

Page 20: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Let’s Start Scanning

• Careful selection of ClientKeyExchange messages:• Wrong TLS version

• Wrong padding length

• Not starting with 0x00 02

• Full / Shortened TLS handshakes:

20

00 02 [non-zero padding] 00 03 03 [secret]

ClientHello

ServerHello

Certificate

ServerHelloDone

ChangeCipherSpec

(Client-) Finished:

ClientKeyExchange’

ClientHello

ServerHello

Certificate

ServerHelloDone

ChangeCipherSpec

(Client-) Finished:

ClientKeyExchange’

Page 21: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Alexa Top 1 Million Scan

• 2,8 % vulnerable

• PayPal, Apple, ebay, Cisco, …

• Different behaviors…different combinations:

21

Illegal

Parameter

Bad Record

MAC Alert/

TCP connection resets Timeouts

Different alerts

Duplicate alerts Alert/Alert Alert

Handshake

Failure/ Internal

Error/ /..

Page 22: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Bleichenbacher’s (padding oracle) attack

2. How we started – Attack on Facebook

3. Performing the scans

4. Responsible disclosure

5. What did we learn

Overview – ROBOT

Designed by Ange Albertini

22

Page 23: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Who Is Responsible for These Mistakes?

• Reporting is not always that easy …

23

Your server is vulnerable to Bleichenbacher‘s attack.

No worries, we usemillitary grade encryption.

Page 24: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Don’t Fix for Some Vendors … Cisco ACE

• Supports only TLS RSA

• Cisco: We won't fix it, it's out of support for several years

• But there were plenty of webpages still running with these devices

Like cisco.com

24

Page 25: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Identified (Most of) Them

25

Page 26: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Test Tools

• No easily usable test tool for Bleichenbacher attacks available

• Currently implemented in SSL Labs, testssl.sh, TLS-Attacker, tlsfuzzer

26

Page 27: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Bleichenbacher’s (padding oracle) attack

2. How we started – Attack on Facebook

3. Performing the scans

4. Responsible disclosure

5. What did we learn

Overview – ROBOT

Designed by Ange Albertini

27

Page 28: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

What Did We Learn?

• 20 year old attacks still work

• New side channels • Timeouts

• TCP resets

• Duplicated alerts

• How about scanning for other vulnerabilities?

28

Page 29: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

About this talk

• Return Of Bleichenbacher’s Oracle Threat (ROBOT). Hanno Böck, Juraj Somorovsky, Craig Young. USENIX Security 2018

• Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod Aviram, Craig Young, Janis Fliegenschmidt, Jörg Schwenk, Yuval Shavitt. USENIX Security 2019

• Can we effectively scan for CBC oracles at scale?

• Can we also identify vulnerabilities and avoid false positives/negatives?

• Are these vulnerabilities exploitable?

Page 30: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Vaudenay’s (padding oracle) attack

2. Padding oracle attack on TLS

3. Scalable scanning

4. Vulnerability clustering

5. Findings

Overview – Padding Oracle Attacks

30

Page 31: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Cipher Block Chaining (CBC) Encryption

31

...m2m1 ...m3 pad

IV

Block CipherEncryption

C1

Block CipherEncryption

C2

Block CipherEncryption

C3

k k k

Page 32: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Cipher Block Chaining (CBC) Decryption

32

...m2m1 ...m3 pad

IV

Block CipherDecryption

C1

Block CipherDecryption

C2

Block CipherDecryption

C3

k k k

Page 33: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

CBC Malleability

33

IV

Block CipherDecryption

C1

k

m1

CBC decryption

Page 34: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

CBC Malleability: Example

34

Block CipherDecryptionk

0

CBC decryption

1

01

Page 35: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

CBC Malleability: Example

35

Block CipherDecryptionk

0

CBC decryption

1

0101

10

Page 36: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Why Are We Talking about Padding Oracles?

• CBC has a fixed padding structure

• Valid padding values:• 0x01

• 0x02 0x02

• 0x03 0x03 0x03

• ….

36

...m2m1 ...m3 pad

Page 37: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Vaudenay’s Padding Oracle Attack Scenario

• 2002

• Adaptive chosen-ciphertext attack

37

C’

valid/invalid

M = Dec(C)

C’’

valid/invalid

CBC Ciphertext C

Correct padding?0x01

0x02 0x02…

IV C1,...,Cn

IV‘ C1

C1IV‘‘

Page 38: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Vaudenay’s Padding Oracle Attack

38

AES dec

01

IV‘16

x16 = 0x01 ⊕ IV’16

IV’16=0...0xFF

m'16=0...0xFF

Goalx16

IV | C1

m

x

Page 39: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Vaudenay’s Padding Oracle Attack

39

AES dec

0IV‘16

Goalx16

02

IV‘15

X15`

IV’15=0...0xFF

m'15=0...0xFF

0102

IV | C1

m

x

Page 40: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Padding Oracles Exploited in Many Scenarios

40

Cryptography in theWeb: The Case of Cryptographic Design Flaws in ASP.NET

Thai Duong

Vnsecurity/HVAOnline

Ho Chi Minh City, Vietnam

[email protected]

Juliano Rizzo

Netifera

Buenos Aires, Argentina

[email protected]

Abstract—This paper discusses how cryptography is misused

in the secur ity design of a large part of the Web. Our focus

is on ASP.NET, the web application framework developed

by Microsoft that powers 25% of all Internet web sites. We

show that attackers can abuse multiple cryptographic design

flaws to compromise ASP.NET web applications. We descr ibe

practical and highly efficientattacks that allow attackers to

steal cryptographic secret keys and forge authentication tokens

to access sensitive information. The attacks combine decryption

oracles, unauthenticated encryptions, and the reuse of keys for

different encryption purposes. Finally, we give some reasons

why cryptography is often misused in web technologies, and

recommend steps to avoid these mistakes.

Keywords-Cryptography, Application Secur ity, Web secur ity,

Decryption oracle attack, Unauthenticated encryption.

I . INTRODUCTION

At EuroCrypt 2004 Nguyen asked, “How can one know if

what is implemented [in software] is good cryptography?”

[1]. This is an important question because history has shown

that cryptography is often used incorrectly in both open

source and proprietary software (see [1]–[7]).Nevertheless,

despite the important role of the WWW, there is limited

research available from both the cryptographic and web

security communities to answer Nguyen’s question for the

case of cryptographic implementations in web technologies.

This paper shows that badly implemented cryptography is

not limited to traditional software, but is highly pervasive in

web applications as well. Since HTTP is a stateless protocol,

web developers must either manage the user session state

data on the server or push it to the client. For performance

and scalability reasons, web developers tend to go with

the latter method. They want to keep session information

secret, so they correctly turn to cryptography. However,

implementing crypto is error-prone. We observe that unau-

thenticated encryption is often used to encrypt session state

data such as HTTP cookies and view states. Unauthenticated

encryption is dangerous [7]–[11],particularly when used in

an authentication system. The ability to forge a ciphertext

that decrypts to a desired plaintext allows the attacker to

impersonate other users easily [7]. Web developers also tend

to use thesamekeys for different encryption purposes. These

cryptographic errors together make the Web become a gold

mine for chosen-ciphertext attacks.

In this paper, we illustrate this point by examining the case

of cryptographic implementations in web applications based

on ASP.NET [12]. The framework was first released in

January 2002 with version 1.0 of the .NET Framework. As

of September 2010, it is believed that 25% of all the Internet

web sites are developed using ASP.NET.1Here we review

ASP.NET v4.0, which was the current stable version at the

time of submission. Our comments also apply to several

previous versions of ASP.NET.

We observe several cryptographic flaws in ASP.NET v4.0.

The most serious flaw (which turns out to have been present

in ASP.NET for almost three years) is a consequence of

unauthenticated encryption. We present two practical and

highly efficient attacks that allow attackers to steal crypto-

graphic secret keys, forge authentication tokens and destroy

the security model of every ASP.NET v4.0 application.

Both are chosen-ciphertext attacks that combine decryption

oracles similar to thepadding oracle introduced by Vaudenay

at EuroCrypt ’02 [13] and the CBC-R technique that Rizzo

and Duong demonstrated at USENIX WOOT ’10 [14]. The

novelty of these attacks is that not only can the attacker

decrypt secret data in ASP.NET, but he also can create

ciphertexts that after being decrypted and processed by

ASP.NET, allow him to retrieve sensitive information.

The rest of the paper is organized as follows. In Section II,

we givean overview of ASP.NET v4.0 and the cryptographic

vulnerabilities in the framework. In Section III, we provide

sufficient background on decryption oracle attacks and the

CBC-R technique to make the paper self-contained. In

Section IV, we describe our first attack exploiting padding

oracles in the framework. In Section V, we describe our

second attack, which is faster than the first attack and does

not require a padding oracle. In Section VI, we consider the

practical impact of our attacks as well as countermeasures

that prevent them. Our reflections on why cryptography is

often misused in web technologies and our recommendations

can be found in Section VII.

1See http://trends.builtwith.com/framework.

2011 IEEE Symposium on Security and Privacy

Unrecognized Copyright Information

DOI 10.1109/SP.2011.42

481

2011 IEEE Symposium on Security and Privacy

1081-6011/11 $26.00 © 2011 IEEE

DOI 10.1109/SP.2011.42

481

On the (In)Security of IPsec in MAC-then-EncryptConfigurations

Jean Paul Degabriele∗

Information Security GroupRoyal Holloway, University of London

Egham, Surrey, TW20 0EX, UK

[email protected]

Kenneth G. Paterson†

Information Security GroupRoyal Holloway, University of London

Egham, Surrey, TW20 0EX, UK

[email protected]

ABSTRACT

IPsec allows a hugeamount of flexibility in theways in whichit s component cryptographic mechanisms can be combined

to build a secure communicat ions service. This may be goodfor support ing different security requirements but is poten-t ially bad for security. We demonst rate the reality of this

by describing efficient , plaintext -recovering at tacks againstall configurat ions of IPsec in which integrity protect ion isapplied prior to encrypt ion – so-called MAC-then-encryptconfigurat ions. We report on the implementat ion of our at -

tacks against a specific IPsec implementat ion, and reflect on

the implicat ions of our at tacks for real-world IPsec deploy-

ments as well as for theoret ical cryptography.

Categoriesand Subject Descriptors

C.2.0 [Com put er -Com municat ion N et wor ks]: General—Secur i ty and protection (e.g., firewal ls)

General Terms

Security

Keywords

IPsec, ESP, AH, MAC-then-encrypt , Traffic Flow Confiden-

t iality, Fragmentat ion

1. INTRODUCTIONIPsec is a notoriously complex protocol suite, but one of

great importance in today’s Internet where it is deployed

∗This author ’s research is funded by Vodafone Group Ser-vices Limited, a Thomas Holloway Research Studentship,and theSt rategic Educat ional Pathways Scholarship Scheme(Malta), part -financed by the European Union – EuropeanSocial Fund.†This author ’s research supported by an EPSRC LeadershipFellowship, EP/ H005455/ 1.

Permission to make digital or hard copies of all or part of this work forpersonal or classroom use is granted without fee provided that copies arenot made or distributed for profit or commercial advantage and that copiesbear this notice and the full citation on the first page. To copy otherwise, torepublish, to post on servers or to redistribute to lists, requires prior specificpermission and/or a fee.CCS’10, October 4–8, 2010, Chicago, Illinois, USA.Copyright 2010 ACM 978-1-4503-0244-9/10/10 ...$10.00.

widely to build Virtual Private Networks (VPNs) and se-

cure remote access solut ions. IPsec offers security at the

IP layer of the TCP/ IP protocol stack, meaning that IPsecprovides cryptographic protect ion for IP packets (or theirpayloads). Part of IPsec’s complexity arises from a delib-erate at tempt by IPsec’s designers to provide a flexible andhighly configurable approach to providing security services

for IP t raffic.The RFCsspecifying themajor component protocols ESP,

AH, IKE [14, 15, 9] and that describing the IPsec architec-ture [13] offer only limited guidance to end users about howbest to configure IPsec to achieve their desired security goals.Moreover, lit t le security analysis of IPsec seems to havebeen

published. In part icular, whilst it is by now well-establishedthat using ESP in “ encrypt ion-only” configurat ions is inse-cure in general [1, 18, 5], there appears to have been no

systematic security evaluat ion of the many different waysof combining encrypt ion and integrity protect ion that are

allowed by IPsec:

• ESP may provide its own integrity protect ion, in which

case it is provided by a MAC algorithm that is appliedafter ESP’s encrypt ion – an encrypt -then-MAC con-st ruct ion.

• Alternat ively, AH can be used to provide the protec-

t ion, again using a MAC algorithm, though with theMAC algorithm having a greater scope than in ESP. Inthis case, packets may be first integrity protected byAH and then encrypted using ESP, or first encrypted

by ESP and then integrity protected by AH (wherenow the extended scope of AH’s integrity protect ion

means that more fields of the IP header are protectedthan would be the case with ESP-provided integrityprotect ion).

• I t is even possible to achieve a MAC-then-encrypt con-st ruct ion using two layers of ESP processing.

• Further, the current version of ESP allows combined-

mode algorithms to be used, wherein encrypt ion andintegrity protect ion are rolled into a single processingstep.

• In all of the aboveconfigurat ions, AH and/ or ESP may

each be applied in either tunnel mode or t ransportmode.

• To add a final dimension, both AH and ESP allow

sequence number checking to be performed as an op-

Page 41: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Vaudenay’s (padding oracle) attack

2. Padding oracle attack on TLS

3. Scalable scanning

4. Vulnerability clustering

5. Findings

Overview – Padding Oracle Attacks

41

Page 42: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

CBC in TLS

• Protects TLS records after a successful handshake

• Available since SSLv2

• Used in many cipher suites:• TLS_RSA_WITH_AES_256_CBC_SHA

• TLS_RSA_WITH_3DES_EDE_CBC_SHA

• …

Page 43: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

AES-CBC in TLS

• MAC-Pad-Encrypt

• Example:• Two blocks

• Message: Hello

• MAC size: 20 bytes (SHA-1)

• Padding size: 32 – 5 – 20 = 7

H e l l o

06 06 06 06 06 06 06

pad

mac

Page 44: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Preventing Padding Oracles

44

Server

Valid / Invalid

Ciphertext

Decryption failed

Challenge: not to reveal padding validitySame error message

Page 45: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Triggering a Typical Padding Oracle

45

H e l l o 06 06 06 06 06 06 06

pad

mac

H e l l o 06 06 06 06 06 06 06

05

C

BAD_RECORD_MAC / DECRYPT_ERROR

Page 46: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Botan (CVE-2015-7824)

• Bad padding: BAD_RECORD_MAC

• Bad MAC: BAD_RECORD_MAC

• Special case: DECODING_ERROR

46

H e l l o 06 06 06 06 06 06 06

pad

mac

05

H e l l o 06 06 06 06 06 06 06

0c 0c 0c 0c 0c 0c 0c0c 0c 0c 0c 0c 0c 0c

Not enough bytes for an HMAC (19)

Page 47: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

OpenSSL (CVE-2016-2107)

• Bad MAC / padding: BAD_RECORD_MAC

• Bad MAC: RECORD_OVERFLOW

• Introduced after patching Lucky13

• Only available in AES-NI supported cipher suites:• TLS_RSA_WITH_AES_*_CBC_SHA• TLS_RSA_WITH_AES_*_CBC_SHA256

47

H e l l o 06 06 06 06 06 06 06

pad

mac

05

H e l l o 1F 1F 1F 1F 1F 1F 1F1F 1F 1F 1F 1F 1F 1F1F 1F 1F 1F 1F 1F 1F 1F 1F1F 1F 1F 1F 1F 1F 1F1F 1F

Page 48: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

POODLE

• Bad MAC / last padding byte: BAD_RECORD_MAC

• Arbitrary padding bytes: no error

48

H e l l o 06 06 06 06 06 06 06

pad

mac

05

H e l l o 06 06 06 06 06 06 06

Everything ok. SSLv3 uses a different padding scheme.

Page 49: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Vaudenay’s (padding oracle) attack

2. Padding oracle attack on TLS

3. Scalable scanning

4. Vulnerability clustering

5. Findings

Overview – Padding Oracle Attacks

49

Page 50: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Goals

• Generate test vectors• Use knowledge from previous works

• Scan Alexa 1M

• Identify vulnerabilities and report them

50

Page 51: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Test Vector Generation

• Malformed TLS records (25)• Flipping bits in MAC

• Flipping bits in padding

• Overlong padding

• Using all … • TLS versions (see the SSLv3 POODLE vulnerability)

• CBC cipher suites (see CVE-2016-2107)

51

H e l l o 06 06 06 06 06 06 061F 1F 1F 1F 1F 1F 1F1F 1F 1F 1F 1F 1F 1F1F 1F 1F 1F 1F 1F 1F 1F 1F1F 1F 1F 1F 1F 1F 1F1F 1F

25 malformed records in total

Page 52: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Test Vector Reduction

• Problem example:• 25 malformed records

• Server supports TLS 1.0 and TLS 1.1 with 10 CBC cipher suites

• Results in 500 TLS handshakes (without rescanning)

• Can we identify all vulnerabilities with less vectors?• Pre-scanning 50k random hosts on port 443

• Reducing the set of malformed records from 25 to 4

• (still scanning with all TLS versions and cipher suites)

52

Page 53: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Alexa Top 1 Million Scan

• Based on our TLS-Attacker: • https://github.com/RUB-NDS/TLS-Attacker

• Supported by redis and mongoDB

• 72 hours, 627,493 hosts supporting CBC cipher suites

• 18,257 vulnerable• Observed different TLS alerts, TCP resets, timeouts, …

53

Page 54: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Malformed Records Triggering Different Fingerprints

54

Different malformed records

Response:• Fatal BAD_RECORD_MAC• Warning• Connection close

Response:• Fatal BAD_RECORD_MAC• Warning• Timeout

How many different fingerprints do we have?

Page 55: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Malformed Records Triggering Different Fingerprints

55

93 Different Fingerprints

Page 56: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Malformed Records Triggering Different Fingerprints

56

Problem: which vendors to notify?

Page 57: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Vaudenay’s (padding oracle) attack

2. Padding oracle attack on TLS

3. Scalable scanning

4. Vulnerability clustering

5. Findings

Overview – Padding Oracle Attacks

57

Page 58: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Vulnerability Clustering

58

A

B

TLS_RSA_WITH_AES_256_CBC_SHA

TLS_RSA_WITH_AES_256_CBC_SHA

TLS_RSA_WITH_3DES_EDE_CBC_SHA

Are A and B implementations equal?

Page 59: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Vulnerability Clustering

59

A

B

C

TLS_RSA_WITH_AES_256_CBC_SHA

TLS_RSA_WITH_AES_256_CBC_SHA

TLS_RSA_WITH_3DES_EDE_CBC_SHA

TLS_RSA_WITH_AES_256_CBC_SHA

TLS_RSA_WITH_3DES_EDE_CBC_SHA

Page 60: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Vulnerability Clustering

60

A

B

C

TLS_RSA_WITH_AES_256_CBC_SHA

TLS_RSA_WITH_AES_256_CBC_SHA

TLS_RSA_WITH_3DES_EDE_CBC_SHA

TLS_RSA_WITH_AES_256_CBC_SHA

TLS_RSA_WITH_3DES_EDE_CBC_SHA

What do we know?• B != C• A and B could be equal• A and C could be equal

Page 61: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Vulnerability Clustering: Usage of Force Atlas2

• Two-dimensional graph

• Edges between equally behaving servers

• Contains as few crossing edges as possible

61

A

What do we know?• B != C• A and B could be equal• A and C could be equal

B C

D E

Page 62: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Vulnerability Clustering: Example

62

TLS_RSA_WITH_AES_128_CBC_SHA

TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA

TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA

TLS_RSA_WITH_AES_128_CBC_SHA

TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA

Page 63: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

1. Vaudenay’s (padding oracle) attack

2. Padding oracle attack on TLS

3. Scalable scanning

4. Vulnerability clustering

5. Findings

Overview – Padding Oracle Attacks

63

Page 64: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Results

• https://github.com/RUB-NDS/TLS-Padding-Oracles

• OpenSSL. CVE-2019-1559.

• Citrix. CVE-2019-6485.

• F5 TMM TLS virtual server. CVE-2019-6593.

• SonicWall SonicOs. CVE-2019-7477

64

Page 65: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

OpenSSL (CVE-2019-1559)

• Identified with the help of the Amazon security team

• Only in stitched cipher suites• Highly optimized, no AES-NI

65

Response:• Fatal BAD_RECORD_MAC• Warning• Connection close

Response:• Fatal BAD_RECORD_MAC• Warning• Timeout

Page 66: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

OpenSSL (CVE-2019-1559)

• Bad padding: BAD_RECORD_MAC, Connection Close

• Bad MAC: BAD_RECORD_MAC, Connection Close

• 0-length record: BAD_RECORD_MAC, Timeout

66

H e l l o 06 06 06 06 06 06 06

pad

mac

05

H e l l o 06 06 06 06 06 06 06

0c 0b 0b 0b 0b 0b 0b0b 0b 0b 0b 0b 0b

Page 67: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Disclaimer

• CBC padding oracle attacks are much harder to exploit …• BEAST scenario needed

• Active MitM attacker

• …

67

Page 68: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Demo: TLS-Scanner

68

Page 69: Scalable Scanning and Automatic Classification of …...•Scalable Scanning and Automatic Classification of TLS Padding Oracle Vulnerabilities. Robert Merget, Juraj Somorovsky, Nimrod

Conclusions

• 20 years old attacks still work

• New side-channels (timeouts, TCP resets, …)

• New attacks can be found by IPv4 scanning

• Disable RSA and CBC cipher suites (not used in TLS 1.3)

• Stop using RSA PKCS#1 v1.5• Use elliptic curves (or RSA-OAEP if RSA needed)

• Stop using CBC• Use authenticated modes of operation like AES-GCM

69