Skip to content
Get started
Bastionary › Knowledge base › MFA and passkeys

Passkey account recovery: the hard problem nobody warns you about

By Bastionary · MFA and passkeys

Passkeys solve the password problem by never letting a shared secret exist. The private key sits in a hardware authenticator or a synced keychain, and the server only ever sees a public key and a signature. That is exactly why recovery is hard: there is no secret to email back to the user, no "reset link" that restores access, and no fallback you can bolt on without quietly reopening the phishing door you just closed.

The question is not academic. A user drops their only phone in a lake, or a laptop is stolen, or an employee leaves and their device is wiped. The account still exists; the credential that proves ownership does not. How you answer that determines whether your passkey rollout is genuinely phishing-resistant or just phishing-resistant until someone gets locked out.

Why "just send a reset email" defeats the point

The instinct is to fall back to email. But email-based recovery means an attacker who controls the inbox can mint a new passkey and take the account. You have spent engineering effort removing the phishable factor from the front door, then left it propped open at the side. The strength of your authentication is now exactly the strength of the weakest recovery path, which is email plus whatever protects the mailbox.

This is the recovery paradox: the easier recovery is for a legitimate user, the easier it is for an attacker. You cannot escape the tradeoff, but you can shape it so the easy paths are low-privilege and the high-privilege paths are deliberately slow.

Enroll more than one credential, up front

The single most effective thing you can do is make account loss rare by design. At enrollment, nudge the user to register at least two authenticators: the platform passkey on their phone and a second one, ideally a roaming security key or a passkey synced to a different ecosystem. WebAuthn supports many credentials per account for exactly this reason.

Treat a single registered credential as a degraded state and surface it. A persistent banner that says "You have one way to sign in. Add a backup so you are not locked out" converts far better than a recovery flow invoked in a panic.

Rule of thumb: count credentials, not users. An account with one passkey is one dropped phone away from a support ticket. An account with two independent authenticators almost never needs recovery at all.

Recovery codes: the honest fallback

When a user genuinely has no registered authenticator left, a pre-generated recovery code is the cleanest option because the user had to possess it before the emergency. Generate a set of single-use codes at enrollment, show them once, and store only hashes. A code redeems into a time-boxed, high-friction window where the user can register a fresh passkey.

// Issue single-use recovery codes at enrollment. Store only the hash.
import { randomBytes, timingSafeEqual, scryptSync } from "node:crypto";

function generateRecoveryCodes(count = 10): { display: string[]; hashes: string[] } {
  const display: string[] = [];
  const hashes: string[] = [];
  for (let i = 0; i < count; i++) {
    const code = randomBytes(10).toString("base64url"); // ~80 bits
    display.push(code);
    const salt = randomBytes(16);
    const hash = scryptSync(code, salt, 32);
    hashes.push(`${salt.toString("hex")}:${hash.toString("hex")}`);
  }
  return { display, hashes }; // show `display` exactly once; persist `hashes`
}

function verifyRecoveryCode(input: string, stored: string): boolean {
  const [saltHex, hashHex] = stored.split(":");
  const candidate = scryptSync(input, Buffer.from(saltHex, "hex"), 32);
  const expected = Buffer.from(hashHex, "hex");
  return candidate.length === expected.length && timingSafeEqual(candidate, expected);
}

A redeemed code must be invalidated immediately, and redemption should not instantly grant a session. It should grant the right to enroll a new credential, after which the user authenticates normally with that new passkey. That extra hop stops a stolen code from being a direct login.

Tier your recovery by privilege

Not every account deserves the same recovery path. Model recovery as tiers and route users based on risk:

  • Low friction: a second registered authenticator. Instant, because possession was already proven.
  • Medium friction: a recovery code plus step-up signals (known device, known network, no recent risky changes). Grants enrollment of a new passkey after a short cool-down.
  • High friction: no code, no device. This is identity re-verification: documentary proof, a video check, or an administrator-mediated process for enterprise tenants, with a mandatory delay and notifications to every channel on file.

The delay matters. A 24-to-72-hour hold on high-tier recovery, during which the legitimate owner is emailed and can cancel, turns a silent takeover into a race the attacker usually loses.

Delegated recovery for organizations

In a B2B context you have a lever consumer apps lack: the tenant administrator. Let an admin re-provision a passkey for a locked-out employee, the same way they offboard someone. This keeps recovery inside an already-trusted relationship and avoids inventing a consumer-grade identity-proofing pipeline. The tradeoff is that the admin account becomes the crown jewel, so it must carry the strongest authentication and the loudest audit trail.

Gotcha: never let a recovery flow silently delete the user's existing passkeys. An attacker who reaches a recovery screen should not be able to lock out the real owner by wiping credentials. Add new authenticators during recovery; remove old ones only after the owner confirms through an independent channel.

Notify, log, and make cancellation easy

Every recovery attempt, successful or not, should fire a notification to all known contact points and land in the audit log with the signals that justified it: IP, device, which tier, which codes were consumed. The notification must contain a one-click "this wasn't me" link that freezes the account. Attackers rely on recovery happening quietly; your job is to make it loud.

Designing the flow end to end

Put together, a defensible passkey recovery system looks like this: push multi-credential enrollment, hand out recovery codes once, tier the fallback paths by privilege and risk, never auto-delete credentials, impose delays on the high-trust paths, and broadcast every attempt. None of these are exotic; they are the difference between a passkey deployment that holds up and one that has a password reset flow hiding behind it.

Recovery is where most passkey projects quietly compromise, because it is the part that does not demo well. But owning your authentication stack means owning the ugly edges too, not just the happy path. If you run your own identity layer, you can decide exactly how these tiers behave, log every attempt where your security team can see it, and tune the friction to your real risk rather than inheriting a vendor's defaults.

Run it yourself

Bastionary is free, open-source software. Follow the quick start to have it running on your own server, or browse the releases on Git.

Get started