Lesson 9 of 19 · 20m
MFA, WebAuthn, and Passkeys: The Factor That Can't Be Phished
TOTP codes replay through a proxy in real time; WebAuthn binds the credential to your origin in the signature itself — the ceremony, what to store, and why recovery is the real attack surface.
A phished user types their TOTP code into the attacker's lookalike login page. The page relays it to your real site through a reverse proxy, the code is still inside its 30-second window, and the session the attacker just created is indistinguishable from a real login. MFA fired. Nothing failed. The factor itself was phishable.
That is the thing to internalize about second factors: TOTP and SMS prove the user knows something. WebAuthn proves the user possesses a key that refuses to operate on the wrong origin. The difference is mathematical, not behavioral.
What each factor actually proves
TOTP (RFC 6238) is a shared secret hashed with the current time into six digits. Those digits are origin-agnostic — they validate anywhere they are typed, including into ev1l.example piping them upstream in real time. Adversary-in-the-middle kits (evilginx2 and successors) automate exactly this relay, MFA and all. SMS is worse on both axes: interceptable, and SIM-swap means the number itself moves.
WebAuthn is asymmetric. The authenticator holds a private key; you hold a public key and a credential ID. navigator.credentials.get() produces an assertion: the browser builds clientDataJSON containing the challenge and its own origin, the authenticator signs that plus the rpIdHash of your relying-party ID. A page on the wrong domain produces an assertion whose RP ID hash doesn't match yours. Verification fails before you look at the signature. The credential is scoped to the origin by construction — the user cannot be tricked into using it elsewhere, which is what "phishing-resistant" actually means.
The ceremony in code
// create(): the options that matter
const opts = {
challenge, // >=16 random bytes, stored server-side, consumed once
rp: { name: "Example" }, // rp.id omitted → effective domain; don't loosen it
user: { id: userIdBytes, name: email, displayName: email },
pubKeyCredParams: [{ alg: -7, type: "public-key" }], // ES256; add -257 for RS256
authenticatorSelection: { residentKey: "preferred" }, // discoverable = passkey-capable
attestation: "none" // attestation proves device vendor, not security — skip it
};On get(): verify the signature over authenticatorData + clientDataJSON, check clientDataJSON.origin is exactly your origin (string equality, not a suffix match), check the rpIdHash, check the userPresent/userVerified flags. signCount detects cloned hardware keys, but synced passkeys routinely report 0 — treat it as a signal, not a gate.
Passkeys are discoverable WebAuthn credentials synced by iCloud Keychain, Google Password Manager, or Bitwarden — the same protocol, no password at all. They shipped broadly after 2022; "WebAuthn" and "passkey" are the same cryptography at different UX.
Backup codes and recovery are the underbelly
Backup codes are single-use TOTPs. Generate them from a CSPRNG and store them hashed — plain SHA-256 is fine because they're high-entropy, unlike passwords, which is why passwords need Argon2id. Consume each exactly once.
Recovery is where the whole scheme dies: a helpdesk reset bypasses everything you built. Treat recovery as its own threat model — verify through a second channel, notify the registered factor, add delay before the reset activates. A support override that silently skips verification is a back door with a ticket number.
And the seeds: TOTP secrets are symmetric secrets at rest. A database dump of seeds plus passwords is a full compromise — encrypt them. WebAuthn's public keys are worthless to an attacker. That asymmetry is the entire point.
Receipts
Google stated in 2018 that its 85,000+ employees had seen zero successful phishing since mandatory FIDO security keys. In Cloudflare's 2022 writeup of the Twilio-style smishing campaign, phished credentials flowed — but hardware-keyed accounts held; their own post credits FIDO as the control that worked. Offer WebAuthn or passkeys first, TOTP second, SMS never if you can help it.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Building a Production REST API With Node.js and Express
Build a REST API in Node.js and Express the way production systems need: input validation, JWT auth, refresh token rotation, status codes, rate limiting, idempotency keys, and centralized error handling.
Node.js Fixed 16 Flaws in One Release. Most of Them Live in HTTP/2 and TLS.
The November 11 Node.js security releases fix 16 CVEs across the 26, 24 and 22 lines, seven of them rated high. Nearly all sit in HTTP/2 and TLS, where a remote client can crash a server, leak memory, or get past per-host client-certificate checks.
Next.js Shipped Seven Advisories and Six of Them Are the Cache
The November 2026 Next.js security release patches seven issues, and six live in the new Cache Components layer, the feature meant to make your app faster by remembering more. Three hit self-hosted next start specifically: the ones Vercel's own platform quietly absorbs.
Forum Archaeology: Nulled vBulletin, XenForo, and the Missing Footer
I could spot a nulled forum in about four seconds, and it never stopped being funny. Here's why the copyright line gives it away, what a measured 97% of nulled add-ons actually contain, and why MyBB quietly became the smart choice for everyone who wanted the look without the paper trail.