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

Also validate revocation reasons in attestation #119

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
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
25 changes: 24 additions & 1 deletion src/Service/AuthenticatorStatusValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class AuthenticatorStatusValidator
* @var string[]
*/
private readonly array $allowedStatus;
/**
* @var string[]
*/
private readonly array $deniedStatus;


public function __construct()
{
Expand All @@ -44,6 +49,13 @@ public function __construct()
AuthenticatorStatus::FIDO_CERTIFIED_L2plus,
AuthenticatorStatus::FIDO_CERTIFIED_L3plus,
];
$this->deniedStatus = [
AuthenticatorStatus::REVOKED,
AuthenticatorStatus::ATTESTATION_KEY_COMPROMISE,
AuthenticatorStatus::USER_KEY_PHYSICAL_COMPROMISE,
AuthenticatorStatus::USER_KEY_REMOTE_COMPROMISE,
AuthenticatorStatus::USER_VERIFICATION_BYPASS
];
}

/**
Expand All @@ -57,18 +69,29 @@ public function validate(array $statusReports): void
$meetsRequirement = false;
$reportsProcessed = 0;
$reportLog = [];
/* The status of the attestation can be multivalued, containing both a certification as a revocation.
First test for valid certification, then for reasons to deny
*/
foreach ($statusReports as $report) {
if (in_array($report->status, $this->allowedStatus)) {
$meetsRequirement = true;
}
$reportsProcessed++;
$reportLog[] = $report->status;
}
if ($meetsRequirement) {
foreach ($statusReports as $report) {
if (in_array($report->status, $this->deniedStatus)) {
$meetsRequirement = false;
}
}
}

if (!$meetsRequirement) {
throw new AuthenticatorStatusNotSupportedException(
sprintf(
'Of the %d StatusReports tested, none met one of the required FIDO Certified statuses. ' .
'Of the %d StatusReports tested, none met one of the required FIDO Certified statuses,
or the status was explicitly denied. ' .
'Reports tested: "%s"',
$reportsProcessed,
implode(', ', $reportLog)
Expand Down
1 change: 1 addition & 0 deletions tests/Service/AuthenticatorStatusValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function invalidReports()
'invalid UPDATE_AVAILABLE' => [[$this->createReport(AuthenticatorStatus::UPDATE_AVAILABLE)]],
'invalid REVOKED' => [[$this->createReport(AuthenticatorStatus::REVOKED)]],
'invalid mixed, all bad' => [[$this->createReport(AuthenticatorStatus::UPDATE_AVAILABLE), $this->createReport(AuthenticatorStatus::NOT_FIDO_CERTIFIED)]],
'invalid FIDO_CERTIFIED and REVOKED' => [[$this->createReport(AuthenticatorStatus::REVOKED), $this->createReport(AuthenticatorStatus::FIDO_CERTIFIED)]],
];
}
final public const USER_VERIFICATION_BYPASS = '';
Expand Down