Skip to content

Commit

Permalink
fix: verify AAGUID match for packed basic attestation
Browse files Browse the repository at this point in the history
  • Loading branch information
bdewater committed Mar 12, 2019
1 parent fa80397 commit 1e6ba27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/webauthn/attestation_statement/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module AttestationStatement
class Base
class NotSupportedError < Error; end

AAGUID_EXTENSION_OID = "1.3.6.1.4.1.45724.1.1.4"

def initialize(statement)
@statement = statement
end
Expand Down
13 changes: 13 additions & 0 deletions lib/webauthn/attestation_statement/packed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def valid?(authenticator_data, client_data_hash)
valid_format? &&
valid_certificate_chain?(authenticator_data.credential) &&
meet_certificate_requirement? &&
matching_aaguid?(authenticator_data.attested_credential_data.aaguid) &&
valid_signature?(authenticator_data, client_data_hash) &&
attestation_type_and_trust_path
end
Expand Down Expand Up @@ -79,6 +80,18 @@ def meet_certificate_requirement?
end
end

def matching_aaguid?(attested_credential_data_aaguid)
extension = attestation_certificate&.extensions&.detect { |ext| ext.oid == AAGUID_EXTENSION_OID }
if extension
# `extension.value` mangles data into ASCII, so we must manually compare bytes
# see https://github.com/ruby/openssl/pull/234
extension.to_der[-WebAuthn::AuthenticatorData::AttestedCredentialData::AAGUID_LENGTH..-1] ==
attested_credential_data_aaguid
else
true
end
end

def valid_signature?(authenticator_data, client_data_hash)
(attestation_certificate&.public_key || authenticator_data.credential.public_key_object).verify(
"SHA256",
Expand Down

0 comments on commit 1e6ba27

Please sign in to comment.