Skip to content

Commit a1b2775

Browse files
fix(webauthn): skip mds validation for none format (#497)
* fix(webauthn): skip mds validation for none format The attestation format none does not include attestation data and therefore cannot be validated against MDS3 metadata. Previously the login flow attempted to validate it, which caused unnecessary failures for authenticators using the none format. This change ensures that none is explicitly exempt from MDS3 validation, allowing logins with such authenticators to succeed as expected. The registration flow already implements this measure. Fixes #387 * docs: add docs
1 parent 46046ca commit a1b2775

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ table for more information. We also include JSON mappings for those that wish to
6767
| type | N/A | N/A | This field is always `publicKey` for WebAuthn |
6868
| id | ID | id | |
6969
| publicKey | PublicKey | publicKey | |
70+
| attestationFormat | AttestationType | attestationType | This field is currently named incorrectly and this will be corrected. |
7071
| signCount | Authenticator.SignCount | authenticator.signCount | |
7172
| transports | Transport | transport | |
7273
| uvInitialized | Flags.UserVerified | flags.userVerified | |

protocol/attestation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (a *AttestationObject) VerifyAttestation(clientDataHash []byte, mds metadat
214214
return nil
215215
}
216216

217-
if e := ValidateMetadata(context.Background(), mds, aaguid, attestationType, x5cs); e != nil {
217+
if e := ValidateMetadata(context.Background(), mds, aaguid, attestationType, a.Format, x5cs); e != nil {
218218
return ErrInvalidAttestation.WithInfo(fmt.Sprintf("Error occurred validating metadata during attestation validation: %+v", e)).WithDetails(e.DevInfo).WithError(e)
219219
}
220220

protocol/metadata.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ import (
1010
"github.com/go-webauthn/webauthn/metadata"
1111
)
1212

13-
func ValidateMetadata(ctx context.Context, mds metadata.Provider, aaguid uuid.UUID, attestationType string, x5cs []any) (protoErr *Error) {
13+
func ValidateMetadata(ctx context.Context, mds metadata.Provider, aaguid uuid.UUID, attestationType, attestationFormat string, x5cs []any) (protoErr *Error) {
1414
if mds == nil {
1515
return nil
1616
}
1717

18+
if AttestationFormat(attestationFormat) == AttestationFormatNone {
19+
return nil
20+
}
21+
1822
var (
1923
entry *metadata.Entry
2024
err error

webauthn/login.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func (webauthn *WebAuthn) validateLogin(user User, session SessionData, parsedRe
372372
err error
373373
)
374374

375-
// Ensure authenticators with a bad status is not used.
375+
// Ensure authenticators with a bad status are not used.
376376
if webauthn.Config.MDS != nil {
377377
var aaguid uuid.UUID
378378

@@ -382,7 +382,7 @@ func (webauthn *WebAuthn) validateLogin(user User, session SessionData, parsedRe
382382
return nil, protocol.ErrBadRequest.WithDetails("Failed to decode AAGUID").WithInfo(fmt.Sprintf("Error occurred decoding AAGUID from the credential record: %s", err)).WithError(err)
383383
}
384384

385-
if e := protocol.ValidateMetadata(context.Background(), webauthn.Config.MDS, aaguid, "", nil); e != nil {
385+
if e := protocol.ValidateMetadata(context.Background(), webauthn.Config.MDS, aaguid, "", credential.AttestationType, nil); e != nil {
386386
return nil, protocol.ErrBadRequest.WithDetails("Failed to validate credential record metadata").WithInfo(e.DevInfo).WithError(e)
387387
}
388388
}

0 commit comments

Comments
 (0)