worldfnd / worldfnd/provekit

[M-4] Verifier panics and becomes unusable after call

Open
#268 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Noir
Stars
138
Forks
47
Avg merge
1d 34m
Merged PRs (30d)
6

Description

  • Context: provekit/verifier/src/lib.rs
Description

The Verifier::verify uses self.whir_for_witness.take().unwrap(), which
(1) will panic if whir_for_witness is None (e.g., a Verifier deserialized from untrusted input with the field omitted/null), and
(2) permanently consumes the whir_for_witness state even on verification failure, making subsequent verify calls on the same Verifier panic.

In a long-running process that reuses a single Verifier across requests, an attacker can trigger a denial-of-service by causing a first verification attempt (valid or invalid) that drains whir_for_witness, then any later verification call crashes the process/thread via the unwrap() panic.

  • Impacted code
impl Verify for Verifier {
    #[instrument(skip_all)]
    fn verify(&mut self, proof: &NoirProof) -> Result<()> {
        self.whir_for_witness.take().unwrap().verify(
            &proof.whir_r1cs_proof,
            &proof.public_inputs,
            &self.r1cs,
        )?;

        Ok(())
    }
}
Recommendation

Avoid panics and avoid consuming verifier state on verification. Prefer let whir = self.whir_for_witness.as_ref().ok_or_else(|| anyhow!(...))?; whir.verify(...) or, if the intent is to consume, change the API to take self by value (one-shot verifier) or restore the value after the call. Replace unwrap() with error propagation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in provekit/verifier/src/lib.rs at the Verify implementation for Verifier::verify. Check how whir_for_witness is handled when it is absent and when verification is called repeatedly. Done means verification returns an error instead of panicking and does not make the verifier unusable after a call.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.