Skip to content

Incorrect merkle validation in process_deposit #703

Closed
@gnattishness

Description

@gnattishness

What is wrong?

process_deposit accepts deposits with an invalid merkle proof as valid

https://github.com/status-im/nim-beacon-chain/blob/257771d9af971621dc73b572c56d5e856ac75ad5/beacon_chain/spec/beaconstate.nim#L57-L70

How can it be fixed

  1. process_deposit should fail if is_valid_merkle_branch() is false e.g. return false
  2. is_valid_merkle_branch() should be called with depth=DEPOSIT_CONTRACT_TREE_DEPTH + 1 according to the spec (https://github.com/ethereum/eth2.0-specs/blob/v0.10.1/specs/phase0/beacon-chain.md#deposits)

How it was found

Discovered via beacon-fuzz (initial testing of deposit fuzzer).
Triggering case: nim-deposit-crash-5d4907f2962783d3806b93bfe1a5f4c808b1c3bf with the following beacon_states
Or the pre-processed input deposit_preprocessed_invalid_merkle.ssz can be directly passed to the nimbus harness nfuzz_deposit

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