Merge pull request #7516 from wbilalz400/fix/webauthn-forced-enrollment-empty-credential

[Web] Fix forced WebAuthn TFA enrollment storing an empty credential
This commit is contained in:
FreddleSpl0it authored and GitHub committed 2026-11-10 15:21:30 +01:00
commit e3a90718c2
3 files changed
+30 -11

No files matched your search

+12
View File
@@ -1394,6 +1394,18 @@ function set_tfa($_data) {
case "webauthn":
$key_id = (!isset($_data["key_id"])) ? 'unidentified' : $_data["key_id"];
// Refuse incomplete WebAuthn registrations. Without this guard a request
// that does not contain the parsed credential data (e.g. a plain form
// POST) would silently insert an empty keyHandle while reporting success.
if (empty($_data['registration']) || empty($_data['registration']->credentialId)) {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_data_log),
'msg' => 'webauthn_registration_failed'
);
return false;
}
$stmt = $pdo->prepare("INSERT INTO `tfa` (`username`, `key_id`, `authmech`, `keyHandle`, `publicKey`, `certificate`, `counter`, `active`)
VALUES (?, ?, 'webauthn', ?, ?, ?, ?, '1')");
$stmt->execute(array(