Skip to content

Commit

Permalink
fix(sigmap-EDAP-01): Missing nil Checks On Parameters Of Incoming Req…
Browse files Browse the repository at this point in the history
…uests
  • Loading branch information
epociask committed Jan 9, 2025
1 parent 0fb5ae8 commit c26f7bd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions store/generated_key/eigenda/eigenda.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions verify/certificate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package verify

import (
"fmt"
"math/big"

"github.com/Layr-Labs/eigenda/api/grpc/disperser"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit c26f7bd

Please sign in to comment.