Multi-factor authentication (MFA) in Cybersecurity - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
We want to understand how the time needed to verify a user changes as more authentication steps are added in multi-factor authentication (MFA).
How does adding more factors affect the time it takes to complete login?
Analyze the time complexity of the following MFA verification process.
function verifyMFA(factors) {
for (let i = 0; i < factors.length; i++) {
if (!verifyFactor(factors[i])) {
return false;
}
}
return true;
}
function verifyFactor(factor) {
// Simulate verification step (e.g., password, code, biometric)
return true; // assume success for simplicity
}
This code checks each authentication factor one by one until all are verified or one fails.
- Primary operation: Loop through each authentication factor to verify it.
- How many times: Once for each factor in the list.
As the number of factors increases, the time to verify grows roughly in direct proportion.
| Input Size (n) | Approx. Operations |
|---|---|
| 2 | 2 verification steps |
| 3 | 3 verification steps |
| 5 | 5 verification steps |
Pattern observation: Each added factor adds one more verification step, so time grows linearly.
Time Complexity: O(n)
This means the time to complete MFA grows directly with the number of factors to check.
[X] Wrong: "Adding more factors does not affect login time much because they run in parallel."
[OK] Correct: Usually, MFA factors are checked one after another, so each adds time. They rarely run fully in parallel.
Understanding how verification steps add up helps you explain system delays and design efficient authentication flows.
What if we verified all factors at the same time instead of one by one? How would the time complexity change?
Practice
Solution
Step 1: Understand MFA's role in security
MFA adds additional verification steps beyond just a password to confirm identity.Step 2: Compare options to MFA purpose
Only adding extra verification steps matches MFA's main goal.Final Answer:
To add extra steps to verify a user's identity -> Option DQuick Check:
MFA purpose = extra verification steps [OK]
- Thinking MFA speeds up login
- Believing MFA replaces passwords fully
- Confusing MFA with password storage
Solution
Step 1: Identify MFA factor types
MFA uses factors like something you know, have, or are (biometrics).Step 2: Match options to factor types
Fingerprint is a biometric factor (something you are), common in MFA.Final Answer:
A fingerprint -> Option AQuick Check:
Biometric factor = fingerprint [OK]
- Choosing username or email as MFA factors
- Confusing password as the only factor
- Ignoring biometric options
Solution
Step 1: Analyze the authentication steps
User provides a password (something they know) and a code from phone (something they have).Step 2: Identify authentication type
Using two different factors means this is multi-factor authentication.Final Answer:
Multi-factor authentication -> Option CQuick Check:
Password + phone code = MFA [OK]
- Thinking it's single-factor because password is used
- Confusing with passwordless login
- Assuming biometric is required for MFA
Solution
Step 1: Understand MFA enforcement
MFA must be required for all logins to be effective.Step 2: Identify why password-only logins occur
If users can log in with just passwords, MFA enforcement is incomplete or misconfigured.Final Answer:
MFA is not properly enforced on all accounts -> Option AQuick Check:
Partial MFA enforcement = password-only logins [OK]
- Blaming password strength for MFA bypass
- Confusing biometric use with enforcement issues
- Thinking MFA can require only one factor
Solution
Step 1: Consider user phone loss impact
Users losing phones means phone-based codes can cause access problems.Step 2: Choose alternative strong factor
Biometric verification (fingerprint/face) does not rely on phones and is secure.Step 3: Evaluate other options
Passwords alone are weak, email codes less secure, security questions often guessable.Final Answer:
Add biometric verification like fingerprint or face scan -> Option BQuick Check:
Biometrics reduce phone dependency and keep security strong [OK]
- Skipping MFA to avoid inconvenience
- Relying on email codes which can be intercepted
- Using weak security questions as second factor
