Skip to content

Commit 35287ea

Browse files
fix: check the credential id length att data (#16)
This checks the credential id length based on the spec. See https://w3c.github.io/webauthn/#attested-credential-data.
1 parent dfd0c65 commit 35287ea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

protocol/authenticator.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"github.com/go-webauthn/webauthn/protocol/webauthncbor"
99
)
1010

11-
var (
11+
const (
1212
minAuthDataLength = 37
1313
minAttestedAuthLength = 55
14+
maxCredentialIDLength = 1023
1415
)
1516

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

207+
if idLength > maxCredentialIDLength {
208+
return ErrBadRequest.WithDetails("Authenticator attestation data credential id length too long")
209+
}
210+
206211
a.AttData.CredentialID = rawAuthData[55 : 55+idLength]
207212

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

0 commit comments

Comments
 (0)