cache timing attacks on rsa key generation
play

CACHE-TIMING ATTACKS ON RSA KEY GENERATION Conference on - PowerPoint PPT Presentation

CACHE-TIMING ATTACKS ON RSA KEY GENERATION Conference on Cryptographic Hardware and Embedded Systems (CHES) 2019 Alejandro Cabrera Aldaya 1 , Cesar Pereida Garca 2 , Luis Manuel Alvarez Tapia 1 , Billy Bob Brumley 2 , {aldaya,


  1. CACHE-TIMING ATTACKS ON RSA KEY GENERATION Conference on Cryptographic Hardware and Embedded Systems (CHES) 2019 Alejandro Cabrera Aldaya 1 , Cesar Pereida García 2 , Luis Manuel Alvarez Tapia 1 , Billy Bob Brumley 2 , {aldaya, lalvarezt89}@gmail.com, {billy.brumley, cesar.pereidagarcia}@tuni.fi 1 Universidad Tecnológica de la Habana (CUJAE), Habana, Cuba 2 Network and Information Security Group (NISEC), Tampere University, Tampere, Finland Aug 25-28, 2019

  2. default Contents Introduction Side-Channel Leakage Finding The BN_FLG_CONSTTIME A New Methodology The Tool Leakage Analysis RSA Key Generation Binary GCD The Attack Conclusion Lessons Learned 2 / 21

  3. default Contents Introduction Side-Channel Leakage Finding The BN_FLG_CONSTTIME A New Methodology The Tool Leakage Analysis RSA Key Generation Binary GCD The Attack Conclusion Lessons Learned 3 / 21

  4. default Introduction ◮ What?: A single trace cache-timing attack against the binary Extended Euclidean (GCD) algorithm used during RSA key generation, leading to complete RSA private key recovery. ◮ Why?: Because we can!. ◮ Cloud services (e.g. AWS, Azure) and automated certificate renewal (e.g. Let’s Encrypt) make RSA key generation a semi-predictable operation. ◮ Micro-architecture attacks. ◮ RSA key generation neglected. ◮ How?: We developed a new methodology to help us detect insecure code paths in OpenSSL, then we combine F LUSH +R ELOAD , signal processing and lattice techniques. 4 / 21

  5. default Contents Introduction Side-Channel Leakage Finding The BN_FLG_CONSTTIME A New Methodology The Tool Leakage Analysis RSA Key Generation Binary GCD The Attack Conclusion Lessons Learned 5 / 21

  6. default OpenSSL and the BN_FLG_CONSTTIME ◮ OpenSSL relies on the BN_FLG_CONSTTIME to protect against timing-attacks. ◮ The fl ag gives a lot of room for mistakes. ◮ Several fl aws involving the fl ag have been identi fi ed previously. ◮ CVE-2016-2178 ◮ CVE-2016-7056 ◮ CVE-2018-0734 ◮ We have a record of well known side-channel vulnerable functions used in OpenSSL. 6 / 21

  7. default A New Methodology ◮ Create a list of known side-channel vulnerable functions in a library (e.g. OpenSSL). ◮ Use a debugger to automatically set breakpoints at lines of code that should be unreachable. ◮ Run several security-critical commands. ◮ Generate a report if any of the breakpoints is reached. ◮ I nvestigate manually the root-cause. 7 / 21

  8. default The Tool 1 ... in BN_is_prime_fasttest_ex (...) at bn_prime.c:329 INFO: Parsing source code at: ./openssl-1.0.2k #2 ... in BN_generate_prime_ex (...) at bn_prime.c:199 ... #3 ... in rsa_builtin_keygen (...) at rsa_gen.c:150 INFO: Breakpoints file generated: triggers.gdb #4 ... ... INFO: Monitor target command line INFO: Insecure code executed! Breakpoint 2, BN_gcd (...) at bn_gcd.c:120 TOOL: gdb --batch --command=triggers.gdb --args openssl-1.0.2k/apps/openssl genpkey -algorithm RSA 120 int ret = 0; -out private_key.pem -pkeyopt rsa_keygen_bits:2048 BN_gcd (...) at bn_gcd.c:120 #0 ... in rsa_builtin_keygen (...) at rsa_gen.c:154 ... #1 INFO: Setting breakpoints... ... Breakpoint 1 at ...: file bn_exp.c, line 418. INFO: Insecure code executed! Breakpoint 2 at ...: file bn_gcd.c, line 120. Breakpoint 3, BN_mod_inverse (...) at bn_gcd.c:238 Breakpoint 3 at ...: file bn_gcd.c, line 238. bn_check_top(a); 238 BN_mod_inverse (...) at bn_gcd.c:238 ... #0 ... in BN_MONT_CTX_set (...) at bn_mont.c:450 INFO: Insecure code executed! #1 Breakpoint 1, BN_mod_exp_mont (...) at bn_exp.c:418 ... in BN_is_prime_fasttest_ex (...) at bn_prime.c:319 #2 bn_check_top(a); ... in BN_generate_prime_ex (...) at bn_prime.c:199 418 #3 BN_mod_exp_mont (...) at bn_exp.c:418 ... in rsa_builtin_keygen (...) at rsa_gen.c:171 #0 #4 ... in witness (...) at bn_prime.c:356 #1 ... 1 [Gri+19] expanded our methodology and tooling into a C I tool called TriggerFlow. https://gitlab.com/nisec/triggerflow 8 / 21

  9. default Contents I ntroduction Side-Channel Leakage Finding The BN_FLG_CONSTTIME A New Methodology The Tool Leakage Analysis RSA Key Generation Binary GCD The Attack Conclusion Lessons Learned 9 / 21

  10. default RSA Key Generation Algorithm 1: OpenSSL RSA key generation Input: Key size n and public exponent e . Output: Public and private key pair. 1 begin while gcd( p − 1 , e ) � = 1 do 2 p ← rand n / 2-bit prime /* Generate p */ 3 while gcd( q − 1 , e ) � = 1 do 4 q ← rand n / 2-bit prime /* Generate q */ 5 d ← e − 1 mod ( p − 1 )( q − 1 ) /* Priv exp */ 6 dp ← d mod ( p − 1 ) 7 dq ← d mod ( q − 1 ) /* CRT parameters */ 8 iq ← q − 1 mod p 9 10 return (N, e), (d, p, q, dp, dq, iq) 10 / 21

  11. default Binary GCD Algorithm 2: Binary GCD Input: I ntegers a and b such that 0 < a < b . Output: Greatest common divisor of a and b . 1 begin u ← a , v ← b , i ← 0 2 while even( u ) and even( v ) do 3 u ← u / 2, v ← v / 2, i ← i + 1 4 while u � = 0 do 5 while even( u ) do 6 u ← u / 2 /* u-loop */ 7 Coppersmith bound while even( v ) do 8 0 512 768 1007 1023 v ← v / 2 /* v-loop */ 9 NIST if u ≥ v then 256 16 10 e = 2 - 1 e = 2 +1 u ← u − v /* sub-step */ 11 else 12 v ← v − u 13 return v · 2 i 14 11 / 21

  12. default Contents I ntroduction Side-Channel Leakage Finding The BN_FLG_CONSTTIME A New Methodology The Tool Leakage Analysis RSA Key Generation Binary GCD The Attack Conclusion Lessons Learned 12 / 21

  13. default Memory Hierarchy 13 / 21

  14. default F LUSH +R ELOAD and Performance Degradation 2) Attacker flushes victim's data from the cache and 1) Victim executes its own process, filling the cache waits 3) Victim may or may not execute its own process 4) Attacker reloads the data and measures the loading time again while the attacker waits 5) Attacker traces the victim's process execution and infers information about the victim 14 / 21

  15. default Attack Scenario Core 0 Core 1 Core 2 Core 3 L1 L1 L1 L1 L1 L1 L1 L1 L2 L2 L2 L2 Attacker Attacker Victim Flush+Reload Perf. Degradation OpenSSL Shared LLC 15 / 21

  16. default The Attack 1/2 ◮ OpenSSL 1.0.2k. Latency (filtered) Trace ◮ F LUSH +R ELOAD [YF14]. Latency (filtered) ◮ Templating. Template ◮ Pearson correlation. 0.4 Correlation 0.2 ◮ Low-pass fi lter. 0 -0.2 ◮ Horizontal -0.4 0 50000 100000 150000 200000 250000 analysis. 300 subtraction probe Trace, Latency shift probe ◮ Sequence of ops. 200 100 284400 284500 284600 284700 284800 284900 285000 285100 285200 285300 Time (samples) LLL S LL S L S LLLLL S L...L S 16 / 21

  17. default The Attack 2/2 ◮ Use expand-and-prune [HMM10] error correction algorithm. ◮ Obtain a ranked list of partial prime factors. ◮ Formulate lattice problems for the candidates. ◮ Run in a cluster for 4 hours. ◮ Recover private keys with a 27% success rate . 17 / 21

  18. default Contents I ntroduction Side-Channel Leakage Finding The BN_FLG_CONSTTIME A New Methodology The Tool Leakage Analysis RSA Key Generation Binary GCD The Attack Conclusion Lessons Learned 18 / 21

  19. default TL;DNL ◮ We developed a simple methodology and tool to track existing fl aws leading to insecure code paths in crypto libraries. ◮ We discovered three new fl aws a ff ecting OpenSSL during RSA key generation. ◮ We performed a cache-timing attack on the GCD algorithm, allowing us to fully recover RSA keys with a success rate of 27%. ◮ Our general strategy was: ◮ F LUSH +R ELOAD and performance degradation. ◮ Signal processing. ◮ Error correction algorithm. ◮ Lattice problem solving. 19 / 21

  20. default Responsible Disclosure We reported our fi ndings to OpenSSL security team , and they con fi rmed a ff ected versions 2 1.1.0-1.1.0h and 1.0.2-1.0.2o. OpenSSL assigned CVE-2018-0737 based on our work and adopted the proposed patches. ◮ Lesson 1: Secure by default. These and similar fl aws can be prevented with a secure-by-default approach. ◮ Adopt constant-time algorithms by default, e.g. [BY19] ◮ Lesson 2: Knowledge transfer. The engineers and cryptographers must work side-by-side to ensure that academic results permeate over real-world products. 2 OpenSSL 1.1.1 did not exist at the time of disclosure. 20 / 21

  21. default Thank you for listening. Questions? 21 / 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend