Skip to main content
QUICK REVIEW

[Paper Review] Mitigating Power Side Channels during Compilation

Jingbo Wang, Chungha Sung|arXiv (Cornell University)|Feb 25, 2019
Cryptographic Implementations and SecurityComputer Science70 references3 citations
TL;DR

This paper proposes a type-based analysis and transformation technique to detect and mitigate power side-channel leaks caused by register reuse in compilers like LLVM. By using Datalog-based static analysis to infer sensitive data types and enforce register allocation constraints, the method prevents leaking through Hamming Weight and Hamming Distance models, achieving faster and more compact code than state-of-the-art masking techniques in cryptographic benchmarks.

ABSTRACT

The code generation modules inside modern compilers such as GCC and LLVM, which use a limited number of CPU registers to store a large number of program variables, may introduce side-channel leaks even in software equipped with state-of-the-art countermeasures. We propose a program analysis and transformation based method to eliminate this side channel. Our method has a type-based technique for detecting leaks, which leverages Datalog-based declarative analysis and domain-specific optimizations to achieve high efficiency and accuracy. It also has a mitigation technique for the compiler's backend, more specifically the register allocation modules, to ensure that potentially leaky intermediate computation results are always stored in different CPU registers or spilled to memory with isolation. We have implemented and evaluated our method in LLVM for the x86 instruction set architecture. Our experiments on cryptographic software show that the method is effective in removing the side channel while being efficient, i.e., our mitigated code is more compact and runs faster than code mitigated using state-of-the-art techniques.

Motivation & Objective

  • To address the previously overlooked problem of power side-channel leaks introduced by register reuse during compilation in modern compilers like LLVM and GCC.
  • To detect leaks caused by storing masked secret values in the same CPU register, which can compromise high-order masking countermeasures.
  • To provide a secure-by-construction mitigation strategy that integrates seamlessly into the compiler backend without requiring bit-level transformation of the program.
  • To ensure high performance and low overhead by leveraging existing production-quality compiler modules and domain-specific optimizations.

Proposed method

  • A Datalog-based declarative analysis engine is used to perform fast, sound type inference on the word-level intermediate representation (IR), assigning each variable a distribution type (public, secret, random).
  • The method infers types for all variables based on user-provided annotations for inputs, enabling detection of pairs of variables that may cause side-channel leaks when stored in the same register.
  • Leak detection is based on Hamming Weight (HW) and Hamming Distance (HD) leakage models, which correlate with real power consumption patterns on hardware.
  • A mitigation layer is integrated into the LLVM backend register allocator, enforcing that potentially leaky variable pairs are assigned to different registers or spilled to isolated memory locations.
  • Domain-specific optimizations are applied to the Datalog engine to improve efficiency and scalability, enabling orders-of-magnitude speedup over formal verification methods.
  • The approach operates directly on word-level IR, avoiding the need for compilation to Boolean or circuit-level representations, which is incompatible with standard compiler flows.

Experimental results

Research questions

  • RQ1Can register reuse in modern compilers like LLVM introduce power side-channel leaks even in programs protected with high-order masking?
  • RQ2Can a fast, sound, and scalable type inference system detect such register reuse leaks without relying on formal verification or bit-level analysis?
  • RQ3Can a backend mitigation strategy enforce secure register allocation without increasing code size or execution time?
  • RQ4Does the method outperform existing state-of-the-art masking techniques in terms of performance and compactness in real cryptographic workloads?

Key findings

  • The method successfully detects and mitigates power side-channel leaks caused by register reuse in LLVM-compiled cryptographic code, even when the input uses high-order masking.
  • Experiments show that the mitigated code is more compact and executes faster than code secured using state-of-the-art high-order masking techniques.
  • The Datalog-based type inference system achieves high efficiency, enabling detection orders of magnitude faster than formal verification methods.
  • The mitigation strategy is effective in practice, as demonstrated by the absence of detectable leaks in compiled binaries on x86 platforms.
  • The method is compatible with existing compiler infrastructure and does not require transformation of the program to bit-level representations.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.