Axisdream
Written and Published byAxisdream·

Why Verifying Code Is Harder Than Verifying Protocol Design

Multi-layer diagram illustrating the abstraction gap between paper cryptographic designs and compiled machine code

Key Takeaways

  • •Verifying software implementations requires proving low-level memory, concurrency, and serialization semantics that abstract protocol models discard.
  • •Examines the abstraction gap between paper models and machine execution, analyzing the structural bottlenecks and trade-offs in real-world deployments.
  • •Provides engineering benchmarks and verification criteria for refinement proofs and the burden of semantics.

On 10 November 2026, Google DeepMind reported using AlphaProof Code to verify concrete implementation code underlying the Signal protocol, demonstrating that machine-checking compiled source code requires proving millions of operational assertions that paper designs ignore. Proving that an abstract cryptographic protocol is secure does not guarantee that the software executing that protocol preserves those security properties.

Cryptographic protocol designs operate on mathematical abstractions. When cryptographers publish a protocol specification, they assume perfect randomness, atomic state transitions, lossless serialization, and isolated memory. Real software executes in an environment shaped by operating system schedulers, memory allocators, foreign function interfaces, and compiler optimization flags. Bridging this abstraction gap accounts for the immense difficulty of real-world formal verification.

The abstraction gap between paper models and machine execution

Protocol proofs typically model a communication system as an idealized state machine. Tools such as the Tamarin Prover or ProVerif analyze protocol specifications by assuming that messages consist of abstract algebraic terms rather than raw byte buffers. Under this Dolev-Yao adversary model, an attacker can intercept, drop, or recombine messages, but cannot break encryption primitives or induce memory corruptions.

In production software, cryptographic failure occurs most frequently outside the algebra:

  • Buffer serialization: an implementation must parse untrusted byte streams into structured memory records. Integer overflows, off-by-one errors, or malformed length headers can crash the process or execute arbitrary shellcode before any cryptographic operation occurs.
  • Concurrency and reentrancy: while paper designs assume sequential state advancement, real applications process incoming messages across asynchronous thread pools. Unsynchronized state updates can cause two concurrent threads to encrypt distinct plaintexts using the identical nonce, destroying confidentiality.
  • Memory hygiene and secret leakage: abstract designs assume that private keys vanish when a session ends. In physical memory, operating system paging, core dumps, or compiler dead-code elimination routines may leave plaintext keys in heap memory long after zeroization routines were called.
Because abstract protocol models strip away these execution semantics, verifying the paper design provides zero mathematical assurance that the running binary is safe against memory corruption or race conditions.

text axisdream
┌────────────────────────────────────────────────────────┐
│             Abstract Cryptographic Model               │
│                                                        │
│  [State S1] ──────(Atomic Transition)──────> [State S2] │
└───────────────────────────┬────────────────────────────┘
                            │ (Discarded Realities)
                            ▼
┌────────────────────────────────────────────────────────┐
│             Concrete Software Implementation           │
│                                                        │
│  - Heap allocation & garbage collection locks          │
│  - Asynchronous thread scheduling & network sockets    │
│  - Byte parsing, pointer arithmetic & endianness       │
│  - Cache side-channel leakage & compiler optimizations │
└────────────────────────────────────────────────────────┘

Refinement proofs and the burden of semantics

To verify that an executable program satisfies a cryptographic specification, engineers must construct a refinement proof. A refinement proof is a formal mathematical demonstration showing that every observable behavior of the concrete code corresponds to a valid execution step in the abstract protocol model.

Constructing a refinement proof is difficult because the proof must track operational semantics at every level of the software stack:

  1. Low-level state invariants: the proof must show that every pointer dereference occurs within allocated memory bounds and that all heap objects remain aligned.
  2. Exhaustive error handling: every possible input/output failure, malformed packet, and system timeout must be accounted for without leaving the state machine in an undefined intermediate condition.
  3. Cryptographic side-channels: the proof must establish that execution duration, branching logic, and memory access patterns do not leak secret key material to co-located processes through CPU cache contention.
When DeepMind applied AlphaProof Code to the Signal protocol, researchers generated more than six million lines of Lean 4 proof code to verify properties that required only a few pages of mathematical specification on paper. The sheer volume of proof terms reflects the need to account for low-level language semantics, memory allocations, and state transition invariants.

The trusted computing base problem

A machine-checked proof provides certainty only within the boundaries of its formal assumptions. The collection of components that must function correctly for a proof to hold is known as the Trusted Computing Base (TCB).

When verifying software source code, the TCB extends far beyond the mathematical proof assistant:

  • The specification correctness: if the Lean theorem formalizing the security property contains a logical loophole or omits a real-world adversary capability, a verified proof guarantees correctness only against that incomplete model.
  • The compiler: formal verification typically targets source code written in languages such as C, Rust, or Go. Compilers often optimize away security-critical instructions, such as explicit memory zeroing loops, if the compiler determines that the zeroed variable is never read again in the program flow.
  • The runtime and hardware: proofs assume that CPU microcode executes instructions faithfully and that memory chips do not suffer from physical bit flips or row-hammer disturbance attacks.

Practical implications for security engineering

The distinction between design verification and implementation verification shapes how engineering organizations should allocate security resources:

  • Protocol proofs confirm architectural soundness: using protocol provers such as Tamarin confirms that key exchanges and authentication handshakes are immune to logical replay attacks before code is written.
  • Code-level verification confirms execution integrity: agentic theorem provers and proof assistants such as Lean verify that the memory layouts, state transitions, and concurrency locks of the actual codebase uphold those design guarantees.
  • Layered defense remains mandatory: because formal proofs cannot model every microarchitectural flaw or compiler optimization quirk, critical cryptographic applications still require defense-in-depth measures, including address space layout randomization, process sandboxing, and hardware security modules.
Verifying software code is fundamentally harder than verifying protocol designs because physical execution cannot discard reality. Autonomous proof agents make implementation verification viable by automating the search through tedious low-level proof obligations, allowing engineers to close the gap between mathematical design and running machine code.

Sources

Related Dispatches