Skip to main content
← CONCEPTS / SECURITY & IDENTITY
An end-to-end domain learning journey

Passkeys, WebAuthn &
FIDO2 Passwordless Auth.

WebAuthn/FIDO2 replaces passwords with per-site asymmetric keypairs generated inside a user's hardware authenticator, where private keys never leave the device and signatures are cryptographically bound to the exact Relying Party origin.
Start the journey7 sections· Last modified Nov 22, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When untrusted callers cross a trust boundary, WebAuthn & FIDO2 Passwordless Auth, because the browser—not the user—supplies the verified origin into the signed challenge, even a pixel-perfect reverse-proxy phishing site cannot replay a WebAuthn assertion.

TL;DR30-second simplified summary
▾

During registration, the Relying Party issues a CSPRNG challenge and rpId, and the authenticator generates a scoped keypair inside its Secure Enclave/TPM. During login, the authenticator signs authenticatorData || sha256(clientDataJSON).

Because the browser injects the real TLS origin into clientDataJSON, AiTM phishing proxies cannot replay assertions. Production backends must consume challenges atomically (GETDEL) and exempt signCount == 0 for cloud-synced passkeys.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
API Security: OAuth 2.1, JWT & mTLS
Modern API security pairs OAuth 2.0 (for delegated user/client authorization), signed JWTs (for stateless, verifiable claims), and Mutual TLS (mTLS) (for cryptographic workload and high-assurance client identity).
JWT Validation Pitfalls & Hardening (RFC 8725)
Stateless JSON Web Tokens fail catastrophically when verifiers trust header fields (alg, kid, jku), skip audience/issuer checks, or confuse asymmetric public keys with HMAC secrets.
Full walkthrough · 7 stages
01
STAGE 01 · THREAT MODELfoundation

Why Passwords and TOTP Fail Against Reverse-Proxy Phishing.

Why this matters: Establish why shared-secret MFA cannot stop real-time adversary-in-the-middle proxies, whereas origin-bound signatures do.

Even with 6-digit TOTP or SMS codes, an Adversary-in-the-Middle (AiTM) reverse proxy sits between the victim and the legitimate login page, forwarding the username, password, and OTP in real time and stealing the resulting session cookie.

