Padding Oracle Attack for non-standard PKCS#1 v1.5 Can non-standard - - PowerPoint PPT Presentation

padding oracle attack for non standard pkcs 1 v1 5
SMART_READER_LITE
LIVE PREVIEW

Padding Oracle Attack for non-standard PKCS#1 v1.5 Can non-standard - - PowerPoint PPT Presentation

Padding Oracle Attack for non-standard PKCS#1 v1.5 Can non-standard implementation provide us a shelter? Si Gao Hua Chen Limin Fan Trusted Computing and Information Assurance Laboratory, Institute of Software, Chinese Academy of Sciences


slide-1
SLIDE 1

Padding Oracle Attack for non-standard PKCS#1 v1.5

Can non-standard implementation provide us a shelter? Si Gao Hua Chen Limin Fan

Trusted Computing and Information Assurance Laboratory, Institute of Software, Chinese Academy of Sciences

November 20, 2013

1 of 29

slide-2
SLIDE 2

Outline

Introduction Basic Problem Motivation Non-standard implementation study Case I Case II Categorize Non-standard implementation Further improvement* Summary

2 of 29

slide-3
SLIDE 3

Outline

Introduction Basic Problem Motivation Non-standard implementation study Case I Case II Categorize Non-standard implementation Further improvement* Summary

2 of 29

slide-4
SLIDE 4

Outline

Introduction Basic Problem Motivation Non-standard implementation study Case I Case II Categorize Non-standard implementation Further improvement* Summary

2 of 29

slide-5
SLIDE 5

PKCS#1 v1.5

PKCS#1 v1.5 coding for encryption

A valid “padded message” should satisfy:

a) 00 02 00 Padding String Data Block =0x00

3 of 29

slide-6
SLIDE 6

PKCS#1 v1.5

PKCS#1 v1.5 coding for encryption

A valid “padded message” should satisfy:

b) 00 02 00 Padding String Data Block =0x02

3 of 29

slide-7
SLIDE 7

PKCS#1 v1.5

PKCS#1 v1.5 coding for encryption

A valid “padded message” should satisfy:

00 02 00 Padding String Data Block length 8? find a 0x00 ? Search for the first 0x00 c) d)

3 of 29

slide-8
SLIDE 8

Bleichenbacher’s Attack

  • From implementation flaws, attackers might have access to an

Oracle, which tells whether certain ciphertext is valid

  • Pick a random r, if c′ = r ec mod n is a valid ciphertext, we know

rm mod n starts with 00 02

  • rm mod n starts with 00 02 limits m to a smaller interval
  • Repeat until we can determine the value of m

4 of 29

slide-9
SLIDE 9

Bleichenbacher’s Attack

  • From implementation flaws, attackers might have access to an

Oracle, which tells whether certain ciphertext is valid

  • Significantly improved in 2012(For RSA-1024, Mean:49001,

Median:14501) [Bardou et al., 2012]

  • Focus on the 00 02 in the start, ignore other conditions
  • Easy countermeasure: OAEP

4 of 29

slide-10
SLIDE 10

PKCS#1 v1.5 still matters

Only for backward compatibility, yet widespread

  • More usage than OAEP [European Network of Excellence in

Cryptology II, 2012]

  • TLS doesn’t support OAEP yet
  • “Backward compatibility Attacks” [Jager et al., 2013]

5 of 29

slide-11
SLIDE 11

This work is about...

Implementations don’t follow the standard step by step

  • Can implementation tricks provide a “shelter ” ?

6 of 29

slide-12
SLIDE 12

More specifically...

  • For instance, in decryption process, after RSA decryption:

XX XX 00 Padding String Data Block find a 0x00 ? Search for the first 0x00 d)

  • “efficient” way to implement PKCS #1 v1.5
  • Bleichenbacher’s Attack doesn’t work (no 00 02)
  • leakage still exists, although very vague
  • not secure, but might be good enough

7 of 29

slide-13
SLIDE 13

Main topic

Question Can this kind of implementation tricks serve as a temporary “shelter”?

8 of 29

slide-14
SLIDE 14

Outline

Introduction Basic Problem Motivation Non-standard implementation study Case I Case II Categorize Non-standard implementation Further improvement* Summary

9 of 29

slide-15
SLIDE 15

Case I: Basic idea

XX XX 00 Padding String Data Block find a 0x00 ? Search for the first 0x00 d)

  • Oracle tells us whether rm mod n has a 0 byte
  • No clear expression available (typically, this part of the

information is ignored by Bleichenbacher’s Attack)

Straightforward idea

Can we get some clear information from this Oracle?

10 of 29

slide-16
SLIDE 16

Property of this Oracle

If m has a 0 byte, 256m mod n must has a 0 byte, unless 256m > n. Thus

Property 1

Let c = me mod n, c′ = 256ec mod n, if O(c) = T and O(c′) = F, we can conclude that 256m > n Extended to [rn, (r + 1)n):

Property 2

Let c1 = (sm)e mod n, c2 = (256sm)e mod n ,sm ∈ [rn, (r + 1)n), if O(c1) = T and O(c2) = F, we can conclude that sm > rn +

1 256n

11 of 29

slide-17
SLIDE 17

Simple idea, but.......

Implementation requirements:

  • The 0 byte in the two most significant positions doesn’t count

(00 02).

  • The 0 byte in the least significant position doesn’t count (no

data block).

XX XX Non-zero bytes find a 0x00 Search for the first 0x00 00 XX 00 Non-zero bytes Search for the first 0x00 00 doesn't count doesn't count 256m mod n m 12 of 29

slide-18
SLIDE 18

Further analysis

  • Even if we take both m and 256m mod n into consideration, we

can not guarantee anything from a single Oracle access.

  • The problem above rarely happens: if we can collect some

points near m and get corresponding replies from the Oracle, we can decide whether 256m > n through probability analysis

13 of 29

slide-19
SLIDE 19

More specifically...

PO(c) PO(c′) 256m < n 256m > n T T 38.21% 14.86% T F 0.25% 23.50% F T 0.23% 23.76% F F 61.31% 37.88%

  • Clearly, if we collect some points near m, and find many

O(c) = O(c′), we can conclude that 256m > n.

14 of 29

slide-20
SLIDE 20

Distinguish algorithm

Require: Padding Oracle PO, ciphertext c, m’s current interval [a, b], r compute the possible interval of s [smin, smax] smin =

  • (r+ 1

256)n

b

  • , smax =
  • (r+ 1

256)n

a

  • —— Make sure sm is near
  • r +

1 256

  • n

while s < smax do collect some sample points near current s, c1 = sec mod n, c2 = (256s)ec mod n call PO to calculate Pr(PO(c1) = PO(c2)) if Pr(PO(c1) = PO(c2)) > threshold then break else s++ end if end while a′ =

  • r+ 1

256 n

s+block+1

  • , b′ =
  • r+ 1

256 n

s−block

  • return [a′, b′]

15 of 29

slide-21
SLIDE 21

Distinguish algorithm

Require: Padding Oracle PO, ciphertext c, m’s current interval [a, b], r compute the possible interval of s [smin, smax] smin =

  • (r+ 1

256)n

b

  • , smax =
  • (r+ 1

256)n

a

  • while s < smax do

collect some sample points near current s, c1 = sec mod n, c2 = (256s)ec mod n call PO to calculate Pr(PO(c1) = PO(c2)) if Pr(PO(c1) = PO(c2)) > threshold then break —— This tells us sm >

  • r +

1 256

  • n

else s++ end if end while a′ =

  • r+ 1

256 n

s+block+1

  • , b′ =
  • r+ 1

256 n

s−block

  • return [a′, b′]

15 of 29

slide-22
SLIDE 22

Distinguish algorithm

Require: Padding Oracle PO, ciphertext c, m’s current interval [a, b], r compute the possible interval of s [smin, smax] smin =

  • (r+ 1

256)n

b

  • , smax =
  • (r+ 1

256)n

a

  • while s < smax do

collect some sample points near current s, c1 = sec mod n, c2 = (256s)ec mod n call PO to calculate Pr(PO(c1) = PO(c2)) if Pr(PO(c1) = PO(c2)) > threshold then break else s++ end if end while a′ =

  • r+ 1

256 n

s+block+1

  • , b′ =
  • r+ 1

256 n

s−block

  • —— Update the interval of m

