Skip to content

Commit

Permalink
eth: check propagated block malformation on receiption (ethereum#20546)
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe authored and wanwiset25 committed Jun 28, 2024
1 parent 8f4a269 commit 1204fa9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,14 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
if err := msg.Decode(&request); err != nil {
return errResp(ErrDecode, "%v: %v", msg, err)
}
if hash := types.CalcUncleHash(request.Block.Uncles()); hash != request.Block.UncleHash() {
log.Warn("Propagated block has invalid uncles", "have", hash, "exp", request.Block.UncleHash())
break // TODO(karalabe): return error eventually, but wait a few releases
}
if hash := types.DeriveSha(request.Block.Transactions()); hash != request.Block.TxHash() {
log.Warn("Propagated block has invalid body", "have", hash, "exp", request.Block.TxHash())
break // TODO(karalabe): return error eventually, but wait a few releases
}
if err := request.sanityCheck(); err != nil {
return err
}
Expand Down

0 comments on commit 1204fa9

Please sign in to comment.