diff --git a/protocol/attestation.go b/protocol/attestation.go index 144fd7c..55c76c6 100644 --- a/protocol/attestation.go +++ b/protocol/attestation.go @@ -157,23 +157,28 @@ func (a *AttestationObject) VerifyAttestation(clientDataHash []byte, mds metadat return nil } - formatHandler, valid := attestationRegistry[AttestationFormat(a.Format)] - if !valid { + var ( + handler attestationFormatValidationHandler + valid bool + ) + + if handler, valid = attestationRegistry[AttestationFormat(a.Format)]; !valid { return ErrAttestationFormat.WithInfo(fmt.Sprintf("Attestation format %s is unsupported", a.Format)) } + var ( + aaguid uuid.UUID + attestationType string + x5cs []any + ) + // Step 14. Verify that attStmt is a correct attestation statement, conveying a valid attestation signature, by using // the attestation statement format fmt’s verification procedure given attStmt, authData and the hash of the serialized // client data computed in step 7. - attestationType, x5cs, err := formatHandler(*a, clientDataHash, mds) - if err != nil { + if attestationType, x5cs, err = handler(*a, clientDataHash, mds); err != nil { return err.(*Error).WithInfo(attestationType) } - var ( - aaguid uuid.UUID - ) - if len(a.AuthData.AttData.AAGUID) != 0 { if aaguid, err = uuid.FromBytes(a.AuthData.AttData.AAGUID); err != nil { return ErrInvalidAttestation.WithInfo("Error occurred parsing AAGUID during attestation validation").WithDetails(err.Error()).WithError(err) diff --git a/protocol/metadata.go b/protocol/metadata.go index da48cb8..01af76a 100644 --- a/protocol/metadata.go +++ b/protocol/metadata.go @@ -36,7 +36,7 @@ func ValidateMetadata(ctx context.Context, mds metadata.Provider, aaguid uuid.UU return nil } - if mds.GetValidateAttestationTypes(ctx) { + if mds.GetValidateAttestationTypes(ctx) && attestationType != "" { found := false for _, atype := range entry.MetadataStatement.AttestationTypes { diff --git a/webauthn/login.go b/webauthn/login.go index 9c73b34..a474ec6 100644 --- a/webauthn/login.go +++ b/webauthn/login.go @@ -349,7 +349,7 @@ func (webauthn *WebAuthn) validateLogin(user User, session SessionData, parsedRe var protoErr *protocol.Error - if protoErr = protocol.ValidateMetadata(context.Background(), webauthn.Config.MDS, aaguid, credential.AttestationType, nil); protoErr != nil { + if protoErr = protocol.ValidateMetadata(context.Background(), webauthn.Config.MDS, aaguid, "", nil); protoErr != nil { return nil, protocol.ErrBadRequest.WithDetails("Failed to validate credential record metadata").WithInfo(protoErr.DevInfo).WithError(protoErr) } }