arXiv:2608.29716cs.SEAug 2026

Manuscript Offprint

arXiv:2608.29716

Agent-Driven Verification of Memory Safety for liblzma Decoder Components with VST

Prokhor Shlyakhtun, Alexander Gryzlov, Vladimir Kukharenko, Vasilii Nesterov, Nikolai Vasiliev, Kirill Ziborov, Eugene Zolotarev, Alex Pokras

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

Prokhor Shlyakhtun¹, Alexander Gryzlov¹,², Vladimir Kukharenko¹, Vasilii Nesterov¹, Nikolai Vasiliev¹, Kirill Ziborov¹, Eugene Zolotarev¹, and Alex Pokras¹

¹ GenProof, USA

{orenty7, alexgryzlov, vladimir, vasa, nick, kirill, eugene, alex}@genproof.com

² IMDEA Software Institute, Madrid, Spain

Abstract. We report on the verification of memory safety for decoder components of liblzma, the compression library underlying xz-utils: the LZMA2 state machine, the LZMA1 decoder it controls, the outer decoding path, and the shared sliding-window dictionary. Built with the Verified Software Toolchain (VST), machine-checked body theorems establish memory safety and partial functional correctness. Across 27 completed body proofs, the largest covers lzma_decode, whose 338 source lines expand to 1,934 lines of C after preprocessing; its proof comprises 183,268 lines of proof script over 775,768 lines of mechanically extracted goal statements. The verification exposed undefined behavior in raw LZMA1 zero-input handling, where range-decoder macros add zero to a null pointer and subtract two null pointers.

Unlike similar work that synthesizes verified code, we verify pre-existing, production-scale C. AI agents complete proof goals and propose refinements; humans write and review models and specifications, and approve semantic changes; the Rocq kernel checks the proof terms.

With agents constructing the proof scripts, the main engineering problems lay in translating and modeling production C, building a robust harness for driving Rocq, and providing feedback for proving agents. VST's assertion logic expressed every contract required by the development. We describe the pipeline, coordination mechanisms, and proof-engineering techniques that resolved these frictions.

Keywords: Memory safety · Separation logic · VST · liblzma · LLM agents · Proof automation · Experience report

1 Introduction

liblzma, the compression library underlying xz-utils, is a widely used open-source dependency. The 2024 xz backdoor (CVE-2024-3094) [15] highlighted the trust placed in this codebase. While that attack used release and build machinery rather than a memory-safety defect, memory-safety defects are the largest single class of exploited vulnerabilities in C and C++ code, on the order of 70% of serious issues at organizations such as Microsoft [14]. We therefore address the library's own code: whether decoder bodies can be proved safe under explicit function contracts.

The Verified Software Toolchain (VST) [4,7] supports foundational verification of C programs through separation-logic proofs over CompCert semantics [12], but the process remains labor-intensive. In our pipeline, AI agents construct and repair proofs and may propose specification refinements. Humans approve every change to a model or function specification before agents propagate it through dependent proofs; the kernel of Rocq (formerly Coq)³ checks the resulting proof terms. The liblzma case study examines both this division of labor and the proof engineering needed to sustain it on production C.

The reported decoder scope contains 22 VST body proofs closed through Qed with no uses of admit or Admitted, covering the LZMA2 framing state machine, outer decoding path, sliding-window dictionary, six supporting LZMA1 functions, and the LZMA1 decoding core. Each theorem establishes Clight safety and model-relative partial functional correctness for its function body, assuming the corresponding contract's precondition and imported contracts. This safety result rules out invalid memory accesses that the semantics represents as stuck execution (§ 2.1); § 6 gives the inventory and contract boundary. The archived artifact contains the Rocq/VST proof sources, verified liblzma source snapshot, and build instructions [20].

At 183,268 lines of proof script, the body proof for lzma_decode is the largest; § 6 explains its scale. Verifiable C does not support the function's original Duff's device⁴ control flow, so the verified 338-line C function uses an explicit state machine; after CompCert preprocessing, its body spans 1,934 nonblank lines of C. Proof construction spanned 1,595 agent sessions over 70 days (§ 3.2). Verification also exposed source-level undefined behavior in the raw LZMA1 zero-input path: range-decoder macros add zero to a null pointer and subtract two null pointers, outside C's defined pointer-arithmetic cases [11, 6.5.7] (§ 6).

This paper makes the following contributions:

  • An agent-human workflow for C verification that assigns proof construction and repair to agents while humans retain authority over models and function contracts (§ 3, § 4).
  • A body-level verification of liblzma decoder components with 22 closed VST body proofs (§ 4, § 6).
  • Agent engineering for long-running proof development: structured Rocq interaction, standalone goal extraction, incremental checking, multi-agent orchestration, and durable session handoffs (§ 3.2).
  • Proof engineering for production C and VST: build-aware Clight generation, model testing against executions, and source normalization (§ 5).

³ Legacy tool and project names such as coqc and CertiCoq retain the former name. ⁴ Duff's device places case labels inside a loop body, allowing a switch to enter the loop at different points.

– Agent-driven proof optimization: a mechanically orchestrated agent swarm that profiles and refactors completed proofs to reduce checking time (§ 3.2).