Side-channels Tom Ristenpart CS 6431. Pick target(s) Choose launch parameters for malicious VMs Each VM checks for co-residence Frequently achieve advantageous.

Slides:



Advertisements
Similar presentations
Side-Channel Attacks on RSA with CRT Weakness of RSA Alexander Kozak Jared Vanderbeck.
Advertisements

Cross-VM Side Channels and Their Use to Extract Private Keys
Lecture 4: Cloud Computing Security: a first look Xiaowei Yang (Duke University)
Hey, You, Get Off of My Cloud: Exploring Information Leakage in Third-Party Compute Clouds Yan Qiang,
Virtualization and Cloud Computing. Definition Virtualization is the ability to run multiple operating systems on a single physical system and share the.
Data encryption with big prime numbers
Public Clouds (EC2, Azure, Rackspace, …) VM Multi-tenancy Different customers’ virtual machines (VMs) share same server Provider: Why multi-tenancy? Improved.
Computer Science CSC 405By Dr. Peng Ning1 CSC 405 Introduction to Computer Security Topic 2. Basic Cryptography (Part II)
Side-Channel Attack on OpenSSL ECDSA Naomi BengerJoop van de Pol Nigel Smart Yuval Yarom 1.
7. Asymmetric encryption-
By Christopher Moran, Nicoara Talpes 1.  Solution is addressed to VMs that are web servers  Web servers should not have confidential information anyway.
Session 4 Asymmetric ciphers.
Remote Timing Attacks -Rashmi Kukanur. Agenda  Timing Attacks  Case Study : –David Brumley –Dan Boneh  Defenses.
RSA Attacks 1 RSA Implementation Attacks RSA Attacks 2 RSA  RSA o Public key: (e,N) o Private key: d  Encrypt M C = M e (mod N)  Decrypt C M = C d.
ECOMMERCE TECHNOLOGY FALL 2003 COPYRIGHT © 2003 MICHAEL I. SHAMOS Cryptography.
Side-Channel Attacks on Smart Cards. Timing Analysis Cryptosystems take different amount of time to process different inputs. Performance optimisations.
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
CSE331: Introduction to Networks and Security Lecture 20 Fall 2002.
Scheduler-based Defenses against Cross-VM Side- channels Venkat(anathan) Varadarajan, Thomas Ristenpart, and Michael Swift 1 D EPARTMENT OF C OMPUTER S.
Radu Muresan CODES+ISSS'04, September 8-10, 2004, Stockholm, Sweden1 Current Flattening in Software and Hardware for Security Applications Authors: R.
Side-Channel Attack: timing attack Hiroki Morimoto.
Authors: Thomas Ristenpart, et at.
Computer Science CSC 474Dr. Peng Ning1 CSC 474 Information Systems Security Topic 2.5 Public Key Algorithms.
Dan Boneh Public Key Encryption from trapdoor permutations The RSA trapdoor permutation Online Cryptography Course Dan Boneh.
Dan Boneh Public Key Encryption from trapdoor permutations RSA in practice Online Cryptography Course Dan Boneh.
1 CIS 5371 Cryptography 8. Asymmetric encryption-.
Topic 18: RSA Implementation and Security
The RSA Algorithm Rocky K. C. Chang, March
Hey, You, Get Off of My Cloud: Exploring Information Leakage in Third-Party Compute Clouds Written by Thomas Ristenpart Eran Tromer Hovav Shacham Stehan.
Cryptography Lecture 8 Stefan Dziembowski
RSA Ramki Thurimella.
Ragib Hasan University of Alabama at Birmingham CS 491/691/791 Fall 2012 Lecture 4 09/10/2013 Security and Privacy in Cloud Computing.
9th IMA Conference on Cryptography & Coding Dec 2003 More Detail for a Combined Timing and Power Attack against Implementations of RSA Werner Schindler.
Class 7 Practical Considerations CIS 755: Advanced Computer Security Spring 2014 Eugene Vasserman
High Performance Computing on Virtualized Environments Ganesh Thiagarajan Fall 2014 Instructor: Yuzhe(Richard) Tang Syracuse University.
Public-Key Encryption
MA/CSSE 473 Day 10 Primality testing summary Data Encryption RSA.
Utilizing Performance Monitors for Compromising keys of RSA on Intel Platforms Sarani Bhattacharya and Debdeep Mukhopadhyay Dept. of Computer Science and.
Thomas Ristenpart,Eran Tromer, Horav Shahcham and Stefan Savage
Cloud security Tom Ristenpart CS Software-as-a-service Infrastructure-as-a- service Cloud providers Cloud computing NIST: Cloud computing is a model.
A paper by Thomas Ristenpart, Eran Tromer, Hovav Shacham, and Stefan Savage, Proceedings of the ACM Conference on Computer and Communications Security,
Slide 1 Vitaly Shmatikov CS 380S Timing Attacks. slide 2 Reading uKocher. “Timing Attacks on Implementations of Diffie-Hellman, RSA, DSS, and Other Systems”
Exploiting Cache-Timing in AES: Attacks and Countermeasures Ivo Pooters March 17, 2008 Seminar Information Security Technology.
Attacking RSA Brian Winant Reference “Twenty Years of Attacks on the RSA Cryptosystem” By Dan Boneh In Notices of the American Mathematical.
PUBLIC-KEY CRYPTOGRAPHY AND RSA – Chapter 9 PUBLIC-KEY CRYPTOGRAPHY AND RSA – Chapter 9 Principles Applications Requirements RSA Algorithm Description.
Remote Timing Attacks are Practical David Brumley Dan Boneh [Modified by Somesh.
WISA 2007 Jeju Island, Korea, 27th – 29th Aug 2007 Longer Randomly Blinded RSA Keys may be Weaker than Shorter Ones Colin D. Walter
Great Theoretical Ideas in Computer Science.
0x1A Great Papers in Computer Security Vitaly Shmatikov CS 380S
Data encryption with big prime numbers DANIEL FREEMAN, SLU.
RSA Cryptosystem Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS Spring 2006 Lecture 8Feb. 09, 2006Carnegie Mellon University.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Copyright © Zeph Grunschlag, RSA Encryption Zeph Grunschlag.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
Key Exchange in Systems VPN usually has two phases –Handshake protocol: key exchange between parties sets symmetric keys –Traffic protocol: communication.
Thomas Ristenpart , Eran Tromer, Hovav Shacham ,Stefan Savage CCS’09
Thwarting cache-based side- channel attacks Yuval Yarom The University of Adelaide and Data61.
Revision. Cryptography depends on some properties of prime numbers. One of these is that it is rather easy to generate large prime numbers, but much harder.
Public Key Cryptography
Virtual Machine Monitors
X. Zhang, Y. Xiao, Y. Zhang Return-Oriented Flush-Reload Side Channels on ARM and Their Implications for Android Devices Xiaokuan Zhang, Yuan Xiao, Yinqian.
Hey, You, Get Off of My Cloud
X. Zhang, Y. Xiao, Y. Zhang Return-Oriented Flush-Reload Side Channels on ARM and Their Implications for Android Devices Xiaokuan Zhang, Yuan Xiao, Yinqian.
Written by : Thomas Ristenpart, Eran Tromer, Hovav Shacham,
Information Security – Theory vs
Bruhadeshwar Meltdown Bruhadeshwar
CSE 451: Operating Systems Autumn Module 24 Virtual Machine Monitors
CSE 451: Operating Systems Autumn Module 24 Virtual Machine Monitors
University of Illinois at Urbana-Champaign
Meltdown & Spectre Attacks
Presentation transcript:

Side-channels Tom Ristenpart CS 6431

Pick target(s) Choose launch parameters for malicious VMs Each VM checks for co-residence Frequently achieve advantageous placement “Cloud cartography” Recall from last time: Hardware Hypervisor OS1 P1 P2 OS2 P1 P2 This shouldn’t matter if VMM provides good isolation!

Today RSA remote side-channel attack Flush+Reload side-channel attack

RSA reminder Z N = { i | gcd(i,N) = 1 } * Claim: Suppose e,d Z φ(N) satisfying ed mod φ(N) = 1 then for any x Z N we have that (x e ) d mod N = x * * (x e ) d mod N = x (ed mod φ(N)) mod N = x 1 mod N = x mod N First equality is by Euler’s Theorem φ(N) = |Z N |

RSA reminder Z N = { i | gcd(i,N) = 1 } * Claim: Suppose e,d Z φ(N) satisfying ed mod φ(N) = 1 then for any x Z N we have that (x e ) d mod N = x * * Z 15 = { 1,2,4,7,8,11,13,14 } * e = 3, d = 3 gives ed mod 8 = 1 Z φ(15) = { 1,3,5,7 } * x x 3 mod y 3 mod φ(N) = |Z N |

Xf pk (X) easy given N,e hard given N,e easy given N,d The RSA trapdoor permutation pk = (N,e) sk = (N,d) with ed mod φ(N) = 1 f N,e (x) = x e mod Ng N,d (y) = y d mod N

pk = (N,e) sk = (N,d) with ed mod φ(N) = 1 f N,e (x) = x e mod Ng N,d (y) = y d mod N But how do we find suitable N,e,d ? If p,q distinct primes and N = pq then φ(N) = (p-1)(q-1) Why? φ(N) = |{1,…,N-1}| - |{ip : 1 ≤ i ≤ q-1}| - |{iq : 1 ≤ i ≤ p-1}| = N-1 - (q-1) - (p-1) = pq – p – q + 1 = (p-1)(q-1) The RSA trapdoor permutation

pk = (N,e) sk = (N,d) with ed mod φ(N) = 1 f N,e (x) = x e mod Ng N,d (y) = y d mod N But how do we find suitable N,e,d ? If p,q distinct primes and N = pq then φ(N) = (p-1)(q-1) Given φ(N), choose e Z φ(N) and calculate d = e -1 mod φ(N) The RSA trapdoor permutation *

We don’t know if inverse is true, whether inverting RSA implies ability to factor Learning p,q from N is the factoring problem

Textbook exponentiation Exp(h,x,N) X’ = h For i = 2 to x do X’ = X’*h Return X’ SqrAndMulExp(h,x,N) b k,…,b 0 = x f = 1 For i = k down to 0 do f = f 2 mod N If b i = 1 then f = f*h mod N Return f How do we compute h x for any h Z N ? Requires time O(|G|) in worst case. Requires time O(k) multiplies and squares in worst case. *

SqrAndMulExp(h,x,N) b k,…,b 0 = x f = 1 For i = k down to 0 do f = f 2 mod N If b i = 1 then f = f*h mod N Return f f 3 = 1  h f 2 = h 2 f 1 = (h 2 ) 2  h b 3 = 1 b 2 = 0 b 1 = 1 f 0 = (h 4  h) 2  h b 1 = 1 = h 8  h 2  h h 11 = h = h 8  h 2  h

SqrAndMulExp(h,x,N) b k,…,b 0 = x f = 1 For i = k down to 0 do f = f 2 mod N If b i = 1 then f = f*h mod N Return f What side-channels might arise? Timing CPU state (caches, branch predictors,…) Power

“Remote” attack setting Hardware Hypervisor OS1 RSA- Decrypt OS2 (Attacker) OS2 (Attacker) Co-located placement on cloud instance RSA-Decrypt takes adversarially supplied ciphertext c Z N and computes c d mod N Attacker can time operation Where would this come up in practice? *

(Part of) TLS handshake for RSA transport Client Server PMS <- D(sk,C) ClientHello, MaxVer, Nc, Ciphers/CompMethods ServerHello, Ver, Ns, SessionID, Cipher/CompMethod CERT = (pk of bank, signature over it) Check CERT using CA public verification key Pick random Nc Pick random Ns Pick random PMS C <- E(pk,PMS) C

SqrAndMulExp(h,x,N) b k,…,b 0 = x f = 1 For i = k down to 0 do f = f 2 mod N If b i = 1 then f = f*h mod N Return f C1C1 t1t1 C2C2 t2t2 … Prior work before BB: Kocher 96 timing attack x = b k b k-1 … b k-i+1 u k-i u k-i-1 … u 0 Guess some bits at frontRemaining exponent bits are unknown Predict how long it should take to decrypt (random) value C If guess is right, predictions will correlate with observed timings If guess is wrong, no correlations As more b k … b k-i+1 known, predictions get stronger Kocher shows can do with q = O(k)

Kocher attack in practice? BB point out: – OpenSSL widely used implementation of TLS Kocher attack doesn’t work against it: – OpenSSL uses CRT, sliding windows, two different modular multiplication algorithms – CRT: Chinese Remainder Theorem – Sliding window: exponentation by handling exponent in chunks, not one bit at a time

Chinese Remainder Theorem For n = n 1 n 2 …n k with gcd(n i,n j ) = 1 System of congruences x = x 1 mod n 1 = … = x k mod n k has exactly one solution and we can find it efficiently For RSA with N = pq d1 = d mod (p-1) d2 = d mod (q-1) q -1 = q -1 mod p Compute m 1 = h d1 mod p m 2 = h d2 mod q Compute m = m 1 + (q -1 *(m1 – m2) mod p) * q

Towards a timing attack Decryption requires m 2 = h d2 mod q Square-and-multiply (lots of multiplies mod q) Sliding window (fewer multiplies mod q) Multiply x*y mod q uses Montgomery reduction Let R = 2 z for some z Compute (xR*yR)*R -1 = zR mod q – Fast to compute R -1 – At end of computation: zR > q then subtract q Schindler’s observation: Pr[subtract q] ≈ (h mod q ) / 2R

R -1 * h lo mod N t lo R -1 *h hi mod N t hi Guess first few bits of q = b k … b 1 Let h lo = b k b k-1 … b k-i … 0 Let h hi = b k b k-1 … b k-i … 0 If b k-i = 0 then: h lo < q < h hi If b k-i = 1 then: h lo < h hi < q q Decryption time h lo h hi if b k-1 = 0 h hi if b k-1 = 1 RSA- Decrypt

Many more details Secondary timing effect – Karatsuba versus standard multiplication – Opposite timing difference for h hi - h lo – Use absolute values: one effect always dominates Sliding window (few multiplications) – Amplify by querying a bunch of values: h hi, h hi + 1, h hi + 2, … – Called a neighborhood

Timing differences measurable

The attack worked… ~1.5 million queries for 1024 bit RSA 2 hours on that era’s computers Blinding countermeasure: y = r e * c mod N m = y d / r mod N SqrAndMulExp(h,x,N) b k,…,b 0 = x f = 1 For i = k down to 0 do f = f 2 mod N If b i = 1 then f = f*h mod N Return f Hardware Hypervisor OS1 RSA- Decrypt OS2 (Attacker) OS2 (Attacker)

Cache-based side channel attacks A long literature on cache side channel attacks – Percivel 2005: RSA side channels – Tromer et al. 2005: AES side channels Today: particularly simple one by Yarom and Faulkner useful in PaaS clouds

Attacker VM Victim VM Main memory L1 instr cache Prime+Probe protocol Attacker VM (each row represents cache set) … Scheduling order on CPU core Victim VM Attacker VM … Timings correlated to (distinct) cache usage patterns of S, M operations Can spy frequently (every ~16 μs) by exploiting scheduling Timings correlated to (distinct) cache usage patterns of S, M operations Can spy frequently (every ~16 μs) by exploiting scheduling Interrupt Slow Fast Runs (S) operation Runs (M) operation

Prime+Probe limitations Works only for L1 caches – Some recent work extending to LLC in certain settings – Multi-core settings difficult (Zhang et al. 2012) Lots of noise from various sources

Towards Flush+Reload Deduplication-based memory page sharing (Linux, KVM, VMWare) Duplicate memory pages detected, physical pages coalesced Virtual address spaces different, but mapped to same physical addresses Main memory Libgcrypt square( ) instructions Inclusive cache architecture

Towards Flush+Reload Deduplication-based memory page sharing (Linux, KVM, VMWare) Duplicate memory pages detected, physical pages coalesced Virtual address spaces different, but mapped to same physical addresses Main memory Libgcrypt square( ) instructions Inclusive cache architecture

Flush+Reload protocol Flush from LLC memory line of interest Wait Time reloading memory line Not-accessed by victim Accessed by victim

Attacking Square and Multiply SqrAndMulExp(h,x,N) b k,…,b 0 = x f = 1 For i = k down to 0 do f = f 2 mod N If b i = 1 then f = f*h mod N Return f

Flush+Reload type attacks damaging Immediately used in a large number of follow- up papers to break various things – Cryptographic targets – Non-cryptographic targets Requires memory deduplication – Turned off in Amazon EC2 But not in Linux by default – PaaS services vulnerable [Zhang et al. 2014]

General victim execution tracing 32 #include "stdio.h” int b; int inc(int number) { return number + 1; } int main() { int a = 9; if (a % 2 == 1) a = inc(a); b = a; return 0; }

Control-Flow Graph 33 #include "stdio.h” int b; int main() { int a = 9; if (a % 2 == 1) a = inc(a); int inc(int number) { return number + 1; } b = a; return 0; }

Control-Flow Graph b6: mov $0x9,%edi 4004bb: callq 4004b4 4004b6: mov $0x9,%edi 4004bb: callq 4004b : lea 0x1(%rdi),%eax : retq : lea 0x1(%rdi),%eax : retq 4004c0: mov %eax,0x200b60(%rip) 4004c6: mov $0x0,%eax 4004cb: retq 4004c0: mov %eax,0x200b60(%rip) 4004c6: mov $0x0,%eax 4004cb: retq chunk 1: [ bf] chunk 3: [4004c0-4004ff] chunk 2: [ f]

Control-Flow Graph 35 chunk1 [ bf] chunk1 [ bf] chunk2 [ f] chunk2 [ f] chunk 3 [4004c0-4004ff] chunk 3 [4004c0-4004ff]

An Attack NFA 36 {c1} {c2, c3} {c3} Flush-Reload {} (c1, t 1, t 2 ) (c2, t 3, t 4 ) chunk1 [ bf] chunk1 [ bf] chunk2 [ f] chunk2 [ f] chunk 3 [4004c0-4004ff] chunk 3 [4004c0-4004ff] start (c3, t 7, t 8 ) (c3, t 5, t 6 )

Three Example Attacks Inferring Sensitive User Data SAML-based Single Sign-on Attacks Password-Reset Attack 37

Three Example Attacks Inferring Sensitive User Data SAML-based Single Sign-on Attacks Password-Reset Attack 38

Password Reset 39 Password Reset Token Verification Pseudo- Random Number Generator User Token

Password Reset Attack 40 Password Reset Token Verification Pseudo- Random Number Generator User Token Pseudo- Random Number Generator Shared Library Shared Library gettimeofday() Attacker Attack NFA Library calls Token Prediction Shared OS Application

Call Graph of Password Resetting 41

Attacker’s Strategy 42 Attacker application Attacker application Victim application Attacker’s account Password reset against his own account Password reset token (attack NFA) Offline: Bruteforce value of getpid() Password reset against victim account Online: token guessing (attack NFA) (HTTP keepAlive)

The Attack NFA 43

Evaluation Demonstrated successful attacks against Magento (controlled by ourselves) in a public PaaS cloud. After 2 20 offline computation, the attacker can narrow down the password reset token to 2 2 possible values---easy to brute-force online. 44

Side-channel countermeasures Constant time code – Input-independent memory accesses, timing Very difficult to truly get! – Input-dependent instruction timing on CPU Best bet: don’t share physical resources