How does two-factor authentication (2FA) work?

The short answer

Two-factor authentication (2FA) asks for a second proof on top of your password: something you have, like your phone. An attacker who only has your password stays locked out.

Animated diagram: How does two-factor authentication (2FA) work?

Two-factor authentication (2FA)

A password proves only one thing: what you know. The problem is that an attacker who stole it knows it too. To the service, it then becomes impossible to tell you and the attacker apart. On its own, a password is a fragile proof.

Two-factor authentication, or 2FA, adds a second proof of a different kind: something you have, like your phone. These are called factors: something you know, and something you have. A May 2023 Microsoft Research study measured a 99.22% drop in the risk of compromise for Microsoft accounts protected by more than one factor.

What the authenticator app really does

The most common method is called TOTP (time-based one-time password). During setup, the service and your authenticator app share a secret key. After that, every thirty seconds, the app calculates a six-digit code from that key and the current time.

On its side, the server runs exactly the same calculation, with the same key and the same time. When you type your code, it compares the two results. If the codes match, you’re in. If not, the door stays shut.

How 2FA protects your account

  1. A key shared once. The secret key is exchanged during setup, between the service and your app. An attacker who steals your password doesn’t have it.
  2. A code that changes fast. The app calculates a new code every thirty seconds. A one-time code only works once.
  3. A check on the server. The server redoes the calculation on its side. Only a code identical to its own opens the account.
  4. A passkey tied to the site. A passkey is tied to the name of the real site. On a fake site, it doesn’t work.

The result: an attacker who only has your password is stuck at the door. The second proof is missing.

2FA is not unbreakable

2FA stops a stolen password used on its own, not a code or a yes that you hand over. In September 2022 at Uber, an attacker had a contractor’s password, probably bought after a malware infection. They kept sending sign-in requests until one was approved. A fake site can also act as a relay: it passes your password and your code to the real site in real time, then steals the session cookie. So a one-time code doesn’t resist phishing. SMS codes are the weakest: if your carrier moves your number to an attacker’s SIM card, the attacker gets your codes. Passkeys, on the other hand, are the phishing-resistant method.

What to do

  • Turn on 2FA today for your main email account, the one that can reset your other accounts. At Google, it’s called 2-Step Verification.
  • If you can, choose a passkey or an authenticator app. SMS is the weakest method, but it’s better than nothing.
  • Never give your code to anyone, and only type it on the real site.
  • Decline any sign-in request you didn’t start yourself, even if it keeps coming back.

#TwoFactorAuthentication#2FA#MFA#passkeys#authentication#phishing#CyberSecurity#InfoSec