πŸ”’ Security

FIDO2

A passwordless authentication standard

πŸ“– Detailed Explanation

FIDO2 is a passwordless authentication standard jointly developed by the FIDO Alliance and the W3C. It consists of two core specifications: WebAuthn (Web Authentication API) and CTAP (Client to Authenticator Protocol). Users authenticate securely through biometrics (fingerprint, face), security keys, PINs, and more.

The core of FIDO2 is public-key cryptography. During registration, a public/private key pair is generated on the user's device, and the private key is stored securely on the device. Only the public key is sent to and stored on the server, so even if the server is hacked, the private key is not leaked. Phishing attacks are also blocked at the source.

The authentication flow uses a Challenge-Response method. When the server sends a random challenge, the client signs it with the private key and responds. The server verifies the signature with the stored public key. Because the private key never leaves the device, it is also safe against Man-in-the-Middle attacks.

FIDO2 is supported by all major browsers (Chrome, Safari, Firefox, Edge) and operating systems (Windows Hello, macOS Touch ID, Android). Passkey, WebAuthn, and security keys (such as YubiKey) are all based on FIDO2. In enterprise environments, it is used as a strong second factor for MFA.

πŸ’» Code Example

// FIDO2/WebAuthn 등둝 (Registration)
async function registerCredential(userId: string, userName: string) {
  // μ„œλ²„μ—μ„œ challenge 및 μ˜΅μ…˜ κ°€μ Έμ˜€κΈ°
  const optionsRes = await fetch('/api/webauthn/register/options', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ userId, userName })
  });
  const options = await optionsRes.json();

  // Base64URL β†’ ArrayBuffer λ³€ν™˜
  options.challenge = base64URLToBuffer(options.challenge);
  options.user.id = base64URLToBuffer(options.user.id);

  // λΈŒλΌμš°μ € WebAuthn API 호좜 - 생체인식/λ³΄μ•ˆν‚€ ν”„λ‘¬ν”„νŠΈ
  const credential = await navigator.credentials.create({
    publicKey: {
      ...options,
      authenticatorSelection: {
        authenticatorAttachment: 'platform', // λ‚΄μž₯ 인증기 (Touch ID λ“±)
        userVerification: 'required',        // 생체인식 ν•„μˆ˜
        residentKey: 'required'              // Passkey 지원
      },
      pubKeyCredParams: [
        { type: 'public-key', alg: -7 },    // ES256 (ECDSA)
        { type: 'public-key', alg: -257 }   // RS256 (RSA)
      ]
    }
  });

  // μ„œλ²„λ‘œ credential μ „μ†‘ν•˜μ—¬ 등둝 μ™„λ£Œ
  await fetch('/api/webauthn/register/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      id: credential.id,
      rawId: bufferToBase64URL(credential.rawId),
      type: credential.type,
      response: {
        clientDataJSON: bufferToBase64URL(credential.response.clientDataJSON),
        attestationObject: bufferToBase64URL(credential.response.attestationObject)
      }
    })
  });
}

// FIDO2/WebAuthn 인증 (Authentication)
async function authenticate() {
  const optionsRes = await fetch('/api/webauthn/authenticate/options');
  const options = await optionsRes.json();
  options.challenge = base64URLToBuffer(options.challenge);

  // μ‚¬μš©μžμ—κ²Œ 인증 ν”„λ‘¬ν”„νŠΈ ν‘œμ‹œ
  const assertion = await navigator.credentials.get({
    publicKey: options,
    mediation: 'optional' // Passkey μžλ™μ™„μ„± 지원
  });

  // μ„œλ²„μ—μ„œ μ„œλͺ… 검증
  const verifyRes = await fetch('/api/webauthn/authenticate/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      id: assertion.id,
      response: {
        authenticatorData: bufferToBase64URL(assertion.response.authenticatorData),
        clientDataJSON: bufferToBase64URL(assertion.response.clientDataJSON),
        signature: bufferToBase64URL(assertion.response.signature)
      }
    })
  });

  return verifyRes.json();
}

πŸ—£οΈ Examples of Practical Conversations

In a security team meeting:

"The OTP method was breached because of MFA fatigue attacks. Switching to FIDO2 security keys will block phishing and also improve the user experience. You can distribute YubiKeys, or even just use platform authenticators like Windows Hello/Touch ID."

In a technical interview:

"Why is FIDO2 resistant to phishing?" - "Thanks to origin binding. When a credential is created, the domain is bound to it, so the credential cannot be used on an attacker's site. The server challenge also prevents replay attacks."

In architecture design:

"Can we completely eliminate passwords with Passkey?" - "Yes, we can. But the account recovery flow is important. You need to design it together with things like having users register Passkeys on multiple devices, backup codes, and trusted-contact recovery."

Take a mock interview on this topic β†’ WIA SOOM AI Interview Β· Start for free

⚠️ Cautions

πŸ”— Related Terms

Passkey OAuth 2.1 MFA Token-based Auth Zero Trust

πŸ“š Learn More

πŸ“„ FIDO Alliance - FIDO2 Official Page πŸ“„ WebAuthn Guide - Developer Guide πŸ“„ MDN - Web Authentication API