Difficulty: Beginner
What are the three categories of authentication factors used in MFA, and are all second factors equally strong?
Multi-factor authentication (MFA) requires proof from two or more independent categories of evidence before granting access. The three classic categories are something you know, something you have, and something you are. Combining categories matters: a password plus a PIN is still only one category (knowledge), so it is not true MFA.
Two further categories are sometimes added: somewhere you are (location or network context) and something you do (behavioural patterns such as typing rhythm). These are usually risk signals rather than primary factors.
Even if an attacker steals your password through phishing or a breach, they still need the second factor. This single step blocks the vast majority of automated account-takeover attacks, which is why banks, UPI apps and workplaces mandate it. MFA does not make an account unbreakable, but it dramatically raises the cost.
| Factor | Strength | Weakness |
|---|---|---|
| SMS OTP | Weak | SIM swap, phishing, SS7 interception |
| Authenticator app (TOTP) | Medium | Phishable via a real-time proxy page |
| Push approval | Medium | MFA fatigue, accidental approval |
| Hardware key / passkey (FIDO2, WebAuthn) | Strong | Needs a device, small extra cost |
SMS is the weakest because of SIM-swap fraud, a real problem in India where attackers port a victim's number to intercept OTPs. TOTP codes and push prompts can be relayed through phishing proxies that sit between the user and the real site. Only WebAuthn and passkeys are phishing-resistant, because the credential is cryptographically bound to the website's origin, so it simply will not work on a look-alike domain.
| Category | Examples | Main weakness | |
|---|---|---|---|
| Something you know | Password, PIN | Phished, reused, guessed | |
| Something you have | Phone, security key | Lost, SMS intercepted | |
| Something you are | Fingerprint, face | Cannot be changed if leaked |
import { authenticator } from 'otplib';
// On enrolment, generate and store a per-user secret
const secret = authenticator.generateSecret();
// show it as a QR code (otpauth:// URI) for the authenticator app
// On login, after the password passes, verify the 6-digit code
const isValid = authenticator.verify({
token: req.body.code, // the code the user typed
secret, // the user's stored secret
});
// authenticator.verify allows a small time window for clock drift
if (!isValid) return res.status(401).json({ error: 'Invalid code' });
TOTP derives a 6-digit code from a shared secret and the current 30-second time window. The server recomputes the expected code and allows a small drift window so a slightly off clock still works.
Multi-factor Authentication, Authentication Factors, TOTP, WebAuthn, Phishing Resistance