Defending Against Cache-Based Side-Channel Attacks

 
Thwarting cache-based side-
channel attacks
 
Yuval Yarom
The University of Adelaide and Data61
 
 
“The binary search needs to be done in constant
time to avoid timing issue. But it's fast, so
there's no problem.”
An anonymous reviewer, AsiaCrypt 2016
 
Outline
 
Introduction to cache attacks
Constant-time programming
Testing for constant-time
Microarchitecture
The Microachitecture
ISA
 
Data
Cache
 
Instruction
Cache
 
Pipeline
 
BPU
 
TLB
 
MMU
 
DRAM
 
Interconnect
 
LLC
 
Microarchitectural attacks
 
Force contention on microarchitectural
components
  Creating timing variations
  That are used to expose an intarnal state
  Which depends on secret data
  Allowing the attacker to infer said data
 
 
5
Cache Structure
 
Stores fixed-size 
lines
Arranged as multiple
sets
, each consisting of
multiple 
ways
.
Each memory line maps
to a single cache set
Can be cached in any of
the ways in the set
Cache
6
The Prime+Probe attack
 
Choose a  cache-sized
memory buffer
Access all the lines in the
buffer, filling the cache
Victim executes, evicting
some of the buffer lines
from the cache
Measure the time to access
the buffer
Accesses to cached lines is
faster than to evicted lines
Memory
Cache
7
C. Percival, "Cache Missing for Fun and Profit", BSDCan, 2005
D. A. Osvik, A. Shamir and E. Tromer, "Cache Attacks and Countermeasures: The Case of AES", CT-RSA 2006
Prime+Probe attack on GnuPG 1.4.13
Square
Multiply
 
The Bernstein attack
 
AES tables stored in
memory
Table access patterns
depend on both the key and
the plaintext/ciphertext
Access time depends on the
pattern of previous accesses
Attack:
Create timing profiles for
each key byte
Measure timing
Match with profile
 
9
 
Timing Profile for byte 15 [Ber05]
 
D. J. Bernstein, "Cache-timing attacks on AES",http://cr.yp.to/antiforgerycachetiming-20050414.pdf, 2005
F
LUSH
+R
ELOAD
F
LUSH
 
memory line
Wait a bit
Measure time to 
R
ELOAD
line
slow-> no access
fast-> access
Repeat
Processor
Memory
Cache
 
10
D. Gullasch, E. Bangerter and S. Krenn, “Cache Games - Bringing Access-Based Cache Attacks on AES to Practice”, IEEE S&P 2011
Y. Yarom and K. Falkner, “Flush+Reload: a High Resolution, Low Noise, L3 Cache Side-Channel Attack”, USENIX Security 2014
 
F
LUSH
+R
ELOAD
 
on GnuPG 1.4.13
 
Why focus on crypto?
 
Because that’s where the keys are
 
 
Small code base with fairly regular operation
Narrow semantic gap between the code and the
leak
 
Mitigation Strategies
 
System
Avoid/reduce sharing
Insert noise (e.g. noisy timers, random caches)
 
Software
Inject noise (e.g. blinding)
Constant-time programming
 
Constant-time programming
 
Execution time does not depend on any secret
data
Three rules:
No instructions with data-dependent execution
time
No secret-dependent flow control
No secret-dependent memory access
 
Constant-time programming in
practice
 
Fix attempt #1
 
Fix attempt #2
 
Fix attempt #3
 
Checking for constant-time
 
Manual testing is not easy and is error-prone.
 
 
Dynamic Analysis
 
ctgrind
A patch against valgrind memcheck
Dynamically taints secret-dependent data
Warns on secret-dependent branches and
memory access
 
Dynamic analysis can miss code paths
 
 
A. G. Langley, ctgrind https://github.com/agl/ctgrind
Source Analysis
FlowTracker
Uses information flow analysis to identify non-
constant-time-accesses
Potential mismatch between code and binary
B. Rodrigues, F. M. Q. Pereira, D. F. Aranha, “Sparse Representation of Implicit Flows
with Applications to Side-Channel Detection”, CC 2016
 
Binary Analysis
 
CacheAudit
Analyses the amount of leakage from a binary given a
cache model
 
The analysis may miss some important cache
configurations
Not all of the microarchitecture is modeled
Cache banks? Branch Prediction? Cache slices?
May accept implementations that are not
constant-time
 
G. Doychev, B.Köpf, L.Mauborgne and J.Reineke, “CacheAudit: A Tool for the Static Analysis ofCache Side Channels”, TISSEC 18(1) 2005
G. Doychev and B. Köpf, “Rigorous Analysis of Software Countermeasures against Cache Attacks”, aarXiv 
1603.02187, 2016
What about instructions with data-
dependent time?
 
ISA
 
Data
Cache
 
Instruction
Cache
 
Pipeline
 
BPU
 
TLB
 
MMU
 
DRAM
 
Interconnect
 
LLC
 
What about instructions with data-
dependent time?
 
We rely on partial and misleading documentation
What if?
A vendor decide to shortcut additions or
multiplications of known zeros?
Writes that do not modify the value do not result in a
dirty cache line?
 
We need guarantees on CPU behaviour
See https://blog.cr.yp.to/20140517-insns.html
 
Summary
 
Microarchitectural attacks are a threat to the
security of cryptographic implementations
Constant time programming is our current
best defence
But we still need:
Improved proofs of correctness
Better tests for constant-time
Vendor guarantees on the hardware
Slide Note
Embed
Share

