Skip to content

[Medium-1] Verifier panics on short hashes vector #34

@this-vishalsingh

Description

@this-vishalsingh

Context: src/signature/generalized_xmss.rs

Description:

verify() indexes sig.hashes[chain_index] without first checking sig.hashes.len() == IE::DIMENSION.

A malicious signature (e.g., decoded from SSZ/serde) with an empty/short hashes vector will trigger an out-of-bounds panic, crashing the verifier (remote DoS in any service that verifies untrusted signatures).

Impact

  • Bug type: Resource management
  • Code:
// ...
let chain_length = IE::BASE;
let num_chains = IE::DIMENSION;
// ...
for (chain_index, xi) in x.iter().enumerate() {
    let steps = (chain_length - 1) as u8 - xi;
    let start_pos_in_chain = *xi;
    let start = &sig.hashes[chain_index];
    let end = chain::<TH>(
        &pk.parameter,
        epoch,
        chain_index as u8,
        start_pos_in_chain,
        steps as usize,
        start,
    );
    chain_ends.push(end);
}
// ...

Recommendation

Before the loop, validate sig.hashes.len() == IE::DIMENSION (and ideally reject any other length early in SSZ/serde decoding).

Return false on mismatch instead of panicking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions