From 1204fa954f171c4019655ba7d2af18888236fd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 13 Jan 2020 15:19:14 +0200 Subject: [PATCH] eth: check propagated block malformation on receiption (#20546) --- eth/handler.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eth/handler.go b/eth/handler.go index b2f0b39a9c..0872040e55 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -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 }