sei-protocol / sei-tendermint

Tendermint fork with ABCI++ support, bug fixes, and custom features
Other
38 stars 36 forks source link

Missing validation of priorities in validateset in Header and Many Other Known Security Issues are Unsolved #246

Open Hellobloc opened 6 days ago

Hellobloc commented 6 days ago

The header hash was generated with a missing hash of the validateset's priorities information. A malicious user could modify the priorities without causing a state hash validation error. Remarkably this is a known issue in Cometbft that breaks the state hash validation for priorities. https://github.com/sei-protocol/sei-tendermint/blob/main/types/validator_set.go#L344-L350

/types/validator.go
type Validator struct {
    Address     Address       `json:"address"`
    PubKey      crypto.PubKey `json:"pub_key"`
    VotingPower int64         `json:"voting_power"`

    ProposerPriority int64 `json:"proposer_priority"`
}
...
types/validator_set.go
func (vals *ValidatorSet) Hash() []byte {
    bzs := make([][]byte, len(vals.Validators))
    for i, val := range vals.Validators {
        bzs[i] = val.Bytes()
    }
    return merkle.HashFromByteSlices(bzs)
}
...
/types/validator.go
func (v *Validator) Bytes() []byte {
    pk, err := ce.PubKeyToProto(v.PubKey)
    if err != nil {
        panic(err)
    }

    pbv := cmtproto.SimpleValidator{
        PubKey:      &pk,
        VotingPower: v.VotingPower,
    }

    bz, err := pbv.Marshal()
    if err != nil {
        panic(err)
    }
    return bz
}

Sei-tendermint implemented its own consensus protocol using cometbft's fork project, but many of the flaws that were fixed in cometbft were not fixed by that project, and this issue is one of them. More information is shown below: Other Unsolved issues' Fix PR and Commits: https://github.com/cometbft/cometbft/pull/3984 https://github.com/cometbft/cometbft/pull/3369 https://github.com/cometbft/cometbft/commit/d766d20c0609e3018e26f30aadf91bd322f8cad9 https://github.com/cometbft/cometbft/pull/890 https://github.com/cometbft/cometbft/pull/865

Hellobloc commented 6 days ago

@jewei1997 @yzang2019 @codchen

Hellobloc commented 2 days ago

@blindchaser