Skip to content

Commit c50f298

Browse files
committed
Add some nil checking to validate.go
Calling validate.SnpAttestation with an incomplete attesstation report will lead to nil dereferences instead of meaningful errors without this.
1 parent 68972f3 commit c50f298

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

validate/validate.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,21 @@ func validateKeys(report *spb.Report, options *Options) error {
612612
}
613613

614614
func validateKeyKind(report *spb.Attestation) (*x509.Certificate, error) {
615+
if report == nil {
616+
return nil, fmt.Errorf("attestation cannot be nil")
617+
}
618+
if report.GetReport() == nil {
619+
return nil, fmt.Errorf("attestation report cannot be nil")
620+
}
621+
if report.GetCertificateChain() == nil {
622+
return nil, fmt.Errorf("attestation certificate chain cannot be nil")
623+
}
624+
615625
info, err := abi.ParseSignerInfo(report.GetReport().GetSignerInfo())
616626
if err != nil {
617627
return nil, err
618628
}
629+
619630
switch info.SigningKey {
620631
case abi.VcekReportSigner:
621632
if len(report.GetCertificateChain().VcekCert) != 0 {

0 commit comments

Comments
 (0)