Course contentsShow
← Security
Lesson 751 of 3,05216. Web Security - Authentication MechanismsFree lesson

WebAuthn and FIDO2 Protocol

Deep dive into WebAuthn API, FIDO2 architecture, public key cryptography flow, and how browsers mediate authenticator communication.

WebAuthn and FIDO2 Protocol

What you'll learn: How WebAuthn and FIDO2 enable secure, phishing-resistant passwordless authentication using public key cryptography in web browsers.

The Big Picture

You learned FIDO2 and WebAuthn exist (lesson 745), but now you'll understand how they actually work. WebAuthn (Web Authentication) is a browser API, while FIDO2 is the overall protocol family that includes both WebAuthn and CTAP (Client to Authenticator Protocol). Together, they let websites authenticate users with biometrics, security keys, or device PINs instead of passwords.

The Public Key Cryptography Flow

Think of it like a secure lockbox system:

  1. Registration: Your authenticator (USB key, phone biometrics, etc.) generates a unique public-private key pair for each website. The public key goes to the website; the private key never leaves your device.

  2. Authentication: The website sends a challenge (random data). Your authenticator signs it with the private key. The website verifies the signature using the stored public key.

This is phishing-resistant because each key pair is tied to a specific domain—an attacker's fake site can't use credentials meant for the real site.

How Browsers Mediate Communication

The browser acts as a trusted intermediary:

  • WebAuthn API runs in JavaScript: navigator.credentials.create() for registration, navigator.credentials.get() for login
  • CTAP protocol handles communication between browser and authenticator (USB, Bluetooth, NFC, or platform authenticator like Windows Hello)
  • The browser verifies the origin, preventing credential theft across domains
  • User presence and verification (biometric/PIN) happen at the authenticator level

The authenticator never exposes the private key—it only outputs signatures. Even if malware compromises your browser, it can't steal your credentials.

Key Takeaway: WebAuthn provides a browser API for passwordless authentication, while FIDO2's public key cryptography ensures credentials are domain-bound, hardware-protected, and impossible to phish—the browser mediates all communication to enforce origin security.