arXiv:2610.20754cs.CROct 2026

Manuscript Offprint

arXiv:2610.20754

Foundations of Hardware-Software Leakage Contracts

Jan Reineke

Jan Reineke [0000−0002−3459−2214]^{[0000-0002-3459-2214]}

Saarland University, Saarland Informatics Campus, Saarbrücken, Germany

reineke@cs.uni-saarland.de

Abstract. Microarchitectural attacks such as Spectre and Meltdown undermine security by exploiting software-visible side effects of microarchitectural optimizations like caches and speculative execution. To use modern hardware securely, programmers must take into account the security implications of these optimizations. Yet instruction set architectures (ISAs)—the conventional abstraction layer between hardware and software—are ill-suited for secure programming: by design, they abstract from microarchitectural details and therefore fail to reflect their security consequences.

A new security abstraction is emerging to fill this void: hardware-software leakage contracts. To support the principled development of secure software on modern hardware such contracts characterize side-channel leakage at the ISA level. Thereby they enable programmers and compilers to generate code that is provably resistant to side-channel attacks—without having to explicitly reason about the microarchitecture. On the other hand, they provide a specification for hardware designers to ensure that microarchitectures do not introduce unintended and undocumented side channels. This paper introduces the foundations of this emerging topic, discussing recent contributions and unresolved challenges along the way.

Keywords: hardware-software contracts · side channels · instruction set architecture · microarchitectural security

1 Introduction

Modern microarchitectures implement a growing number of optimizations to increase performance. Today even simple processors in embedded systems often employ caches to hide the latency of main memory. General-purpose processors in personal computers and data centers employ multi-level caches, deep pipelines, and various forms of speculation to reduce latency and to increase instruction throughput.

Microarchitectural attacks [7, 74, 89, 59, 90, 55, 60, 79, 10, 26, 78, 77, 87, 42, 69] exploit the fact that these features may have software-visible side effects. In particular, instructions may have vastly different execution latencies depending on the context they are executed in. For example, memory instructions can be served in a few cycles from the cache but may take hundreds of cycles if they need

J. Reineke

if (secret) wait 1 second return else input * secret wait 100 seconds return 42 return 42

((a))

((b))

((c))

nirvana = Mem[secret] return Mem[input]

assert (input >= A.size) if (input < A.size) y = A[input] z = B[y]

((d))

((e))

Fig. 1: Example programs that may or may not leak secrets via their timing.

to access main memory. Measuring latencies of instruction or of entire programs thus allows attackers to gain information about the execution context, which may in turn depend on secret data.

Defending against microarchitectural attacks is challenging since microarchitectural optimizations are “invisible” at the instruction set architecture (ISA) level, which is the traditional hardware-software interface. Hardware-software leakage contracts [46] (short: leakage contracts) aim to fill this void by specifying at the ISA-level what information a program may leak. In this way they may serve as a rigorous foundation for writing programs that are resistant against microarchitectural attacks.

Consider the pseudo-code example programs in Figure 1. Let us assume an attacker who can control the input and observe a program's execution time. Which of these programs leak information about secrets to this attacker?

The program in Figure 1(a) certainly leaks the value of the secret variable via its timing, independently of the underlying microarchitecture. This example illustrates that side-channel security cannot be achieved purely in hardware.

For the program in Figure 1(b) it depends. On some processors, the multiplication instruction has operand-dependent timing, e.g. due to a fast-path implementation of multiplication by zero. On such processors, the timing of the program in Figure 1(b) will give away some information about secret. On other processors, the same program may have constant execution time.

For the program in Figure 1(c) it again depends. Assuming that the conditional statement is implemented via a conditional branch instruction, the program will leak the branch outcome—and thus the secret—on most in-order pipelined processors. There, the “branch taken” case will take a few cycles longer as the processor initially continues fetching the instructions immediately following the branch instruction, switching to the correct branch target only once the branch condition has been evaluated. Most processors also employ instruction caches. With instruction caches, the two program paths may touch a different number of memory blocks and thus have secret-dependent execution time due to a varying number of cache misses.