return [a′, b′]

15 of 29

slide-23
SLIDE 23

Distinguish algorithm

Require: Padding Oracle PO, ciphertext c, m’s current interval [a, b], r compute the possible interval of s [smin, smax] smin =

  • (r+ 1

256)n

b

  • , smax =
  • (r+ 1

256)n

a

  • while s < smax do

collect some sample points near current s, c1 = sec mod n, c2 = (256s)ec mod n call PO to calculate Pr(PO(c1) = PO(c2)) if Pr(PO(c1) = PO(c2)) > threshold then break else s++ end if end while a′ =

  • r+ 1

256 n

s+block+1

  • , b′ =
  • r+ 1

256 n

s−block

  • return [a′, b′]

Repeat with larger r, until there is only one m left in [a,b]

15 of 29

slide-24
SLIDE 24

Some other troubles...

“stuck ”problem

  • After the first round(r=0), [smin, smax] is too small
  • No enough points for analysis(stuck)

Solution:

  • multiplier 2: more powerful, less efficient

PO(c) PO(c′) 2m < n 2m > n T T 25.19% 15.01% T F 13.20% 23.75% F T 13.35% 23.60% F F 48.25% 37.64%

16 of 29

slide-25
SLIDE 25

Some other troubles...

“stuck ”problem

  • After the first round(r=0), [smin, smax] is too small
  • No enough points for analysis(stuck)

Solution:

  • multiplier 2: more powerful, less efficient

PO(c) PO(c′) 2m < n 2m > n T T 25.19% 15.01% T F 13.20% 23.75% F T 13.35% 23.60% F F 48.25% 37.64%

16 of 29

slide-26
SLIDE 26

Complete attack for case I

Complete attack algorithm:

  • Prefer multiply 256 method (efficiency)
  • Typically, only the first few(4-5) rounds need multiply 2 method
  • About 0.11 million oracle accesses for RSA-1024 (stable

performance) Works when implementation also checks PS length

XX XX 00 Padding String Data Block find a 0x00 ? Search for the first 0x00 d) c) length8 ?

17 of 29

slide-27
SLIDE 27

Outline

Introduction Basic Problem Motivation Non-standard implementation study Case I Case II Categorize Non-standard implementation Further improvement* Summary

18 of 29

slide-28
SLIDE 28

Another case...

Now let’s move on

00 XX 00 Padding String Data Block =0x00? find a 0x00 ? Search for the first 0x00 a) d)

  • much easier to analyze (0x00 in the start)
  • Any m passes the check means m must start with 0x00

19 of 29

slide-29
SLIDE 29

Oracle Analysis

Let T = 28(k−1), Oracle’s behavior:

rn (r+1)n rn+T T F T F F F F

  • F

F

  • F
  • F

Search for the first T Search for the first T

  • For each r, both rn and rn + T can be used
  • Similar as before, need both to complete the attack
  • Much more efficient, 12 000 oracle access for RSA-1024

(stable performance)

  • Also works when PS length is checked

20 of 29

slide-30
SLIDE 30

Outline

Introduction Basic Problem Motivation Non-standard implementation study Case I Case II Categorize Non-standard implementation Further improvement* Summary

21 of 29

slide-31
SLIDE 31

Categorize Non-standard implementation

Stronger and weaker:

  • a) and b) are (00 02) stronger checks (more leakage)
  • Relatively, c) and d) are weaker (less leakage)
  • stronger checks dominate the corresponding analysis
  • Thus, Non-standard implementations can be divided into 4

Groups:

  • Group I (none): case I
  • Group II (only 02): probably variant of Bleichenbacher’s Attack
  • Group III (only 00): case II
  • Group IV (both): Bleichenbacher’s Attack

22 of 29

slide-32
SLIDE 32

Global view

! " # $% & ' () * + (+ ,

  • .
  • /

,- 1 ) + 2 3 /

  • 45

6 6 + 2 ) , 7 / , 8.

  • .

5 9. * 8 6 /

  • 4

( : 1 ) + ; , 7 /

  • /

, 2 < 6 = ) > ? . / * . @ * + >

  • .

5 9> * 8 6 /

  • 4

