In lib/proto/circuit.h, CircuitRep::from_bytes() has off-by-one bounds checks for quad gate and wire indices:
// `lib/proto/circuit.h:215` – comment says "index of quad must be < wires in the layer"
if (g > max_g) return nullptr; // accepts g == max_g (one-past-end)
// `lib/proto/circuit.h:220`
if (hl > nw || hr > nw) return nullptr; // accepts hl/hr == nw (one-past-end)
lib/proto/circuit.h:224 in the same function uses the correct >= pattern for an analogous constant-index check (if (vi >= numconst)), confirming the inconsistency.
These boundary values are later dereferenced without bounds checks.
A malformed circuit blob with a single quad index at the boundary value (g == max_g or h == nw) is sufficient to trigger OOB on prover evaluation, and can also trigger OOB on verifier-side EQ indexing.
Fix: Change > to >= in both checks.
In
lib/proto/circuit.h, CircuitRep::from_bytes() has off-by-one bounds checks for quad gate and wire indices:lib/proto/circuit.h:224in the same function uses the correct>=pattern for an analogous constant-index check (if (vi >= numconst)), confirming the inconsistency.These boundary values are later dereferenced without bounds checks.
A malformed circuit blob with a single quad index at the boundary value (
g == max_gorh == nw) is sufficient to trigger OOB on prover evaluation, and can also trigger OOB on verifier-side EQ indexing.Fix: Change
>to>=in both checks.