diff --git a/da/blob/types.go b/da/blob/types.go index b7cb254c13..98fa63d432 100644 --- a/da/blob/types.go +++ b/da/blob/types.go @@ -49,6 +49,7 @@ type ConsensusSidecars interface { } type Sidecar interface { + GetIndex() uint64 GetBlob() eip4844.Blob GetKzgProof() eip4844.KZGProof GetKzgCommitment() eip4844.KZGCommitment diff --git a/da/blob/verifier.go b/da/blob/verifier.go index 4fcb94c629..1778695858 100644 --- a/da/blob/verifier.go +++ b/da/blob/verifier.go @@ -78,6 +78,11 @@ func (bv *verifier) verifySidecars( // Verifying that sidecars block headers match with header of the // corresponding block concurrently. for i, s := range sidecars.GetSidecars() { + // This check happens outside the goroutines so that we do not + // process the inclusion proofs before validating the index. + if s.GetIndex() >= bv.chainSpec.MaxBlobsPerBlock() { + return fmt.Errorf("invalid sidecar Index: %d", i) + } g.Go(func() error { var sigHeader = s.GetSignedBeaconBlockHeader() diff --git a/da/types/sidecar.go b/da/types/sidecar.go index 7f6d16fa21..8a9967a2d6 100644 --- a/da/types/sidecar.go +++ b/da/types/sidecar.go @@ -84,6 +84,10 @@ func (b *BlobSidecar) HasValidInclusionProof( ) } +func (b *BlobSidecar) GetIndex() uint64 { + return b.Index +} + func (b *BlobSidecar) GetBlob() eip4844.Blob { return b.Blob }