The content discusses strategies to mitigate cache-based side-channel attacks, focusing on the importance of constant-time programming to avoid timing vulnerabilities. It covers topics such as microarchitectural attacks, cache structure, Prime+Probe attack, and the Bernstein attack on AES. Through detailed explanations and examples, the text emphasizes the critical need for secure coding practices and countermeasures to protect sensitive data from exploit.

  • Cache attacks
  • Security
  • Constant-time programming
  • Microarchitecture
  • Side-channel attacks

Uploaded on Sep 24, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Thwarting cache-based side- channel attacks Yuval Yarom The University of Adelaide and Data61

  2. The binary search needs to be done in constant time to avoid timing issue. But it's fast, so there's no problem. An anonymous reviewer, AsiaCrypt 2016

  3. Outline Introduction to cache attacks Constant-time programming Testing for constant-time

  4. The Microachitecture ISA TLB Microarchitecture Pipeline BPU Instruction Cache Data Cache MMU LLC DRAM Interconnect

  5. Microarchitectural attacks Force contention on microarchitectural components Creating timing variations That are used to expose an intarnal state Which depends on secret data Allowing the attacker to infer said data 5

  6. Cache Structure Stores fixed-size lines Arranged as multiple sets, each consisting of multiple ways. Each memory line maps to a single cache set Can be cached in any of the ways in the set Memory Sets Cache Ways 6

  7. The Prime+Probe attack Choose a cache-sized memory buffer Access all the lines in the buffer, filling the cache Victim executes, evicting some of the buffer lines from the cache Measure the time to access the buffer Accesses to cached lines is faster than to evicted lines Memory Cache C. Percival, "Cache Missing for Fun and Profit", BSDCan, 2005 D. A. Osvik, A. Shamir and E. Tromer, "Cache Attacks and Countermeasures: The Case of AES", CT-RSA 2006 7

  8. Prime+Probe attack on GnuPG 1.4.13 Square Multiply

  9. The Bernstein attack AES tables stored in memory Table access patterns depend on both the key and the plaintext/ciphertext Access time depends on the pattern of previous accesses Attack: Create timing profiles for each key byte Measure timing Match with profile Timing Profile for byte 15 [Ber05] 9 D. J. Bernstein, "Cache-timing attacks on AES",http://cr.yp.to/antiforgerycachetiming-20050414.pdf, 2005

  10. FLUSH+RELOAD Processor FLUSH memory line Wait a bit Measure time to RELOAD line slow-> no access fast-> access Repeat Cache Memory D. Gullasch, E. Bangerter and S. Krenn, Cache Games - Bringing Access-Based Cache Attacks on AES to Practice , IEEE S&P 2011 Y. Yarom and K. Falkner, Flush+Reload: a High Resolution, Low Noise, L3 Cache Side-Channel Attack , USENIX Security 2014 10

  11. FLUSH+RELOAD on GnuPG 1.4.13

  12. Why focus on crypto? Because that s where the keys are Small code base with fairly regular operation Narrow semantic gap between the code and the leak

  13. Mitigation Strategies System Avoid/reduce sharing Insert noise (e.g. noisy timers, random caches) Software Inject noise (e.g. blinding) Constant-time programming

  14. Constant-time programming Execution time does not depend on any secret data Three rules: No instructions with data-dependent execution time No secret-dependent flow control No secret-dependent memory access

  15. Constant-time programming in practice

  16. Fix attempt #1

  17. Fix attempt #2

  18. Fix attempt #3

  19. Checking for constant-time Manual testing is not easy and is error-prone.

  20. Dynamic Analysis ctgrind A patch against valgrind memcheck Dynamically taints secret-dependent data Warns on secret-dependent branches and memory access Dynamic analysis can miss code paths A. G. Langley, ctgrind https://github.com/agl/ctgrind

  21. Source Analysis FlowTracker Uses information flow analysis to identify non- constant-time-accesses Potential mismatch between code and binary B. Rodrigues, F. M. Q. Pereira, D. F. Aranha, Sparse Representation of Implicit Flows with Applications to Side-Channel Detection , CC 2016

  22. Binary Analysis CacheAudit Analyses the amount of leakage from a binary given a cache model The analysis may miss some important cache configurations Not all of the microarchitecture is modeled Cache banks? Branch Prediction? Cache slices? May accept implementations that are not constant-time G. Doychev, B.K pf, L.Mauborgne and J.Reineke, CacheAudit: A Tool for the Static Analysis ofCache Side Channels , TISSEC 18(1) 2005 G. Doychev and B. K pf, Rigorous Analysis of Software Countermeasures against Cache Attacks , aarXiv 1603.02187, 2016

  23. What about instructions with data- dependent time? ISA TLB Pipeline BPU Instruction Cache Data Cache MMU LLC DRAM Interconnect

  24. What about instructions with data- dependent time? We rely on partial and misleading documentation What if? A vendor decide to shortcut additions or multiplications of known zeros? Writes that do not modify the value do not result in a dirty cache line? We need guarantees on CPU behaviour See https://blog.cr.yp.to/20140517-insns.html

  25. Summary Microarchitectural attacks are a threat to the security of cryptographic implementations Constant time programming is our current best defence But we still need: Improved proofs of correctness Better tests for constant-time Vendor guarantees on the hardware

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#