Skip to content

fix(zkvm): halt with invalid hint when read_vec length rounding overflows - #3012

Closed
MatusKysel wants to merge 1 commit into
succinctlabs:mainfrom
MatusKysel:fix/read-vec-hint-len-overflow
Closed

MatusKysel wants to merge 1 commit into
succinctlabs:mainfrom
MatusKysel:fix/read-vec-hint-len-overflow

Conversation

@MatusKysel

@MatusKysel MatusKysel commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

read_vec_raw rounds the prover-supplied HINT_LEN up to a multiple of 8 with (len + 7) / 8 * 8. A length in [usize::MAX - 6, usize::MAX - 1] wraps the capacity to 0, so the input pointer isn't advanced and read_vec builds a Vec with len > capacity. The honest executor can't produce such a length, but HINT_LEN is only range-checked, so a malicious prover can.

Solution

Use checked_next_multiple_of(8) and halt with exit code 3 (invalid hint) on overflow. Every other length rounds as before.

Checked with an executor patched to return usize::MAX - 6: exit 0 with the forged len/capacity before, exit 3 after. There's no automated test because the executor can't forge HINT_LEN.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

…lows

read_vec_raw rounded the prover-supplied HINT_LEN up to a multiple of 8
with unchecked arithmetic. A length in [usize::MAX - 6, usize::MAX - 1]
wrapped the capacity to 0, so the input pointer was not advanced and
read_vec/read built a Vec with len > capacity via Vec::from_raw_parts.

Use checked rounding and halt with exit code 3 (invalid hint) when it
overflows. No real input can be that long, so honest executions are
unaffected.
@MatusKysel

Copy link
Copy Markdown
Contributor Author

Superseded by d3d90aa (feat: improve zkvm allocators), which makes the rounding checked and asserts len <= capacity in read_vec/read. The only remaining difference would be exit code 3 instead of 1 on overflow, which only matters under experimental and would not cover the other bad-length panics in read_vec_raw anyway. Closing.

@MatusKysel MatusKysel closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant