From c26f7bd560c9ec0d3e748ff8d357eef26cd709a4 Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Fri, 10 Jan 2025 01:06:37 +0700 Subject: [PATCH] fix(sigmap-EDAP-01): Missing nil Checks On Parameters Of Incoming Requests --- store/generated_key/eigenda/eigenda.go | 10 ++++++++++ verify/certificate.go | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/store/generated_key/eigenda/eigenda.go b/store/generated_key/eigenda/eigenda.go index b67ce1d2..9922b32e 100644 --- a/store/generated_key/eigenda/eigenda.go +++ b/store/generated_key/eigenda/eigenda.go @@ -59,6 +59,11 @@ func (e Store) Get(ctx context.Context, key []byte) ([]byte, error) { return nil, fmt.Errorf("failed to decode DA cert to RLP format: %w", err) } + err = cert.NoNilFields() + if err != nil { + return nil, fmt.Errorf("failed to verify DA cert: %w", err) + } + decodedBlob, err := e.client.GetBlob(ctx, cert.BlobVerificationProof.BatchMetadata.BatchHeaderHash, cert.BlobVerificationProof.BlobIndex) if err != nil { return nil, fmt.Errorf("EigenDA client failed to retrieve decoded blob: %w", err) @@ -119,6 +124,11 @@ func (e Store) Put(ctx context.Context, value []byte) ([]byte, error) { } cert := (*verify.Certificate)(blobInfo) + err = cert.NoNilFields() + if err != nil { + return nil, fmt.Errorf("failed to verify DA cert: %w", err) + } + err = e.verifier.VerifyCommitment(cert.BlobHeader.Commitment, encodedBlob) if err != nil { return nil, fmt.Errorf("failed to verify commitment: %w", err) diff --git a/verify/certificate.go b/verify/certificate.go index 9defd894..ee68ef0e 100644 --- a/verify/certificate.go +++ b/verify/certificate.go @@ -1,6 +1,7 @@ package verify import ( + "fmt" "math/big" "github.com/Layr-Labs/eigenda/api/grpc/disperser" @@ -29,6 +30,19 @@ type BlobHeader struct { type Certificate disperser.BlobInfo +// NoNilFields ... check if struct pointer fields are nil +func (c *Certificate) NoNilFields() error { + if c.BlobVerificationProof == nil { + return fmt.Errorf("BlobVerificationProof is nil") + } + + if c.BlobHeader == nil { + return fmt.Errorf("BlobHeader is nil") + } + + return nil +} + func (c *Certificate) BlobIndex() uint32 { return c.BlobVerificationProof.BlobIndex }