Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check the credential id length att data #16

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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