Auditing Custom Zero-Knowledge Tooling with AI Agents
Trail of Bits describes using AI agents over six months to build custom developer tooling, decompilers, static analyzers, and formal verification models for a custom zero-knowledge virtual machine assembly language.
What Changed in Tooling Development
According to Trail of Bits, security engineers spent six months using AI agents to build developer and analysis tooling from scratch for the Miden zero-knowledge virtual machine (VM) and its custom assembly language (MASM). The project produced a Language Server Protocol (LSP) server, a static analysis engine, a decompiler, and a Lean model of the VM executor.
The decompiler effort required more than 100 AI-generated commits over multiple months. Because hand-written MASM lacks declared signatures, standard calling conventions, and stack-neutral loops, the decompiler had to focus on a well-defined subset of the language rather than universal decompilation.
How It Works: Static Analysis and Formal Verification
The source notes that AI agents helped construct an abstract interpretation engine for static analysis. This analysis found over 400 unique locations where type validation could be improved. It also uncovered a high-severity vulnerability in the mod_12289 procedure caused by an unvalidated advice value supplied by the prover.
Separately, agents assisted in creating a minimal Miden VM executor in Lean along with an automatic translator from MASM to Lean. This generated 95 machine-checked correctness proofs covering the binary arithmetic components of the Miden core library. This formal modeling process caught two subtle bugs that the existing unit test suite missed.
Why a Developer Might Care
Developers working with niche languages or new architectures can apply similar strategies:
- Custom Ecosystem Support: When a language lacks native IDE support or linters, developers can direct AI agents to build project-specific LSP servers and decompilers.
- Automated Code Auditing: Teams can co-develop abstract interpretation engines and data-flow analysis passes with AI models to catch unvalidated inputs and type enforcement errors.
- Proof Assistant Integration: Engineers can use agents to translate low-level custom assembly into formal verification tools like Lean, helping generate machine-checked correctness proofs.
The source also highlights an economic shift: because AI agents can carry out exploratory side projects with light supervision, failed experiments primarily cost tokens rather than large human resource allocations.
Limitations
The source identifies several technical constraints:
- Decompilation Scope Restrictions: The generated decompiler cannot handle all MASM procedures due to implicit stack effects, variable stack slots in while-loops, and differing stack effects across conditional branches.
- Manual Verification of Proofs: While the Lean proof assistant validates generated correctness proofs automatically, human auditors must manually review theorem statements to ensure they test the intended properties.
- Unpredictable Exploratory Payoffs: Exploratory tool building remains unpredictable by nature, making it difficult to pitch such efforts to clients in advance without relying on low token costs to justify the initial attempt.