Summary
A quorum verification flaw in Nimiq's Rust block primitives allows malicious validators to bypass SkipBlockProof::verify by abusing integer truncation and inadequate input validation on signer indices.
By crafting MultiSignature.signers entries with out-of-range indices that collide when cast from usize to u16, an attacker can make a small set of real signatures appear to meet the required 2f+1 quorum threshold and have an invalid skip block proof accepted.
Affected context
This vulnerability affects systems using the nimiq-block Rust crate for consensus-related operations, specifically where SkipBlockProof::verify is relied upon to validate BLS multi-signature-based skip block proofs.
The issue manifests when MultiSignature.signers is treated as a trusted set of signer indices and these indices are used both to compute quorum size via BitSet.len() and to index into slot tables after being cast down to u16. Deployments are at risk when untrusted or semi-trusted parties can propose or relay skip block proofs that are then verified by honest nodes.
Exploit preconditions
- Attack surface: Consensus / block validation layer, specifically skip block proof verification using
SkipBlockProof::verify. - Required access: Ability to submit or influence skip block proofs (e.g., as a validator or protocol participant capable of proposing or relaying blocks/proofs).
- Trigger point: Verification of a crafted
SkipBlockProofwhoseMultiSignature.signersbitset includes carefully chosen out-of-range indices. - Why exploitation is possible:
- The quorum count is derived from
BitSet.len(), which reflects the number of set bits, including those at large indices. - The same indices are later cast from
usizetou16(slot as u16) for slot lookup. - Indices separated by multiples of 65536 (2^16) map to the same
u16value, causing multiple logically distinct signer slots to collide onto the same real slot. - A malicious validator can inflate the apparent number of signers while actually controlling far fewer real slots, then multiply a single valid BLS signature to match the inflated count.
Why this happens
The core problem is a combination of insufficient input validation (CWE-20) and integer handling errors (CWE-190) in security-critical quorum calculations.
At a high level:
- The code treats the
MultiSignature.signersbitset as if all set bits correspond to valid, in-range validator slots without enforcing a strict upper bound. - It computes quorum membership using
BitSet.len(), a metric that can be inflated by placing bits at arbitrarily large indices. - It later truncates those indices from
usizetou16for slot lookup, assuming the reduction is safe. This introduces index collisions where indices differing by multiples of 65536 resolve to the sameu16slot.
This behavior maps to:
- CWE-20: Improper Input Validation: the signer indices are not validated against the expected slot range before being used to compute quorum.
- CWE-190: Integer Overflow or Wraparound: casting from a wider integer type to a narrower one discards high-order bits, effectively causing wraparound / truncation.
- CWE-345: Insufficient Verification of Data Authenticity: the multi-signature and corresponding signer set are not tightly bound in a way that prevents index manipulation and multiplicity tricks.
- CWE-1284: Improper Validation of Integrity Check Value: the aggregate signature and signer set are accepted as a valid integrity proof without robust checks that each counted signer corresponds to a unique, valid validator slot.
Conceptually, the bug is: "Quorum and aggregation logic trusts an attacker-controlled set of indices, then silently truncates those indices when mapping them onto a smaller domain," which is an insecure pattern in any consensus, voting, or multi-signature system.
Potential impact
- A malicious validator can cause skip block proofs to be accepted with far fewer than the required
2f+1real signatures. - Consensus nodes may accept blocks or skip blocks that do not actually meet the intended quorum, undermining fault tolerance assumptions.
- Adversaries could accelerate or manipulate chain progression by forging apparent agreement, potentially enabling:
- Chain reordering or censorship scenarios.
- Safety violations where conflicting histories are both considered valid by different nodes.
- Reduced resiliency against collusion or partial validator compromise, as fewer keys are needed to simulate a full quorum.
General mitigation guidance
Effective mitigation focuses on correctly binding signer identities to indices and eliminating unsafe integer truncation in verification logic.
Useful defensive patterns include:
- Strong range validation on indices:
- Treat all signer indices as untrusted input.
- Enforce that every index falls within the valid validator slot range before counting it toward quorum or using it for lookups.
- Consistent integer types for indices:
- Use a single, explicit type for validator indices across the codebase (e.g., a domain-specific
ValidatorIndexnewtype) to avoid accidental narrowing conversions. - Avoid casts from wider to narrower integer types in consensus-critical code; if necessary, use checked conversions that fail on out-of-range values.
- Deduplication and uniqueness checks:
- Ensure each counted signer corresponds to a unique, valid slot.
- Reject proofs where multiple indices map to the same logical validator due to truncation or encoding quirks.
- Tight binding between signatures and signer sets:
- Architect the multi-signature scheme so that the aggregate signature, signer list/bitset, and validator set are cryptographically and structurally linked, leaving no room for index manipulation.
- Defensive coding patterns in consensus logic:
- Treat consensus verification as a high-assurance boundary with explicit assertions and invariants (e.g., "no out-of-range indices", "no duplicate signers").
- Favor clear, auditable logic over micro-optimizations in these paths.
How teams detect issues like this
Detection should focus on identifying unsafe index handling and trust of attacker-controlled indices in consensus or cryptographic verification code.
Potential strategies:
- Static analysis and linting:
- Flag casts from wider integer types (e.g.,
usize) to narrower ones (e.g.,u16) in security-critical modules. - Detect unchecked conversions such as
ascasts in Rust whereTryFromorchecked_*variants should be used. - Highlight uses of bitsets or collections where element indices come from untrusted data and are not range-checked before use.
- Targeted code review practices:
- Review all implementations of quorum checks, multi-signature aggregation, and consensus verification for:
- Assumptions about index ranges and uniqueness.
- Silent truncation, wraparound, or overflow behavior.
- Reliance on collection lengths (
len(), bit counts) that can be manipulated by adversaries. - Property- and fuzz-based testing:
- Use fuzzers to generate signer bitsets with large, sparse, or malformed indices and verify that the implementation never:
- Counts out-of-range indices toward quorum.
- Accepts proofs where multiple indices collide onto the same logical validator.
- Add invariants to tests, such as "accepted proof ⇒ each counted signer is within range and unique".
- Automated review tools:
- Integrate Rust-specific security linters and custom Clippy lints into CI to flag unsafe integer casts and missing range checks.
- Use formal verification or model checking for critical consensus components where feasible.