FIDO2/WebAuthn defeats AiTM phishing because the browser enforces origin binding: the authenticator signs the TLS origin observed by the browser (https://evil-login.com), which never matches the legitimate Relying Party's expected origin (https://example.com).

Component Topology

Why Passwords and TOTP Fail Against Reverse-Proxy Phishing

ClientingressEdge GatewaycomputeJWKS / VaultstorageTarget ServicecontrolBearer / mTLSkey lookupscoped call
02
STAGE 02 · REGISTRATIONfoundation

The WebAuthn Registration Ceremony (Attestation).

Why this matters: Trace how a Relying Party issues a challenge and persists a scoped public key without ever seeing a private key.

1.

Server Challenge: RP generates a 32-byte CSPRNG challenge, stores it in short-lived state (e.g., Redis with 5-minute TTL), and specifies rp.id, user.id, and allowed algorithms (-7 ES256, -8 EdDSA). 2. Browser & Authenticator: navigator.credentials.create() invokes the platform authenticator (Touch ID, Windows Hello, Android Biometrics) or roaming key.

WebAuthn Registration Data Flow

RP ServerBrowser APISecure EnclaveRP Credential DB
Engineering Decision Framework
Problem
How to implement Passkeys, WebAuthn & FIDO2 Passwordless Auth without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When untrusted callers cross a trust boundary, webAuthn & FIDO2 Passwordless Auth, because the browser—not the user—supplies the verified origin into the signed challenge, even a pixel-perfect reverse-proxy phishing site cannot replay a WebAuthn assertion.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Passkeys, WebAuthn & FIDO2 Passwordless Auth experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · AUTHENTICATIONintermediate

Assertion Verification, Origin Binding & Replay Protection.

Why this matters: Walk through every cryptographic check the server must perform on a WebAuthn login assertion.

When signing in, navigator.credentials.get() returns authenticatorData, clientDataJSON, and signature.

The RP server must verify all of the following in order:

  • Challenge: clientDataJSON.challenge matches the stored single-use challenge (and delete it immediately to prevent replay).
  • Origin & Type: clientDataJSON.type === 'webauthn.get' and clientDataJSON.origin matches your exact allowlisted HTTPS origin.
  • RP ID Hash: First 32 bytes of authenticatorData equal sha256(expectedRpId).
  • Signature: Verify signature over authenticatorData || sha256(clientDataJSON) using the stored COSE public key.
Lifecycle & Failure Recovery

Assertion Verification, Origin Binding & Replay Protection

check pubkeyRBAC/ABAC matchkid/TTL mismatchUnauthenticatedSignature VerifiedPolicy AllowedExpired / Revoked
04
STAGE 04 · PRODUCTION CODEintermediate

Safe Challenge Lifecycle & Assertion Verification with Atomic Consumption.

Why this matters: Implement replay-safe challenge consumption and signature validation with explicit failure handling and signCount rules.

Always consume challenges atomically (GETDEL in Redis) so concurrent replay attempts fail immediately, and handle synced passkeys (signCount == 0) properly:

import hashlib, json, base64

def verify_assertion(redis_client, session_id, assertion, stored_cred, expected_origin, expected_rp_id):
    # 1. Atomically consume single-use challenge (prevents replay race conditions)
    expected_challenge = redis_client.getdel(f'webauthn:chal:{session_id}')
    if not expected_challenge:
        raise AuthError('Challenge missing, expired, or already consumed')

client_data = json.loads(base64.urlsafe_b64decode(assertion['clientDataJSON'] + '=='))
    if client_data.get('type') != 'webauthn.get' or client_data.get('origin') != expected_origin:
        raise AuthError('Origin or ceremony type mismatch (possible phishing proxy)')
    if client_data.get('challenge') != expected_challenge:
        raise AuthError('Challenge mismatch')

auth_data = base64.urlsafe_b64decode(assertion['authenticatorData'] + '==')
    if auth_data[:32] != hashlib.sha256(expected_rp_id.encode()).digest():
        raise AuthError('RP ID hash mismatch')

# 2. Verify cryptographic signature over auth_data || sha256(clientDataJSON_raw)
    if not verify_cose_signature(stored_cred.public_key, auth_data, assertion['clientDataJSON'], assertion['signature']):
        raise AuthError('Invalid WebAuthn signature')
05
STAGE 05 · DISCOVERABLE CREDENTIALSintermediate

Resident (Discoverable) Keys vs. Enterprise Hardware Keys.

Why this matters: Compare cloud-synced passkeys and hardware-bound FIDO2 keys across recovery, UX, and enterprise attestation.

  • Synced Passkeys (Multi-Device): Stored in iCloud Keychain, Google Password Manager, or 1Password; BE (Backup Eligible) and BS (Backed Up) flags are 1.

Great for consumer UX because losing a phone does not lock out the account. - Device-Bound Keys (Single-Device): YubiKeys or enterprise TPMs where BE=0.

06
STAGE 06 · RECOVERYadvanced

Preventing Lockout Without Weakening Security.

Why this matters: Design multi-passkey enrollment and high-assurance recovery flows so fallback channels do not become the weakest link.

If a user registers a single hardware key and loses it, falling back to an unverified SMS reset reintroduces SIM-swap risk.

Best practices:

  1. Encourage 2+ passkeys (e.g., platform passkey + backup security key or synced password manager).
  2. Use WebAuthn Conditional UI (mediation: 'conditional') for one-tap autofill login.
  3. Gate recovery with high-entropy recovery codes or identity-verified re-enrollment delays.
07
STAGE 07 · GOTCHASadvanced

Subdomain rpId Scope, signCount=0 False Positives & Browser Quirks.

Why this matters: Avoid common production outages caused by misconfigured rpId domains or naive signCount checks.

  • rpId Domain Mismatch: Setting rpId to login.example.com prevents credentials from working on app.example.com.

Use the registrable domain (example.com) if passkeys span subdomains—but never a public suffix. - False Cloned-Key Lockouts: Multi-device synced passkeys intentionally emit signCount = 0.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

An employee clicks a link to `https://corp-sso-login.com` (an AiTM reverse proxy for `https://sso.corp.com`) and taps their FIDO2 passkey. Why does the login fail?

Recommended Learning Flow