{"canonical_url":"https://engineer.company/glossary/multi-factor-authentication/","content_markdown":"# Multi-factor authentication\n\n## What it is\n\nMulti-factor authentication, usually shortened to MFA, is a sign-in that accepts\na claimed identity only when it is backed by more than one kind of evidence.\nNIST SP 800-63B-4, the US federal guideline on authentication that many\norganisations outside government also follow, names the three kinds: something\nyou know, such as a password; something you have, such as a phone or a security\nkey; and something you are, such as a fingerprint. Its definition turns on one\nword. The system must require more than one distinct type of factor, so a\npassword and the answer to a security question add up to a single factor,\nbecause both are things you know. Two-factor authentication, or 2FA, is the\ncommon case of exactly two.\n\nThe guideline accepts two ways of getting there. The first combines separate\nsingle-factor authenticators: a password, plus a phone app that shows one-time\ncodes or a list of printed backup codes. The second uses one multi-factor\nauthenticator, such as a security key or a phone that holds a private key and\nwill only use it after a PIN or a fingerprint. In that case the PIN or\nfingerprint is called an activation factor. It is checked on the device itself,\nand the server receives only the result, a signature it can verify, so a single\ntouch presents two factors.\n\nBiometrics have a narrow place in this. NIST allows a fingerprint or a face only\nwhen a physical authenticator is also involved in the authentication, never as a\nfactor on its own, and requires that a non-biometric alternative is always\noffered. The guideline is plain that biometric characteristics are not secret: a\nface can be photographed, and a fingerprint lifted from something its owner has\ntouched.\n\n## Why it matters\n\nA password can be copied without its owner noticing: typed into a convincing\ncopy of a sign-in page, guessed, or reused on a site whose database is later\nstolen. MFA makes a copied password insufficient on its own, because the\nattacker still needs something of a different kind.\n\nNIST makes this the baseline for its second assurance level. At AAL2, the user\nmust authenticate through two factors, either combined in one authenticator or\nsupplied separately, and the combination must include a physical authenticator\ntogether with a password or a biometric comparison. Verifiers at that level must\noffer at least one phishing-resistant option, and federal agencies must require\nphishing-resistant authentication of their staff, contractors and partners.\n\nThe methods sold under the same three letters differ from one another more than\nMFA differs from a password alone, and the guideline sorts them clearly:\n\n- **Codes sent by text message or voice call** are the only authenticator type\n  NIST labels restricted. They may still be used, but the verifier must offer an\n  alternative without that label, tell the user about the risk and have a plan\n  for moving away from it. Changing the registered phone number counts as\n  binding a new authenticator, with all the checks that implies.\n- **Codes from an app and push prompts on a phone** are acceptable at AAL2 but\n  are not phishing-resistant: what the person types or approves is not tied to\n  the site that asked for it.\n- **Cryptographic authenticators that bind their answer to the site**, such as\n  passkeys and smart cards, are phishing-resistant. AAL3 requires one whose\n  private key cannot be exported from its hardware.\n\nEmail is missing from the list on purpose: the guideline rules it out as a\nchannel for out-of-band authentication.\n\n## What it looks like in practice\n\nThe code in an authenticator app is the most common second factor, and RFC 6238\n(May 2011) defines it in a few pages. At enrolment the server generates a secret\nkey and hands it to the app, usually as a QR code, so that both sides now hold\nthe same key. To produce a code, each side divides the current Unix time by a\ntime step, 30 seconds by default, and treats the whole number as a counter. It\ncomputes an HMAC of that counter with the key and cuts the result down to a\nshort decimal number, using the method of HOTP, which RFC 4226 defined in 2005\nand which requires at least six digits. In Python the whole calculation fits in\na few lines:\n\n```python\nimport hashlib, hmac, struct\n\ndef totp(key: bytes, unix_time: int, digits: int = 6, step: int = 30) -\u003e str:\n    counter = struct.pack(\"\u003eQ\", unix_time // step)\n    mac = hmac.new(key, counter, hashlib.sha1).digest()\n    offset = mac[-1] \u0026 0x0F\n    code = struct.unpack(\"\u003eI\", mac[offset:offset + 4])[0] \u0026 0x7FFFFFFF\n    return str(code % 10**digits).zfill(digits)\n\nprint(totp(b\"12345678901234567890\", 59, digits=8))  # 94287082\n```\n\nThe test vectors in the RFC use that 20-byte ASCII key and eight digits. At 59\nseconds after the epoch the counter is 1, and the SHA-1 variant gives 94287082,\nwhich is what the function prints; the six-digit code an app would show is the\nlast six of those digits, 287082. Nothing in the calculation touches the\nnetwork, which is why the app works on a phone in flight mode, and also why the\nserver has to keep its own copy of every user's key.\n\nChecking a code is the same calculation on the server, followed by a comparison.\nRFC 6238 recommends accepting at most one earlier time step to cover network\ndelay, and forbids accepting a code a second time once it has been used\nsuccessfully.\n\nA passkey replaces the shared secret with a key pair. Under Web Authentication\nLevel 3, a W3C Recommendation since 25 August 2026, the authenticator creates a\nkey pair for one site, identified by its domain, and gives the server only the\npublic key. At sign-in the browser passes along the origin it is actually\nconnected to, and the authenticator signs the server's challenge together with\nthat origin, so a signature produced on a lookalike domain is useless at the\nreal one. With a PIN or a fingerprint required to use the key, a passkey is a\nmulti-factor authenticator in a single step. WebAuthn calls passkeys that are\ncopied across a person's devices multi-device credentials, and NIST accepts\nthese synced keys at AAL2 but not at AAL3, because a key that can be synced is\nby definition a key that can be exported.\n\nTurning MFA on is the easy part. Deciding who must use it, which methods count\nwhere and what happens when someone loses a phone is account administration,\npart of the wider arrangement of access. This site's\n[security and access management service](/services/security-access/) describes\nthat arrangement: accounts, passwords and permissions set up so that each person\nholds exactly the access their job needs, and leavers lose it on the day they\nleave.\n\n## Where it goes wrong\n\n**A phishing page relays the code.** A one-time code is a number the user reads\nand types, and nothing in it records which site the user was looking at. A\nlookalike page that forwards the password and the code to the real site within\nthe time step signs in as the user. NIST therefore states that no authenticator\nwhose output is entered by hand counts as phishing-resistant, and adds that how\nthe user reached the fake page is irrelevant. The fix is an authenticator that\nbinds its answer to the verifier: by its domain name, as WebAuthn does, or to\nthe TLS channel itself, as client certificates and smart cards do. Require one\nof these for administrators and offer it to everyone else.\n\n**The phone number is the factor.** A code sent by text message goes to whoever\nthe mobile operator currently routes that number to. NIST's own list of threats\nincludes an attacker who has persuaded the operator to redirect the victim's\nnumber and then receives the code. Before sending a code by text message or\nvoice call, verifiers should look for signs such as a recent SIM change, number\nporting or a device swap. Keep text messages as a fallback rather than the main\nmethod, and require a full sign-in before the number on file can change.\n\n**Approve, approve, approve.** A push prompt with a single Approve button asks\nfor a decision, not for evidence. An attacker who already holds the password can\ntrigger prompts until the user, tired of the noise, accepts one. NIST calls this\nauthentication fatigue and no longer considers approve-only flows acceptable: a\nsecret must travel from one channel to the other, for example a number shown on\nthe sign-in screen that the user types into the phone. Picking it from a short\nlist is not enough, since the user may simply guess. Limit how many prompts can\nbe sent since the last successful sign-in, as the guideline also recommends.\n\n**Recovery skips the second factor.** A \"lost my phone\" link that asks only for\nthe password, or sends a reset link by email, turns MFA into an option the\nattacker can decline. For accounts at AAL2, NIST requires recovery to use two\nrecovery codes obtained by different methods, one recovery code plus a\nsingle-factor authenticator still bound to the account, or repeating the\nidentity proofing. Every recovery must send the user a notification. More\ngenerally, one factor must never be usable to obtain an authenticator of another\nkind: a password alone must not be enough to print a fresh set of backup codes.\n\n**The code is accepted twice, or for too long.** A six-digit code has a million\npossible values, so its strength comes from the rules around it. A verifier that\naccepts several time steps either side of now, or accepts a code that has\nalready been used, gives an attacker who has seen one code a window in which to\nuse it again. Record the last time step accepted for each user and reject\nanything at or before it, keep the window to the single step that RFC 6238\nallows for delay, and cap consecutive failures: NIST allows no more than 100\nbefore the authenticator is disabled.\n\n**The seeds sit beside the passwords.** Codes from an app are symmetric: the\nserver holds every user's key, and anyone who copies those keys can generate\nvalid codes for every account. NIST requires the keys to be strongly protected,\nwith access limited to the software components that need them. Do not keep them\nas plain columns next to the password hashes. Encrypt them with a key kept in a\nseparate secret store, and let only the service that verifies codes read them.\n\n## Further reading\n\n- [NIST SP 800-63B-4, Definitions and Acronyms](https://pages.nist.gov/800-63-4/sp800-63b.html#def-and-acr)\n  — the definitions of multi-factor authentication, multi-factor authenticator\n  and phishing resistance in the current guideline.\n- [NIST SP 800-63B-4 at the Computer Security Resource Center](https://csrc.nist.gov/pubs/sp/800/63/b/4/final)\n  — the publication record: published in July 2025, superseding SP 800-63B.\n- [RFC 6238: TOTP](https://www.rfc-editor.org/rfc/rfc6238) — the time-based\n  one-time password algorithm, its test vectors and the rules for clock drift.\n- [RFC 4226: HOTP](https://www.rfc-editor.org/rfc/rfc4226) — the counter-based\n  algorithm underneath it, including the truncation to six or more digits.\n- [Web Authentication, Level 3](https://www.w3.org/TR/webauthn-3/) — the W3C\n  specification behind passkeys, with origin-scoped credentials and synced\n  passkeys.\n\n\u003chttps://engineer.company/glossary/multi-factor-authentication/\u003e\n","date_modified":"2026-10-30T02:51:31Z","description":"How multi-factor authentication combines different kinds of proof, why a typed code can be relayed while a passkey cannot, and the recovery flows that undo it.","formats":{"gemtext":"https://engineer.company/glossary/multi-factor-authentication/index.gmi","gopher":"https://engineer.company/glossary/multi-factor-authentication/gophermap","html":"https://engineer.company/glossary/multi-factor-authentication/","json":"https://engineer.company/glossary/multi-factor-authentication/index.json","markdown":"https://engineer.company/glossary/multi-factor-authentication/index.md","pdf":"https://engineer.company/glossary/multi-factor-authentication/index.pdf"},"kind":"page","language":"en","title":"What is multi-factor authentication?","url":"https://engineer.company/glossary/multi-factor-authentication/","version":1}