Skip to content
Business logic Audit finding Advanced

First chunk having cpu chip is incorrectly checked in convert circuit

A check in the convert recursion circuit that should prevent the first chunk from lacking a CPU chip is ineffective because the chunk counter is incremented before the check. This allows a chunk without a CPU chip to be converted first, producing a recursion proof that may not satisfy the completeness condition.

cergyk Follow

Originally disclosed on Sherlock

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

Found by

cergyk

Description

In the convert recursion circuit, there's a check preventing the first chunk from having no CPU chip:

convert/builder.rs#L220-L221:

Rust
    if !flag_cpu {
        builder.assert_felt_ne(current_chunk, CC::F::ONE);

Unfortunately, the current_chunk is already incremented to be "expected next chunk", meaning that even if the currently converted proof has chunk number 1, the check always checks 2 != 1, and thus is always true;

convert/builder.rs#L199-L213:

Rust
    /*
    Chunk number constraints and updates
        */
    {
        // range check
        CC::range_check_felt(builder, public_values.chunk, MAX_LOG_NUMBER_OF_CHUNKS);


        // current chunk is incremented by 1
        //@audit current_chunk is incremented before the check equal to one
        current_chunk = builder.eval(current_chunk + CC::F::ONE);


        // If the chunk has a "CPU" chip, then the execution chunk should be incremented by 1.
        if flag_cpu {
            current_execution_chunk = builder.eval(current_execution_chunk + CC::F::ONE);
        }
    }

Impact

Impact is not clear, since it allows for one chunk to be converted first without having a cpu. The resulting recursion proof can be used in combine circuit, but will not fulfill the completeness condition (contains_execution_chunk).

Recommendation

Either move the check before the increment or modify as follows:

convert/builder.rs#L220-L221:

Diff
    if !flag_cpu {
-        builder.assert_felt_ne(current_chunk, CC::F::ONE);
+        builder.assert_felt_ne(current_chunk - CC::F::ONE, CC::F::ONE);

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 cergyk. 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

The check compares the already-incremented chunk number against one, so it never catches the first chunk.

Impact

The resulting recursion proof can be used in the combine circuit but will not fulfill the completeness condition (contains_execution_chunk).

What the attacker needed

None

The fix

The check should be moved before the increment or adjusted to compare the pre-increment value; the protocol team fixed this issue.

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, circuits enforce rules. Here, a rule meant to stop the first chunk from missing a CPU chip is broken because the chunk number is increased before the rule is checked. So the rule never triggers, and a proof can be created that skips a required condition.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by cergyk

View all

29 more disclosed reports, best first.

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.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.