cd ../articles

Security

Lock it twice: the power of 2FA

A stolen password is only half an account. What each kind of second factor protects against, a live demo of how authenticator codes are computed, and a 15-minute plan.

  • TOTP
  • FIDO2
  • Passkeys

Picture it: 3 a.m., your phone buzzing with password-reset emails, login alerts and receipts for things you never bought. Most account takeovers start the same boring way, with a password that leaked somewhere else. A second factor is what turns that leak into a non-event.

Your password is probably already out there

Breach databases hold billions of email and password pairs. Type your address into haveibeenpwned.com; most people find at least one hit. Attackers do not guess passwords anymore, they replay them: if you reused a password on a forum that was breached in 2015, every account sharing it is exposed.

Billionsleaked credentials in public breach dumps
Reuseturns one breach into many compromised accounts
99.9%of automated account attacks blocked by MFA (Microsoft)

Something you know, something you have

The usual analogy is "a second lock on the door". Here is a more useful one: your password is a key, which can be copied, stolen or guessed. The second factor is something you have: a phone or a hardware key. Someone in another country holding your password still does not hold your phone.

Three kinds of second factor

SMS codes

better than nothing, barely

  • Works on any phone
  • Easy to set up
  • SIM-swapping attacks are real
  • Messages can be intercepted
  • No signal, no access

Authenticator apps (TOTP)

the sweet spot for most people

  • Works offline
  • Cannot be SIM-swapped
  • Free; some apps offer encrypted backup
  • Still phishable: a fake site can relay the code
  • Lose the phone without backup codes, lose access

Hardware keys (FIDO2)

the final boss

  • Phishing-resistant: the key checks the real domain
  • Nothing to type, nothing to intercept
  • Costs around €25–60
  • Buy two: one is the backup

For email, banking and anything with money on it, a hardware key or a passkey is worth it. For everything else, an authenticator app beats SMS by a long way.

How an authenticator code is actually made

There is no magic and no network involved. When you scan the QR code, the site and your phone share a secret. Every 30 seconds, both sides compute the same thing, standardised in RFC 6238:

counter = floor(unix_time / 30)
hash    = HMAC-SHA1(secret, counter)
code    = 6 digits taken from the hash (dynamic truncation)
2fa.svg
How a 6-digit code is made
How a 6-digit code is made

Here it is running live, in your browser, on a random secret generated just now. Nothing is sent anywhere.

30s
------
time step (counter): …
Add this secret to an authenticator app as a manual entry and you will see the same six digits. Do not paste a real secret here, or anywhere you do not need to.

That is also why a breach of the website does not hand over future codes from your phone, and why the secret behind a QR code deserves the same care as a password.

"But what if…"

…I lose my phone?

Backup codes. When you enable 2FA, the service gives you around ten one-time codes. Print them or store them in your password manager. Some apps (Aegis, 2FAS, Ente Auth) can also export an encrypted backup of your secrets.

…the service itself gets hacked?

Your password may leak, but past codes are useless and future ones need the secret on your device. Change the password, and if the service says secrets leaked too, re-enrol 2FA.

…it is overkill for my email?

Your email is the master key: every "forgot password" link lands there. Whoever owns your inbox owns everything else. It is the first account to protect, not the last.

The 15-minute plan

Tick these off as you go; the boxes remember their state in this browser only.

Today: your email

This week: your money

This month: your identity

The friction problem

"Typing a code every time is annoying." Filing a police report is more annoying. Most services remember trusted devices, so in practice you enter a code on a new device or every few weeks. Thirty seconds a month is a fair price.

The next step: passkeys

Passkeys remove the password entirely. Your device holds a private key, unlocked with your face, fingerprint or PIN, and it only answers the real website's domain, so phishing pages get nothing. Apple, Google and Microsoft all support them. Where a site offers one, take it.

The bottom line

2FA is not perfect; nothing is. But no other security upgrade does as much in so little time. Lock it once with a password. Lock it twice with a second factor.

Apps to start with

Aegis

Open source, Android, encrypted backups.

2FAS / Ente Auth

iOS and Android, free, encrypted sync.

Google / Microsoft Authenticator

Mainstream, cloud backup tied to your account.

YubiKey, Nitrokey…

FIDO2 hardware keys. Buy two.