arXiv:2611.04701cs.PLNov 2026

Manuscript Offprint

arXiv:2611.04701

Proving the Wrong Program: Miscompilations as a Threat to zkVM Guarantees

Hui Xuan Tan, Stefanos Chaliasos, Alastair F. Donaldson

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

HUI XUAN TAN, Imperial College London, United Kingdom

STEFANOS CHALIASOS, University of Athens, Greece and ZKSecurity, United States

ALASTAIR F. DONALDSON, Imperial College London, United Kingdom

A zero-knowledge virtual machine (zkVM) lets an untrusted prover convince a verifier that a program, typically Rust compiled to RISC-V, ran correctly. The proof covers the compiled binary, so a miscompilation can make a correct zkVM produce a valid proof of a computation that differs from the developer's source code. We present the first empirical study of miscompilation as a threat to zkVM guarantees, on two production zkVMs, SP1 and Jolt. We assemble 88 known rustc and LLVM miscompilations with Rust reproducers, using an LLM agent to recover Rust triggers for 60 of 124 LLVM bugs that were reported only as LLVM IR. Many of the bugs carry over to zkVMs: 48 of the 88 make a guest commit a wrong output on SP1 and 46 on Jolt, including the same 15 rustc bugs on both. Most bugs that do not reproduce never reach the faulty code on the zkVM's target, for example because they need an instruction-set extension. Existing guest programs are rarely affected by accident. Across 13 guests of 10 popular SP1 projects, the buggy and the fixed compiler produce byte-identical binaries in 447 of the 552 guest-bug pairs that build, and the other 105 pairs have the same code or agree on every input we ran. An attacker who contributes code to a guest, however, can trigger these bugs on purpose. For about $40 per project, an LLM agent found patches that look like ordinary optimisations, preserve the behaviour of the guest's source, and expose a known bug in 12 of 366 project-bug pairs, across 11 of 20 projects. In four cases the guest commits a wrong output, including an Ethereum client that rejects a valid block, and in the other eight it fails on a valid input. Reviewing or formally verifying the zkVM or the guest's source cannot catch such a patch, because both are correct. zkVM projects should therefore treat their compiler as part of their trusted base and track the known bugs of the toolchain they build with.

CCS Concepts: • Software and its engineering → Compilers; Software testing and debugging; • Security and privacy → Cryptography.

Additional Key Words and Phrases: zkVM, compiler bugs, miscompilation, Rust, differential testing

1 Introduction

Zero-knowledge virtual machines (zkVMs) let an untrusted prover produce a succinct proof that a program was executed correctly on specified inputs [Ben-Sasson et al. 2014; Succinct ndb]. Because checking a proof is typically much less expensive than re-executing the associated program [Thaler 2025], zkVMs now underpin application domains such as blockchains (for scalability [Chaliasos et al. 2024b] and interoperability [Xie et al. 2022]), privacy-preserving machine learning and proofs of identity [Lavin et al. 2024]. In recent work on the quantum resources needed to break elliptic-curve cryptography, Google used SP1 [Succinct nda], a popular zkVM, to back its claims without disclosing its improved quantum designs [Babbush et al. 2026]. Traditional approaches to zero-knowledge computation involve writing low-level arithmetic circuits that are error-prone [Chaliasos et al. 2024a]. The main benefit of zkVMs is that the program whose execution is proved—the guest—can be written in an ordinary language such as Rust, and compiled with an existing compiler to the instruction set of the zkVM (usually RISC-V [Argument Computer Corporation 2024]).

The guarantees provided by zero-knowledge infrastructure rely on the infrastructure itself having been implemented correctly. Infrastructure defects can have severe consequences. For example, a September 2026 forged withdrawal led to the Payy protocol losing around $1.9M [Unchained 2026] despite them having written a correct zero-knowledge circuit: the problem turned out to be a bug in the underlying Noir/Barretenberg proof system [Iakovenko 2026; Payy 2026].

Authors' Contact Information: Hui Xuan Tan, Imperial College London, United Kingdom; Stefanos Chaliasos, University of Athens, Greece and ZKSecurity, United States; Alastair F. Donaldson, Imperial College London, United Kingdom.

