BackCache: Mitigating Contention-Based Cache Timing Attacks by Hiding Cache Line Evictions

Quancheng Wang, Ming Tang, Han Wang, Yuzhe GuarXiv 2023 · OpenReview

TL;DR

This paper introduces BackCache, a novel hardware-software co-design that mitigates contention-based cache timing attacks on L1 data caches. By using a fully associative backup cache to store evicted lines and employing a random replacement policy and dynamic resizing, BackCache ensures cache hits for victims and hides eviction patterns from attackers, with minimal performance impact.

What Problem Does This Paper Address?

Modern processors heavily rely on caches to bridge the speed gap between the CPU and main memory, significantly boosting performance. However, these caches, particularly the L1 data cache, are also a prime target for sophisticated "cache timing attacks." These attacks exploit the subtle differences in access times between a cache hit and a cache miss to infer sensitive information from victim processes. Contention-based attacks, where an attacker and victim share the same cache but not memory regions, are particularly concerning. Attackers can strategically evict cache lines, forcing the victim to experience misses, and then observe the victim's access patterns by re-accessing those lines. Existing defenses like cache partitioning, randomization, and flushing often come with high overheads, complex implementations, or can be bypassed by advanced attacks, leaving a critical security gap for L1 data caches.

Methods

The core innovation of BackCache is its "always cache hits" philosophy for the L1 data cache. It achieves this by introducing a fully associative backup cache that resides alongside the L1 data cache. When a cache line is evicted from the L1 data cache, it's immediately moved to this backup cache. This way, even if the line is no longer in the L1, accessing it from the backup cache still results in a fast cache hit, masking the eviction from the attacker.

To enhance security and prevent attackers from exploiting the backup cache itself, two key mechanisms are introduced:

  1. Random Used Replacement Policy (RURP): This policy for the backup cache prioritizes keeping cache lines that have been recently accessed (marked with a "used bit"). This prevents attackers from easily predicting which lines will be evicted from the backup cache, making it harder for them to craft precise eviction sets.
  2. Dynamic Backup Cache Resizing Mechanism: Attackers might try to infer the backup cache's size to craft attacks. This mechanism dynamically adjusts the backup cache's size based on memory access counts, making it difficult for attackers to determine its exact capacity and thus hindering their ability to infer secret information.

The system also includes hardware registers to manage this dynamic resizing and a new BUCLR instruction to clear the "used bit" during context switches, ensuring proper operation.

Datasets

The paper does not explicitly mention specific datasets for training. For evaluation, the authors utilize:

  • gem5 simulator: A cycle-accurate simulator used to implement and evaluate the BackCache design.
  • Mibench benchmark suite: Used for single-thread performance evaluation.
  • SPEC CPU 2017 benchmark suite: Also used for single-thread performance evaluation.
  • PARSEC 3.0 benchmark suite: Used for multi-thread performance evaluation.
  • Linux kernel: Modified to support the BUCLR instruction for context switching.
  • OpenSSL 1.1.1m: Used to simulate a real-world AES encryption scenario for security evaluation.

Key Insights and Ideas

  • Shifting the Paradigm: From Misses to Hits: The fundamental insight is to move away from simply mitigating cache misses (which is what attackers exploit) towards ensuring cache hits, even when data is evicted from the primary cache. This is a clever way to "hide in plain sight."
  • The Power of a Backup: A fully associative backup cache is surprisingly effective. Its ability to hold evicted lines without a fixed mapping to specific cache sets makes it difficult for attackers to correlate evictions with specific victim accesses.
  • Randomness as a Security Feature: The RURP policy highlights how introducing controlled randomness in replacement can significantly complicate an attacker's strategy, especially when combined with the "used bit" to track recent activity.
  • Dynamic Size for Dynamic Threats: The dynamic resizing mechanism is crucial for addressing attacks that might exploit knowledge of the cache's fixed size. By making the size unpredictable, it adds another layer of defense.
  • Hardware-Software Co-design is Key: The success of BackCache relies on tight integration between hardware modifications (backup cache, new bits) and software support (ISA extension, OS modifications), demonstrating the power of this approach for security.

Key Results

  • Security: BackCache effectively prevents contention-based cache timing attacks, including Prime+Probe attacks on single cache sets and real-world AES encryption scenarios. The attacker is unable to reliably distinguish between cache hits and misses, thus failing to extract sensitive information.
  • Performance Overhead: The performance impact is minimal.
  • OS kernel context switch overhead: 2.61%
    • Single-thread benchmarks (Mibench): Average 3.80%
    • Single-thread benchmarks (SPEC CPU 2017): Average 2.66%
    • Multi-thread benchmarks (PARSEC): Average 3.36%
  • Hardware Overhead: CACTI 6.5 estimates a 1.54x increase in access latency and a 1.77x increase in energy consumption for the L1 data cache subsystem. The area overhead is estimated to be around 2.05x.

Limitations and Future Work

  • Performance Overhead: While considered minimal, the performance overhead is still present and might be a concern for extremely performance-sensitive applications. The paper notes that the overhead is similar across different configurations of the dynamic backup cache resizing.
  • Attack Complexity: The paper acknowledges that while BackCache significantly increases the attacker's complexity (e.g., 16x for a specific attack scenario), it doesn't completely eliminate all possible attack vectors, particularly those not covered by the threat model (e.g., certain reuse-based attacks if not carefully handled).
  • Future Work: The authors suggest further research into optimizing the dynamic resizing mechanism and exploring its applicability to other cache levels or security scenarios. They also highlight the need to strike a balance between security and performance, suggesting sensitivity analysis of memory access thresholds for dynamic resizing. The paper also mentions that the "used bit" is reset to 0 during context switches, which is a crucial detail for security.

Summary updated

Abstract

Caches are used to reduce the speed differential between the CPU and memory to improve the performance of modern processors. However, attackers can use contention-based cache timing attacks to steal sensitive information from victim processes through carefully designed cache eviction sets. And L1 data cache attacks are widely exploited and pose a significant privacy and confidentiality threat. Existing hardware-based countermeasures mainly focus on cache partitioning, randomization, and cache line flushing, which unfortunately either incur high overhead or can be circumvented by sophisticated attacks. In this paper, we propose a novel hardware-software co-design called BackCache with the idea of always achieving cache hits instead of cache misses to mitigate contention-based cache timing attacks on the L1 data cache. BackCache places the evicted cache lines from the L1 data cache into a fully-associative backup cache to hide the evictions. To improve the security of BackCache, we introduce a randomly used replacement policy (RURP) and a dynamic backup cache resizing mechanism. We also present a theoretical security analysis to demonstrate the effectiveness of BackCache. Our evaluation on the gem5 simulator shows that BackCache can degrade the performance by 2.61%, 2.66%, and 3.36% For OS kernel, single-thread, and multi-thread benchmarks.
BibTeX
@misc{wang2023backcache,
  author = {Quancheng Wang and Ming Tang and Han Wang and Yuzhe Gu},
  title = {{BackCache: Mitigating Contention-Based Cache Timing Attacks by Hiding Cache Line Evictions}},
  year = {2023},
  eprint = {2304.10268},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.10268},
}
Figure