Bound untrusted decode paths against allocation DoS - #2
Open
mellowcroc wants to merge 1 commit into
Open
Conversation
Four consumer paths decoded ceremony-derived artifacts before checking the length/count fields that drive allocation, letting a hostile or corrupt input exhaust memory or panic (unrecoverable throw on the native verifier, module abort on wasm): - prover.UnmarshalProof: preflight the BSB22 commitment-count prefix and the exact encoded length before gnark-crypto runs make([]G1Affine, count). Closes a remote unauthenticated OOM on the verifier HTTP API. - wasm-prover fetchCCS: bound the decoded CCS to its signed size, cap the zstd decoder window, and recover() the decode so a hostile length prefix errors instead of aborting the module. - proofassets.ValidatePKIndexAllocations: bound NbWires, NbInfinityA/B, and NbCommitmentKeys against the signed FileSize and section geometry. Applied on the full-index paths (ReadPKIndex, streampk.ValidateIndex); the manifest digest covers only geometry, so the counters were otherwise free. - streampk domain decode: validate the FFT cardinality is canonical before precomputing twiddles, so a hostile 2^32 cardinality is rejected before the ~274 GB allocation. Adds regression tests for the proof and PK-index paths.
mellowcroc
force-pushed
the
audit/ed25519-key-validation
branch
from
August 13, 2026 09:48
4164355 to
dbbfb84
Compare
mellowcroc
force-pushed
the
harden/untrusted-decode-dos
branch
from
August 13, 2026 09:48
96daa63 to
56f410e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four consumer paths decoded ceremony-derived artifacts before checking the
length/count fields that drive allocation, letting a hostile or corrupt input
exhaust memory or panic — an unrecoverable
throwon the native verifier, amodule abort on wasm.
prover.UnmarshalProof— preflight the BSB22 commitment-count prefix andthe exact encoded length before gnark-crypto runs
make([]G1Affine, count).Closes a remote, unauthenticated OOM on the verifier HTTP API (a ~200-byte
body with a
0xFFFFFFFFcount requested ~412 GB).fetchCCS— bound the decoded CCS to its signed size(
io.LimitReader), cap the zstd decoder window (WithDecoderMaxMemory, was64 GiB default), and
recover()the decode so a hostile length prefix errorsinstead of aborting the module.
proofassets.ValidatePKIndexAllocations— boundNbWires,NbInfinityA/B, andNbCommitmentKeysagainst the signedFileSizeandsection geometry. Applied on the full-index paths (
ReadPKIndex,streampk.ValidateIndex); the manifest digest covers only geometry, so thecounters were otherwise free.
(power-of-two with a real generator, bounding it to the field's 2-adicity)
before precomputing twiddles, so a hostile
2^32cardinality is rejectedbefore the ~274 GB allocation.
Adds regression tests for the proof and PK-index paths.
Note: this branch is stacked on
audit/ed25519-key-validation(that branch'son-curve commit already modifies
keysource.go). Againstmainthis PR's difftherefore also includes the audit series; retarget the base to
audit/ed25519-key-validation, or merge that PR first, for a clean diff.