Login methods, ranked
From a reused password to a passkey, one rung at a time. Throw the same five attacks at each and watch where they stop: anything you can type, a fake page can steal.
What you'll take away
- Explain how one reused password lets a small shop's leak open your bank
- Know why an SMS code falls to a SIM swap and an authenticator app doesn't
- Spot why any code you type can be relayed by a fake login page within seconds
- Set up a passkey with a spare, and check the account recovery isn't the weak lock
The 1-minute version
Tap a point and the picture below plays that step.
Throw all five at a reused password, then climb a rung at a time and see where each attack stops
Nobody has attacked yet
You have 2FA with codes from an authenticator app, and you log in through a fake page that relays everything live. Is the account safe?
The picture: the bank at the end of its street, with check A (what you know) and check B (the second step) across it; you on the square with your phone, and for a passkey your browser's domain check in front of you. The attacker has his own corner, between the shop that leaked and his fake bank, mybank-login.com; the carrier that holds your number is at the cross street's other end. Each attack is one light: red where it got in, a barrier down where it was stopped. A model of what each method is built to stop, not a measurement.
Compare them all: Login methods
Every tile takes the same five attacks in a row: leaked passwords, guessing, a fake login page relaying live, a SIM swap and push spam. Hitting a wall means it held; ? means it's up to you.
Use it when Nowhere: it's here to show how many attacks land
Skip it when Everywhere, above all email and banking
A model of what each method is built to stop. Someone set on handing things over can still lose with any of them, and a weak account recovery is always a back door. Press any tile to see it large above, with when it fits.
What each rung stops
| Method | Stops | Falls to |
|---|---|---|
| a long unique password | leaked passwords, guessing | phishing, if you paste it in |
| + SMS code | leaked passwords | SIM swap, live phishing |
| + authenticator app | leaked passwords, SIM swap | live phishing |
| + push approve | leaked passwords, SIM swap | live phishing, push spam |
| passkey, hardware key | all five here | a weak account recovery |
Anything you can type can be phished
A fake page that relays live doesn't need to break anything: you type the password and the code, it types them into the real site seconds later. Passkeys and hardware keys answer only the real domain, so there's nothing to relay.
Keep a spare, and mind the recovery
A passkey on one phone is one lost phone from a locked account. Add a second passkey or key. And an account is only as strong as its recovery: if "forgot password" sends an SMS, that SMS is the real lock.
In real code
// How an authenticator app makes its 6 digits (TOTP, RFC 6238): HMAC of the current 30-second step with a secret the
// app and the server share, cut down to digits. Checked against the RFC's own test vectors. Note what it doesn't do:
// nothing ties the code to the real site, so a fake page that relays it within its window can use it.
// Run: node totp.ts (Node 23.6+; on Node 22: node --experimental-strip-types totp.ts)
import assert from "node:assert/strict";
import { createHmac } from "node:crypto";
function hotp(secret: Buffer, counter: number, digits = 6): string {
const msg = Buffer.alloc(8);
msg.writeBigUInt64BE(BigInt(counter));
const h = createHmac("sha1", secret).update(msg).digest();
const off = h[h.length - 1] & 0x0f; // dynamic truncation (RFC 4226)
const bin = ((h[off] & 0x7f) << 24) | (h[off + 1] << 16) | (h[off + 2] << 8) | h[off + 3];
return String(bin % 10 ** digits).padStart(digits, "0");
}
const totp = (secret: Buffer, unixSeconds: number, digits = 6, step = 30) => hotp(secret, Math.floor(unixSeconds / step), digits);
/** The server accepts the current step and one either side, for clocks a little apart. */
const verify = (secret: Buffer, code: string, now: number) => [-1, 0, 1].some((w) => totp(secret, now + w * 30) === code);
const rfc = Buffer.from("12345678901234567890"); // RFC 6238 appendix B, SHA-1
assert.equal(totp(rfc, 59, 8), "94287082");
assert.equal(totp(rfc, 1111111109, 8), "07081804");
assert.equal(totp(rfc, 1234567890, 8), "89005924");
const now = 1_700_000_000;
const code = totp(rfc, now);
const relayedIn10s = verify(rfc, code, now + 10); // a fake page passes it on: still good
const twoMinutesLater = verify(rfc, code, now + 120);
assert.equal(relayedIn10s, true);
assert.equal(twoMinutesLater, false);
console.log(`RFC 6238 vectors match · code ${code} · relayed 10 s later: accepted · 2 minutes later: refused`);
node totp.ts (Node 23.6+ · on Node 22 add --experimental-strip-types)It printed: RFC 6238 vectors match · code 921300 · relayed 10 s later: accepted · 2 minutes later: refusedHow an authenticator app makes its 6 digits, checked against RFC 6238's own test vectors. A code relayed 10 seconds later still passes, which is why a live fake page can use it.
Common questions
Why is reusing one password so bad?
Sites get breached all the time, and the leaked email and password pairs are tried on other sites by the million (credential stuffing). One small shop leaking can open your bank. A password manager gives each site its own long password, so a leak costs one site.
Is SMS two-factor still worth turning on?
Yes, if it's all a service offers: it stops leaked passwords. But an attacker can talk the carrier into moving your number to their SIM (a SIM swap), and a fake page can ask for the code too. For important accounts with better options, use an authenticator app or a passkey.
Can two-factor be phished?
Any code you type can be. A fake page takes the password and the code as you type them and enters them on the real site within seconds; a 6-digit code good for 30 seconds is plenty of time. Passkeys and hardware keys answer only the real domain, so there's nothing to relay.
What is MFA fatigue?
The attacker already has your password and sends approval after approval, maybe at 3 a.m., until you tap approve to make it stop. Many services now make you type a number shown on the login screen. That stops blind taps, but not a fake page, which can show you the number.
What makes a passkey phishing-proof?
There's nothing to type or paste. The private key stays on your device, and the browser lets it sign only for the domain it was made for. A look-alike domain can't ask for it, so a fake page gets nothing to relay.
What if I lose the phone with my passkey?
A passkey kept only on that phone goes with it (one synced through a password manager comes back on the new phone), so add a second passkey or a hardware key before you need it. And check recovery: if "forgot password" sends an SMS, that SMS is the real lock.
Are security questions safe?
Not really: your first school or pet is often in old posts anyone can find. If a site makes you set them, answer with random words like a password and keep them in your password manager.
Which method stops which attack?
A long unique password stops leaks and guessing. SMS adds a layer but falls to a SIM swap; an authenticator app stops that. Everything you type still falls to a fake page. Passkeys and hardware keys stop all five attacks here.
Next lesson
Cookies and sessionsLevel: Intermediate
Getting in is solved; after it, a cookie keeps you logged in, and next come the rules that stop it being stolen.