On simple embedded processors without caches or Dynamic Random-Access Memory (DRAM)-based main memory the program in Figure 1(d) may have constant execution time. In the presence of a data cache, on the other hand, the program may be used to leak some bits of the value of secret. Assuming an initially empty cache, the access to Mem[input] will result in a cache hit if and only if it accesses the same memory block as the first memory access to Mem[secret]. Thus, depending on the exact cache geometry a subset of the bits of secret leak. E.g. on a byte-addressable system with 32-byte cache lines, the 5 least significant bits determine the offset within a memory block, while all other bits determine the memory block and may thus be inferred from the execution time of the program by varying the input and measuring the execution time. Similarly, the program's execution time may leak information about the secret due to history-dependent DRAM latencies.

Unlike the previous examples, the program in Figure 1(e) has no explicit secrets. For the sake of the example, let's assume that the array bounds and the data within arrays A and B is public while all out-of-bounds data is secret. On non-speculative processors the program in Figure 1(e) either fails on the assertion or it branches to the end of the program. Thus without speculation there's no leakage of secret data. On processors implementing speculative execution without Spectre countermeasures, however, the program may leak out-of-bounds data of array A: Assume that input >= A.size. Then, the processor may nevertheless speculatively execute the two accesses to A[input] and B[y], later rolling back their architectural effects. The first access is out-of-bounds and thus brings secret data into variable y, and the second access encodes this secret value in the cache state, as the address of the access is secret dependent. This second access also makes the execution time of the program itself secret dependent as it may result in a hit or a miss depending on the value of A[input] and the initial cache state. The program is a simple variation of Spectre V1 [55].

From the above examples we can draw several conclusions:

  1. Side-channel vulnerabilities are not a matter that can be fully addressed by clever microarchitecture design. The program in Figure 1(a) leaks the secret on any reasonable microarchitecture.

  2. The same program may be vulnerable on one microarchitecture and secure on another (Figures 1(b) to 1(e)). Furthermore, depending on the microarchitecture, data may leak even if the program’s execution logically does not depend upon it, as the Spectre V1 example in Figure 1(e) shows.

Due to the absence of guarantees about side-channel leakage the ISA level, programmers need to reason directly about the underlying microarchitecture to write side-channel-secure code. However, vendors are not releasing specifications about the microarchitecture at a sufficient level of detail to guarantee security. Furthermore, future microarchitects may design optimizations that break current programs' security by introducing new sources of leakage without breaking any guarantees provided by the ISA. As illustrated in Figure 2, leakage contracts

J. Reineke

Figure

Fig. 2: Leakage contracts establish security at the ISA level.

address both of these issues. They specify potential information leakage due to side channels at the ISA level. This enables programmers and compiler designers to reason about side-channel security without having to explicitly consider microarchitectural features. Leakage contracts also act as a specification that constrains the design of future microarchitectures, preventing the unintended and undocumented introduction of new vulnerabilities.

Consider the following informal contract in plain language:

“For every multiplication the second operand leaks and for every memory access the memory address leaks.”

Interpreting a program instruction-by-instruction and evaluating the contract in each step yields a trace of contract observations. For example, for any initial state, the program in Figure 1(b) yields a trace consisting of a single observation that leaks the value of secret. The program in Figure 1(d) yields traces of length two, leaking secret and input. If wait × seconds is implemented using a busy-wait loop, then wait 1 second and wait 100 seconds execute different numbers of instructions. As a result, their contract traces differ in length and thus implicitly leak the value of secret. Thus these three programs are vulnerable under the contract above, as they leak information about secrets. On the other hand, the programs in Figures 1(c) and 1(e) are secure as they yield traces that are independent of any secrets.

We discuss secure programming, i.e., what it means for a program to be secure under a contract, as well as techniques to verify and enforce this property in Section 4.

Secure programming is only meaningful if the microarchitecture that a program is executed on satisfies the contract. A contract is sound for a given microarchitecture, or, equivalently, the microarchitecture satisfies the contract, if the contract captures all leaks in the microarchitecture, i.e., any two program executions that are distinguishable by an attacker must result in different contract traces. We formally define contracts and contract satisfaction in Section 3. There, we also discuss techniques to verify that a given microarchitecture satisfies a contract and to synthesize contracts for a given microarchitecture. To prepare for this, we introduce architectures and microarchitectures in Section 2.

References (80)