[M-2] Unchecked try_into unwrap may panic

Open Beginner friendly
#266 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start in provekit/verifier/src/whir_r1cs.rs and inspect the try_into().unwrap() calls at lines 100–103 and 148–150 in the dual- and single-commitment paths. Trace the verifier error type and conversion patterns used nearby, then exercise malformed hint-vector inputs. Done means incorrect prover-controlled lengths return a controlled verification error instead of panicking.

Written by the indexing model from the issue text.

Description

Context: provekit/verifier/src/whir_r1cs.rs

Description

The verifier uses try_into().unwrap() on prover-controlled hint vectors to convert them into fixed-size arrays (e.g., [FieldElement; 3]). If a maliciously crafted proof provides hint vectors of incorrect length, these unwrap calls will panic, crashing the verifier.

Affected code paths:

  • Dual-commitment mode: lines 100–103
  • Single-commitment mode: lines 148–150

A malicious prover can exploit this to perform a denial-of-service attack by sending malformed proofs that trigger the unwrap panics.

  • Impacted code
let whir_sums_1: ([FieldElement; 3], [FieldElement; 3]) = (sums_1.0.try_into().unwrap(), sums_1.1.try_into().unwrap());
...
let whir_sums: ([FieldElement; 3], [FieldElement; 3]) = (sums.0.try_into().unwrap(), sums.1.try_into().unwrap());
Recommendation

Replace try_into().unwrap() with fallible conversions that return an error (for example, using try_into().context(...) or ensure!) so that malformed proofs produce a controlled verification error rather than a panic.

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

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.

More from worldfnd/provekit

All issues in worldfnd/provekit

Similar issues

More Cryptography issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.