Skip to content

Commit

Permalink
fix: check the credential id length att data (#16)
Browse files Browse the repository at this point in the history
This checks the credential id length based on the spec. See https://w3c.github.io/webauthn/#attested-credential-data.
  • Loading branch information
james-d-elliott committed Mar 1, 2022
1 parent 729227d commit b3b93ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion protocol/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"github.com/go-webauthn/webauthn/protocol/webauthncbor"
)

var (
const (
minAuthDataLength = 37
minAttestedAuthLength = 55
maxCredentialIDLength = 1023
)

// Authenticators respond to Relying Party requests by returning an object derived from the
Expand Down Expand Up @@ -218,6 +219,10 @@ func (a *AuthenticatorData) unmarshalAttestedData(rawAuthData []byte) (err error
return ErrBadRequest.WithDetails("Authenticator attestation data length too short")
}

if idLength > maxCredentialIDLength {
return ErrBadRequest.WithDetails("Authenticator attestation data credential id length too long")
}

a.AttData.CredentialID = rawAuthData[55 : 55+idLength]

a.AttData.CredentialPublicKey, err = unmarshalCredentialPublicKey(rawAuthData[55+idLength:])
Expand Down

0 comments on commit b3b93ac

Please sign in to comment.