Skip to content
Business logic Audit finding Advanced

Inconsistent Multiplicity Increment in `read_ghost_addr`

The read_ghost_addr method incorrectly increments the multiplicity counter for ghost reads, unlike other ghost read methods. This inconsistency could cause circuit constraint verification to fail in zero-knowledge proof systems.

0xgh0st Follow

Originally disclosed on Sherlock

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

Found by

0xgh0st

Summary

A logic bug exists in the read_ghost_addr method in compiler where it incorrectly increments the multiplicity counter for ghost reads. This violates the ghost read semantics and could lead to incorrect circuit constraint verification in zero-knowledge proof systems.

Root Cause

The read_ghost_addr method calls read_addr_internal with increment_mult: true, which increments the multiplicity counter. This is inconsistent with other ghost read methods:

  • read_ghost_vaddr correctly uses increment_mult: false
  • read_ghost_const initializes multiplicity to zero without incrementing

Ghost reads are intended for non-computational operations that should not affect memory access counts used in circuit constraints.

Rust
    pub fn read_ghost_addr(&mut self, addr: Address<FC::F>) -> &mut FC::F {
        self.read_addr_internal(addr, true)
    }
 
    fn read_addr_internal(&mut self, addr: Address<FC::F>, increment_mult: bool) -> &mut FC::F {
        use vec_map::Entry;
        match self.addr_to_mult.entry(addr.as_usize()) {
            Entry::Vacant(_) => panic!("expected entry: addr_to_mult[{:?}]", addr.as_usize()),
            Entry::Occupied(entry) => {
                // This is a read, so we increment the mult.
                let mult = entry.into_mut();
                if increment_mult {
                    *mult += FC::F::ONE;
                }
                mult
            }
        }
    }

Internal Pre-conditions

NA

External Pre-conditions

  1. Code must use raw Address<FC::F> objects in ghost operations rather than higher-level types like Felt<FC::F> or Ext<FC::F, FC::EF>

Attack Path

  1. Trigger Condition: Use an Address<FC::F> object directly in a ghost operation (e.g., print_f(address))
  2. Bug Activation: The read_ghost method calls read_ghost_addr which incorrectly increments multiplicity
  3. Propagation: Incorrect multiplicity values get backfilled into circuit instructions during compilation

Impact

Circuit constraint verification may fail due to inconsistent memory access counts

PoC

No response

Mitigation

Change line 390 in read_ghost_addr from:

Rust
self.read_addr_internal(addr, true)

to:

Rust
self.read_addr_internal(addr, false)

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 0xgh0st. 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 read_ghost_addr method passes true for increment_mult instead of false, causing an unintended increment of the multiplicity counter.

Impact

Circuit constraint verification may fail due to inconsistent memory access counts.

What the attacker needed

Code uses raw Address objects in ghost operations

The fix

The protocol team fixed this issue by changing the increment_mult argument to false in read_ghost_addr.

How it was found

  1. Use an Address object directly in a ghost operation such as print_f(address).
  2. The read_ghost method calls read_ghost_addr, which incorrectly increments multiplicity.
  3. Incorrect multiplicity values get backfilled into circuit instructions during compilation.

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 circuit tracks how many times each memory address is read or written. A 'ghost read' is a special read that should not change that count. Here, one ghost read function accidentally increased the count, which could make the circuit's checks fail.

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 0xgh0st

View all

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