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

backport: master to v0.1 #19

Merged
merged 2 commits into from
Mar 1, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
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.
  • Loading branch information
james-d-elliott committed Mar 1, 2022
commit 35287ea54b50b1f553f3cc0f0f5527039f375e2c
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 @@ -203,6 +204,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