Lesson 5 of 9 · 26m
WebAuthn Authentication and Phishing Resistance
How assertion validation works, why origin binding stops phishing, and what signCount, user verification, and cross-device flows tell you.
WebAuthn's security miracle is not the key pair by itself. It is the fact that the browser includes the origin and relying party in the signed data. A lookalike phishing domain cannot ask the authenticator to produce a valid assertion for your real origin, no matter how convincing the page looks.
The authentication ceremony
const assertion = await navigator.credentials.get({
publicKey: {
challenge,
rpId: "login.sudosecurity.org",
userVerification: "preferred",
timeout: 60000,
},
});When allowCredentials is omitted, discoverable credentials can be used: the authenticator can select the right passkey for the relying party. That is the modern passkey login flow. When you do supply allowCredentials, you are narrowing the ceremony to known credential IDs, often because you already know which account is being authenticated.
Validate the signed facts, not just the signature
Server validation must verify the authenticator signature and the parsed client data:
clientDataJSON.type == "webauthn.get"
clientDataJSON.challenge == issued base64url challenge
clientDataJSON.origin == approved origin exactly
authenticatorData.rpIdHash == SHA-256(rpId)
signature verifies over authenticatorData || SHA-256(clientDataJSON)Do not substring-match origins. https://login.sudosecurity.org.evil.test is not close enough, and neither is an unexpected port or scheme.
Why real-time phishing fails here
With TOTP, a phishing proxy can collect the code and replay it to the real site immediately. With WebAuthn, the challenge is valid but the origin in clientDataJSON is the phishing origin. Your server rejects it because origin binding is cryptographic evidence, not UI trust. This is the core meaning of phishing-resistant authentication.
User verification and sign count
User verification means the authenticator checked a PIN, biometric, or device unlock locally. The server receives evidence in flags, not biometric data. signCount is a monotonic counter on some authenticators and can help detect cloning, but many modern passkeys report zero or behave differently because credentials sync. Use it as a signal, not as a hard universal rule.
Field notes
- Authentication ceremonies need the same single-use challenge discipline as registration.
- Cross-device sign-in uses a QR or nearby-device flow, but the assertion still carries origin-bound data; validate it normally.
- A successful WebAuthn login is strong evidence of key possession, but it does not prove the session cannot later be hijacked.
- Log ceremony IDs, credential IDs, and validation failure reasons. Never log private keys, raw secrets, or complete challenges after use.
Was this lesson helpful?