Zero Config Values Can Crash or Stall the Prover Indefinitely
The prover's shard-splitting code trusts configuration values without checking for zero, so a zero threshold causes a panic or an infinite loop. An attacker who can influence the configuration, for example through environment variables or a large program, could crash or stall proof generation.
johnyfwesh Follow with mohamedfahmy
Originally disclosed on Code4rena
Submitted by johnyfwesh, also found by mohamedfahmy
crates/core/executor/src/record.rs #L201)
ExecutionRecord::split trusts SplitOpts values without guarding against zeros. The per-syscall divisor comes straight from the options (threshold = opts.syscall_threshold[syscall_code]) and is passed to events.chunks_exact(threshold) (crates/core/executor/src/record.rs:201). Rust panics on chunks_exact(0), so any zero threshold crashes the prover during shard generation.
When done == true, the same routine computes capacity = 2 * opts.page_prot and capacity = 2 * opts.memory inside loops that slice init_remaining/finalize_remaining by init_to_take and finalize_to_take (crates/core/executor/src/record.rs:250 and crates/core/executor/src/record.rs:314). If either capacity is zero, both counts stay at zero, the slices never shrink, and the loop spins forever while holding the deferred-record mutex—a CPU-burning DoS.
Nothing prevents these zeros from entering the function. SplitOpts::new divides the remaining trace area by various costs and then truncates to the nearest multiple of 32 via trunc_32 (crates/core/executor/src/opts.rs:83-145, crates/core/executor/src/utils.rs:111). Whenever the quotient drops below 32, the threshold collapses to zero. The only assertion checks available_trace_area >= fixed_trace_area, so reaching exactly zero slack—or any positive slack insufficient for a single chunk—is accepted.
Attackers do not need privileged configuration access:
PrecompileEvents::defaultseeds an entry for everyshould_send()syscall, even when the event list is empty. A zeroed threshold therefore triggerschunks_exact(0)immediately on the first shard (crates/core/executor/src/events/precompiles/mod.rs:246-279).- The public prover APIs propagate
SP1CoreOptsstraight from environment variables or user-supplied configs. A large-yet-valid ELF (≈23.6M instructions) already causesavailable_trace_areato fall below the minimum cost, yielding zero thresholds under default settings. Users can also setHEIGHT_THRESHOLD=1or otherwise override the options to hit the same state.
Affected Code
// crates/core/executor/src/record.rs:188-360
for (syscall_code, events) in precompile_events.into_iter() {
let threshold: usize = opts.syscall_threshold[syscall_code];
let chunks = events.chunks_exact(threshold); // panic when threshold == 0
…
}
let capacity = 2 * opts.page_prot; // zero ⇒ init_to_take == finalize_to_take == 0
let init_to_take = init_remaining.len().min(capacity);
let finalize_to_take = finalize_remaining.len().min(capacity - init_to_take);
…
init_remaining = &init_remaining[init_to_take..]; // never advances when both counts are 0
Impact
- Deterministic panic: Any zero
syscall_thresholdindex triggersslice::chunks_exact(0), terminating the worker thread and aborting proof generation (crates/core/executor/src/record.rs:201). - Livelock/DoS: Zero
memoryorpage_protthresholds trap the splitter in infinite loops, monopolising the record mutex and stalling the prover (crates/core/executor/src/record.rs:250,crates/core/executor/src/record.rs:314). - Attacker-controlled reachability:
SplitOptsisSerialize/Deserialize, exposed through SDK builder APIs, and populated from unvalidated environment variables (crates/core/executor/src/opts.rs:36-56). Large programs or crafted configs make zeros unavoidable under default logic.
View detailed Proof of Concept
Recommended Mitigation
- Enforce minimum values when constructing
SplitOpts(e.g., clamp each threshold to at least1, or wrap them inNonZeroUsizeand surface configuration errors early). - Add defensive assertions in
ExecutionRecord::splitto fail fast if a zero sneaks through, ensuring future regressions are caught during testing. - Consider distributing trace area using
usize::max(value, 1)(or similar) instead of hard truncation viatrunc_32. - Cover these invariants with unit tests that instantiate
SplitOptsnear the boundary conditions.
References
crates/core/executor/src/record.rs:201crates/core/executor/src/record.rs:250crates/core/executor/src/record.rs:314crates/core/executor/src/opts.rs:36-145crates/core/executor/src/utils.rs:111crates/core/executor/src/events/precompiles/mod.rs:246-279
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
Root cause
Likely the code does not validate that configuration values used as divisors or loop capacities are greater than zero before using them.
Impact
A zero threshold causes a deterministic panic or an infinite loop that holds a mutex, stalling the prover; the text says attackers can reach this through unvalidated environment variables or large programs.
What the attacker needed
Ability to influence prover configuration; or a large program that reduces trace area
The fix
The report recommends enforcing minimum values when constructing `SplitOpts`, adding defensive assertions in `ExecutionRecord::split`, and covering boundary conditions with unit tests.
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.
A prover is a program that creates cryptographic proofs. It splits its work into chunks, and the chunk size comes from settings. If a setting is zero, the code either crashes or gets stuck in a loop that never finishes, so the proof never gets made.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.