Commit fb0cacc9 authored by Adam Langley's avatar Adam Langley Committed by Commit Bot

Reject U2F assertion responses that assert CTAP2 flags.

(This doesn't apply to U2F register responses because there's no flags
byte there.)

Bug: 896980
Change-Id: I02c63d4bc63db4a8e2e7256a428d8349c34f5443
Reviewed-on: https://chromium-review.googlesource.com/c/1355242
Commit-Queue: Adam Langley <agl@chromium.org>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: default avatarMartin Kreichgauer <martinkr@google.com>
Cr-Commit-Position: refs/heads/master@{#612300}
parent ecc7ffae
...@@ -36,9 +36,15 @@ AuthenticatorGetAssertionResponse::CreateFromU2fSignResponse( ...@@ -36,9 +36,15 @@ AuthenticatorGetAssertionResponse::CreateFromU2fSignResponse(
if (key_handle.empty()) if (key_handle.empty())
return base::nullopt; return base::nullopt;
auto flags = u2f_data.subspan<kFlagIndex, kFlagLength>(); auto flags = u2f_data.subspan<kFlagIndex, kFlagLength>()[0];
if (flags &
(static_cast<uint8_t>(AuthenticatorData::Flag::kExtensionDataIncluded) |
static_cast<uint8_t>(AuthenticatorData::Flag::kAttestation))) {
// U2F responses cannot assert CTAP2 features.
return base::nullopt;
}
auto counter = u2f_data.subspan<kCounterIndex, kCounterLength>(); auto counter = u2f_data.subspan<kCounterIndex, kCounterLength>();
AuthenticatorData authenticator_data(relying_party_id_hash, flags[0], counter, AuthenticatorData authenticator_data(relying_party_id_hash, flags, counter,
base::nullopt); base::nullopt);
auto signature = auto signature =
......
...@@ -530,6 +530,21 @@ TEST(CTAPResponseTest, TestParseU2fSignWithNullResponse) { ...@@ -530,6 +530,21 @@ TEST(CTAPResponseTest, TestParseU2fSignWithNullResponse) {
EXPECT_FALSE(response); EXPECT_FALSE(response);
} }
TEST(CTAPResponseTest, TestParseU2fSignWithCTAP2Flags) {
std::vector<uint8_t> sign_response = GetTestSignResponse();
// Set two flags that should only be set in CTAP2 responses and expect parsing
// to fail.
sign_response[0] |=
static_cast<uint8_t>(AuthenticatorData::Flag::kExtensionDataIncluded);
sign_response[0] |=
static_cast<uint8_t>(AuthenticatorData::Flag::kAttestation);
auto response = AuthenticatorGetAssertionResponse::CreateFromU2fSignResponse(
test_data::kApplicationParameter, sign_response,
GetTestCredentialRawIdBytes());
EXPECT_FALSE(response);
}
TEST(CTAPResponseTest, TestParseU2fSignWithNullCorruptedCounter) { TEST(CTAPResponseTest, TestParseU2fSignWithNullCorruptedCounter) {
// A sign response of less than 5 bytes. // A sign response of less than 5 bytes.
auto response = AuthenticatorGetAssertionResponse::CreateFromU2fSignResponse( auto response = AuthenticatorGetAssertionResponse::CreateFromU2fSignResponse(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment