CipherGuard: Compiler-aided Mitigation against Ciphertext Side-channel Attacks
Ke Jiang, Sen Deng, Yinshuai Li, Shuai Wang, Tianwei Zhang, Yinqian Zhang
TL;DR
CipherGuard tackles ciphertext side channels in TEEs caused by deterministic memory encryption by introducing a compiler-based mitigation that integrates dynamic taint analysis with static program rewriting. It implements three complementary defenses—software-assisted probabilistic encryption, secret-aware register allocation, and diversion-based obfuscation—along with robust nonce management and formal correctness proofs. Empirical results across major cryptographic libraries show substantial improvements over prior work, achieving an average overhead as low as $1.41\times$ and up to $1.95\times$ in their most efficient configuration, with stronger coverage than post-hoc binary masking. The work highlights the practicality and portability of compiler-driven defenses, offering verifiable, high-coverage protection that can be extended to other compilers and cryptographic workloads while maintaining functional correctness."
Abstract
Recently, the new ciphertext side channels resulting from the deterministic memory encryption in Trusted Execution Environments (TEEs), enable ciphertexts to manifest identifiable patterns when being sequentially written to the same memory address. Attackers with read access to encrypted memory in TEEs can potentially deduce plaintexts by analyzing these changing ciphertext patterns. In this paper, we design CipherGuard, a compiler-based mitigation tool to counteract ciphertext side channels with high efficiency and security guarantees. CipherGuard is based on the LLVM ecosystem, and encompasses multiple defense strategies, including software-assisted probabilistic encryption, secret-aware register allocation, and diversion-based obfuscation. The design of CipherGuard demonstrates that compiler techniques are highly effective for fine-grained control over mitigation code generation and assisted component management. Through a comprehensive evaluation, it demonstrates that CipherGuard can strengthen the security of various cryptographic implementations more efficiently than existing state-of-the-art defense, i.e., CipherFix. In its most efficient strategy, CipherGuard incurs an average performance overhead of only 1.41X, with a maximum of 1.95X.