( A + 6 B 6 (. , 5 + . C @ C 5 C 7 C D+ 7 / . , D+ . , E F < 6 = )' < 6 = )' >

  • .

5 9 E E GH I JE E HK L M I F N , , + 5 + 2 2 . 6 1 O O G F F < 6 = )' >

  • .

5 9 E E EM K JE E PG G E P F < 6 = )' ' Q . 6 / . ,

  • B

R * + / 5 4 + , @ . 5 4 + 6 S 2 .

  • .

5 9 O O H F F T F F L F F F M F < 6 = )' ' ' D. , 8 + 6 S 2 .

  • .

5 9 EE T M EE L P K F F < 6 = )' ' ' >

  • .

5 9 E IM P G E IM L M E J F F N , , + 5 + 2 2 . 6 1 O O E E F F F < 6 = )' ' ' >

  • .

5 9 E GJ P L E GJ H M E I F F < 6 = )' Q R * + / 5 4 + , @ . 5 4 + 6 S 2 .

  • .

5 9 PL T I E PH G I E G F F F R * + / 5 4 + , @ . 5 4 + 6 S 2 .

  • .

5 9 E HG E H K IM I J E P F F F N , , + 5 + 2 2 . 6 1 O O E H F F F F R * + / 5 4 + , @ . 5 4 + 6 S 2 .

  • .

5 9 E LP L GE J PM G K

23 of 29

slide-33
SLIDE 33

Outline

Introduction Basic Problem Motivation Non-standard implementation study Case I Case II Categorize Non-standard implementation Further improvement* Summary

24 of 29

slide-34
SLIDE 34

Further improvement*

Although practical, our attack for case I isn’t efficient enough:

  • Idea comes from Dr. Cheng Chen
  • push the “0x00 ”to the start

00 00 00 Data Block find a 0x00 d)

  • Let C = 28(k−3), k is the byte length of n

25 of 29

slide-35
SLIDE 35

Further improvement*

Although practical, our attack for case I isn’t efficient enough:

  • Idea comes from Dr. Cheng Chen
  • push the “0x00 ”to the start
  • Let C = 28(k−3), k is the byte length of n

rn (r+1)n rn+C F T T T F F

  • F

F

  • F
  • T

T T

25 of 29

slide-36
SLIDE 36

Further improvement

  • Looks like case II, yet slightly different from case II
  • Similar to the Step 2.c in Bleichenbacher’s attack

rn (r+1)n rn+C F T T T F F

  • F

F

  • F
  • T

T T

m(rn+C)/b m(rn+C)/a Any F means sm>rn+C

  • To ensure this works, start with several rounds of our case I

attack

  • about 20 000 oracle access (80% off, stable)
  • Also works when implementation check PS length (more

rounds of case I attack)

26 of 29

slide-37
SLIDE 37

Outline

Introduction Basic Problem Motivation Non-standard implementation study Case I Case II Categorize Non-standard implementation Further improvement* Summary

27 of 29

slide-38
SLIDE 38

Summary

  • We propose analysis for two types of non-standard

implementations

  • Together with Bleichenbacher’s attack, we can conclude most
  • f non-standard implementations are vulnerable
  • Moreover, some non-standard implementations are even worse!

28 of 29

slide-39
SLIDE 39

THE END

Thanks for listening!

29 of 29

slide-40
SLIDE 40

Bardou, Romain, Focardi, Riccardo, Kawamoto, Yusuke, Simionato, Lorenzo, Steel, Graham, & Tsay, Joe-Kai. 2012. Efficient Padding Oracle Attacks on Cryptographic Hardware. Pages 608–625 of: Safavi-Naini, Reihaneh, & Canetti, Ran (eds), Advances in Cryptology — CRYPTO 2012. Lecture Notes in Computer Science, vol. 7417. Springer Berlin Heidelberg. European Network of Excellence in Cryptology II. 2012 (30 Sept). ECRYPT II Yearly Report on Algorithms and Keysizes (2011-2012). Tech. rept. European Network of Excellence in Cryptology II. Jager, Tibor, Paterson, Kenneth G., & Somorovsky, Juraj. 2013. One Bad Apple: Backwards Compatibility Attacks on State-of-the-Art Cryptography. In: NDSS Symposium 2013.

29 of 29