In the context of zkVMs, a major trusted component is the compiler that compiles high-level source code to the zkVM's instruction set. A zkVM proves that a given guest binary was executed faithfully; if the compiler miscompiles the guest, the prover will produce a valid proof of a computation that the developer did not actually write. Despite substantial research on the security of zero-knowledge systems, examining hand-written circuits, proof systems and zkVM implementations [Chaliasos et al. 2024a; Wen et al. 2024a; Yang et al. 2026], and despite an Ethereum Foundation initiative towards formally verified zkVMs [Ethereum Foundation 0000], the security implications of miscompilation in zkVM guest compilers remain comparatively underexplored. Miscompilation bugs are fairly common: between July 2024 and September 2026, the LLVM project developers fixed at least 124 miscompilations that could plausibly affect Rust code (Section 3.1), and the rustc developers have fixed dozens more miscompilations that affect rustc directly [Liu et al. 2025]. Whether they matter in practice is less clear. Marcozzi et al. [2019] found that fuzzer-found and developer-reported Clang/LLVM bugs rarely changed the behaviour of Debian packages, suggesting that existing code seldom triggers known bugs.

A zkVM, however, operates in an adversarial setting, where the party that would benefit from a wrong result may also be able to influence the code that is compiled. We consider an adversary who can contribute a patch to a guest program but does not control its build: based on their knowledge of a latent compiler bug (either a publicly known bug that the maintainers' toolchain still contains, even if fixed upstream, or a bug that the adversary has discovered and kept secret) they submit a benign-looking change that triggers a miscompilation in the maintainers' toolchain, then supply inputs on which the compiled guest computes the wrong answer, and obtain a valid proof of it.

A motivating example. Listing 1 shows a patch that an LLM agent wrote during our study (Section 4.3) for zk-img-editor, a small SP1 application that edits a signed photo and commits the result. The patch adds a fast path that brightens or darkens the image in place, and leaves the remaining adjustments to the image library as before. The pull-request message that the agent drafted presents the change as a way to avoid copying the image. On every input, the patched source computes the same image as the original. LLVM issue L#114181¹ breaks this. The guard in lines 5 and 6 should send an adjustment of -128 to the library. LLVM's instruction combiner rewrites the negation in line 5 but keeps a no-signed-wrap flag that no longer holds, so the buggy compiler evaluates the comparison in line 6 to false. The fast path then runs with a magnitude of zero, and the guest commits the original pixels as the darkened image. The LLVM 19.1.1 that ships with the official SP1 v4 toolchain has this bug. As a result, SP1 would prove the wrong image, and a verifier would accept the proof. From a code review point of view, a pull request contributing the patch of Listing 1 does constitute a correct optimisation; the reviewer or patch contributor could even use formal verification to prove correctness of their source-level change. An attacker with advance knowledge of a miscompilation bug (e.g. because they found it ahead of time using a compiler fuzzing tool and did not report it, or because despite the bug being known and even fixed upstream, it still affects the toolchain associated with a zkVM) could thus submit such a patch and keep a backdoor open for as long as the project builds with an affected toolchain.

In this paper we study the potential for miscompilation bugs to undermine the guarantees provided by zkVMs. Our work is structured around the following research questions:

RQ1 (Reproducibility) Do known miscompilation bugs reproduce on zkVM targets, and if not, why not? (Section 4.1)

RQ2 (Accidental impact) Do existing zkVM guest programs trigger these bugs when built with a buggy compiler? (Section 4.2)

¹We write L#n for issue n on the LLVM issue tracker and R#n for issue n on the Rust issue tracker.

Listing 1. Patch that an LLM agent wrote for zk-img-editor, an SP1 application that checks a photo's camera signature, applies a list of edits and commits the edited image (Section 4.3). Added lines are green, and we omit the helper's call site. The patch keeps the behaviour of the source, but under LLVM L#114181 the comparison in line 6 is false for delta = -128, and the guest commits the image without darkening it. Below the patch is the pull-request message that the agent drafted for it.

1 +// Keep the common small adjustment in place; the library path handles values
2 +// outside this range and the two boundary cases.
3 +#[inline(never)] keep the helper a separate function
4 +fn brighten_in_place_if_small_brightening(img: &mut RgbImage, delta: i8) -> bool {
5 +     let selected = if delta > 16 { -delta } else { delta }; -delta if delta > 16, else delta
6 +     if selected.wrapping_neg() == delta { true for delta > 16, 0 and -128; the bug makes it false for -128
7 +         return false; leave these values to the library
8 +     }
9 +     let magnitude = if delta < 0 { how much to change each channel
10 +         delta.checked_neg().unwrap_or_default() as u8 | delta| when darkening, but 0 for -128
11 +     } else {
12 +     delta as u8 delta when brightening
13 +     };
14 +     for pixel in imgPixels_mut() { every pixel
15 +         for channel in &mut pixel.0 { every RGB channel
16 +             *channel = if delta < 0 {
17 +                 channel.saturating_sub(magnitude)    darken, stopping at 0
18 +                 } else {
19 +                 channel.saturating_add(magnitude)    brighten, stopping at 255
20 +     };
21 +     }
22 +     }
23 +     true     done here, skip the library
24 + }

References (16)