Multi-factor authentication
Multi-factor authentication (MFA), sometimes called two-factor authentication (2FA),1 is a form of authentication that accepts a sign-in only when the user presents evidence from at least two distinct categories of factor: something the user knows, something the user has, and something the user is.2 An attacker who has the password from a leak, a Phishing page or Credential stuffing still lacks the second proof. Against most password attacks, Brute-force attack and password spraying among them, no single control does more; one Microsoft analysis put the share of account compromises it would have stopped at 99.9%.2
Factors
Each category is a factor. Passwords and PINs are knowledge; an authenticator app, a hardware key or a phone that receives codes is possession; a fingerprint or a face is inherence. A password plus a PIN is two pieces of one factor and does not count as MFA.2 Location and other risk signals can decide when to ask for more proof, but are not a factor, and NIST accepts a biometric only as the activation of a physical authenticator such as a phone.3
How a time-based code works
The most widely used one-time code is the TOTP code, defined in RFC 6238.4 At setup the site shows a QR code that carries a random secret, the seed, and the user scans it into an authenticator app.2 From then on, the app and the server each compute the code from the seed and the clock:
T = floor((current Unix time - T0) / X) // X = 30 seconds, T0 = 0 by default
TOTP = HOTP(K, T) // K = the shared seedT counts 30-second steps since 1 January 1970, so both sides need a correct clock.4 No code travels from the server to the phone. Because the server must compute the same codes, it stores the seed in a form it can read: the seed cannot be hashed like a password, and whoever copies it can generate valid codes until the user sets up a new one. Changing the password does not change the seed.2
A verifier keeps seeds encrypted, accepts the current step and at most the one before it, and limits attempts, since a six-digit code has only about a million values. It also refuses a code it has already accepted, which NIST makes a requirement.23
Kinds of second factor
| Factor | How it works | Phishing |
|---|---|---|
| Authenticator app (TOTP) | The user types a code computed on the phone | Phishable; the code is short-lived |
| SMS or voice code | The site sends a code to a phone number | Phishable; NIST lists it as restricted |
| Push approval | The user taps Approve in an app | Open to repeated prompts |
| Recovery codes | A list issued at setup, each code used once | Phishable |
| Security key, passkey | The device signs a challenge with a private key | Resistant |
SMS codes are restricted under NIST SP 800-63B-4 because a phone number can be taken over through a SIM swap or number porting, and the messages can be intercepted through SS7.2 NIST forbids email as an out-of-band authenticator.3
A hardware key or a passkey answers a challenge from the site with a private key that never leaves the device, and the answer is bound to the site's real origin. A look-alike domain receives nothing it can reuse.2 NIST calls this property phishing resistance and defines it as a feature of the protocol that does not depend on the user spotting the fake site.3 As a second factor, a passkey counts only when the server checks its user-verification flag; a touch that proves presence is not enough.2
Assurance levels
NIST SP 800-63B-4 grades sign-in in three Authentication Assurance Levels. AAL1 allows one factor. AAL2 requires two distinct factors and at least one phishing-resistant option on offer. AAL3 requires a phishing-resistant authenticator with a key that cannot be exported, which rules out passkeys that sync between devices.3
Attacks on MFA
The common attacks go after the way MFA is deployed.2 A reverse proxy phishing kit such as Evilginx shows the real sign-in page through the attacker's server, passes the password and the TOTP code on in real time, and keeps the session cookie that comes back, which leads to Session hijacking. MFA fatigue sends push prompts over and over until the user approves one; number matching and a cap on prompts counter it. A downgrade attack uses a legacy endpoint or a weaker fallback method that skips the second factor.2 The reset flow is another way in, which is why changing a factor should take an existing factor and a live session alone should not be enough.2
Where to require it
MFA belongs on every account and is mandatory for administrators.2 Inside a signed-in session, some actions ask for the second factor again: changing the password or the email address, turning MFA off, and moving to an admin session. Every sign-in path needs the same check; a separate login API or a mobile app is the path most often left out.2
MFA in Supabase
Supabase Auth supports TOTP and phone factors and records the result in the user's JWT as the aal claim: aal1 after a normal sign-in, aal2 after a verified second factor.1 An MFA screen in the frontend adds no protection until the database and APIs check that claim. For tables, the Supabase guide gives a restrictive row level security policy; as restrictive makes it apply on top of every other policy on the table:
create policy "Require MFA"
on table_name
as restrictive
to authenticated
using ((select auth.jwt() ->> 'aal') = 'aal2');Variants of the policy require aal2 only for newer accounts or only for users with a verified factor. A server that finds a session at aal1 should send the user to the code screen, not answer 401 or 403. After a factor is removed, the session falls back to aal1 only when the token is next refreshed.1
Notable incident
In June 2024 Mandiant reported that a group it tracks as UNC5537 had signed in to the Snowflake accounts of many companies with stolen passwords, copied their data and tried to extort them; Mandiant and Snowflake notified about 165 organisations. Most passwords came from infostealer infections dating back as far as November 2020. Mandiant found no breach of Snowflake's own systems and named three causes: no MFA on the accounts, passwords never changed after the theft, and no network allow lists.5 Snowflake has since been phasing out password-only sign-in; in the final phase, planned for August to October 2026, human users can no longer sign in with a password alone.6
In SecFlash
SecFlash reports SF-CLD-529 when a member of the connected Supabase account signs in without MFA, and SF-CLD-313 for the same on a Cloudflare account. SF-CLD-524 reports a project that offers its own users too few second factors. All three show on the Cloud page.
See also
- Authentication
- Session management
- Credential stuffing
- Phishing
- Session hijacking
- Responding to an administrator account takeover
- Category: Authentication
References
- a b c "Multi-Factor Authentication". Supabase Docs. Supabase.
- a b c d e f g h i j k l m n "Multifactor Authentication Cheat Sheet". OWASP Cheat Sheet Series.
- a b c d e "NIST SP 800-63B-4, Digital Identity Guidelines: Authentication and Authenticator Management". NIST (2025).
- a b M'Raihi, D. et al. (May 2011). "RFC 6238: TOTP: Time-Based One-Time Password Algorithm". IETF.
- back Mandiant (10 June 2024). "UNC5537 Targets Snowflake Customer Instances for Data Theft and Extortion". Google Cloud Threat Intelligence.
- back "Planning for the deprecation of single-factor password sign-ins". Snowflake Documentation. Snowflake.
External links
- SP 800-63B-4: Authentication and Authenticator Management, NIST
- Multi-Factor Authentication, Supabase Docs