Two-Factor Authentication (2FA/MFA) Bypass Testing

Two-factor authentication is supposed to be the backstop. Even if an attacker steals credentials, 2FA catches them at the door. The reality is that 2FA implementations vary enormously in quality — and a surprising number have bypass vulnerabilities that can be found through systematic testing.

This guide covers the most common 2FA/MFA implementation flaws, how to test for them, and what secure implementations look like. This is not about SIM swapping or social engineering — it is about application-level vulnerabilities in the authentication flow itself.


2FA Bypass Categories

Before testing, understand the landscape. 2FA bypasses fall into a few broad categories:

Category Root Cause Severity
Response manipulation Client-controlled auth decision Critical
OTP reuse No invalidation after use High
Brute-forceable OTP No rate limiting on verification High
Step skipping Improper session state tracking Critical
Backup code abuse Unlimited use or predictable codes High
Token leakage OTP exposed in response/logs High
Account enumeration Different responses per account Medium

Test 1: Response Manipulation

This is the most damaging and embarrassingly common bypass. The server validates the OTP, then returns a JSON response like {"success": false, "message": "Invalid code"}. The client reads that response and decides whether to grant access. Some implementations make the auth decision on the client side based on this response.

Test this by intercepting the 2FA submission request and modifying the response before it reaches the client:

# Intercept the OTP submission response and change:
# {"success": false, "mfa_verified": false}
# to:
# {"success": true, "mfa_verified": true}

# In Burp Suite: Proxy → Intercept → Response modification rules
# Or use match-and-replace on responses from /api/mfa/verify

If the application grants access after you flip the response to success with an invalid OTP, the auth decision is happening client-side. This is a critical finding.

Also test HTTP status code manipulation. Some apps check only the HTTP status, not the response body:

# Test: submit wrong OTP, intercept response
# Change 403 to 200 in the response
# Does the app redirect to the authenticated area?

Test 2: OTP Reuse

Time-based OTPs (TOTP) should be invalidated after use. If the same 6-digit code can be submitted twice within its validity window and succeed both times, the implementation is not invalidating used tokens.

# Test procedure:
# 1. Generate a valid TOTP code from your authenticator app
# 2. Use it to authenticate successfully (step 1)
# 3. Log out
# 4. Before the 30-second window expires, attempt to authenticate again
#    using the same TOTP code
# Expected: second attempt should fail with "code already used"
# Vulnerable: second attempt succeeds

This matters most in high-security contexts. An attacker who captures an OTP in transit (man-in-the-middle, phishing) can replay it before the window expires.

Test 3: Rate Limiting on OTP Verification

TOTP codes are 6 digits: 1,000,000 possible values. At 30-second windows, an attacker who can make unlimited attempts could cycle through all values within hours. SMS OTPs are typically 4-6 digits, worse.

# Burp Suite Intruder attack against OTP endpoint
POST /api/mfa/verify
{"code": "§000000§"}

# Payload: Numbers 000000 to 999999
# Look for:
# - Rate limit after N attempts
# - Account lockout
# - CAPTCHA challenge
# - Response time changes

# If no rate limiting: document OTP length + attempt rate = time to brute force

Test lockout behavior separately: does the account lock? Does it lock the first factor (password) or just the 2FA step? Does it send an alert?

Test 4: Step Skipping (Authentication Flow Bypass)

Multi-step authentication flows often use session state to track progress: "user has provided valid password, now awaiting MFA." If that state tracking is incomplete, an attacker can skip directly to a post-MFA endpoint.

# Test procedure:
# 1. Complete a full login with MFA — capture all cookies/tokens at each step
# 2. Note the session token issued after step 1 (password) but before MFA
# 3. In a separate session, complete step 1 (password) only
# 4. Use the step-1 session token to directly request authenticated endpoints
#    that normally require completed MFA
# 5. Also test: directly navigating to /dashboard or /api/user with a step-1 token

# Vulnerable if: server accepts step-1 token on step-2-only endpoints

Common variants:

Test 5: OTP in API Response

This sounds too obvious to be real. It happens. Some implementations send the OTP to the user via SMS, but also include it in the API response — presumably for debugging or testing — and that code was never removed from production.

# After triggering "send OTP" request, inspect the API response:
POST /api/auth/send-otp
Response:
{
  "status": "sent",
  "message": "Code sent to +31**6****789",
  "debug_otp": "482617"   # This is the vulnerability
}

Also check application logs accessible to users, error messages that echo back submitted values, and email confirmations that include the raw OTP.

Test 6: Backup Code Abuse

Backup codes are one-time use codes for account recovery. Test these attack vectors:

# Test backup code endpoint independently:
POST /api/auth/backup-code
{"code": "XXXXX-XXXXX"}

# Apply same Intruder testing as TOTP — are backup codes brute-forceable?
# Note backup code format (length, character set) from the "generate backup codes" UI

Test 7: "Remember This Device" Bypass

Many applications offer a "remember this device for 30 days" option to skip 2FA on trusted devices. This creates a cookie or token that grants MFA-equivalent trust.

# After using "remember device":
# 1. Find the remember-device cookie/token (usually separate from session)
# 2. Test if this token can be used across accounts (IDOR)
# 3. Test if the token expires as documented
# 4. Test if the token is predictable (sequential IDs, weak entropy)
# 5. Test if invalidating MFA (disabling/re-enabling) revokes remember-device tokens
# 6. Test if the token works on different IP addresses than it was issued on

Test 8: Account Enumeration via 2FA

If 2FA responds differently depending on whether an account exists, attackers can enumerate valid usernames by reaching the 2FA step.

# Test: submit a valid password for a known account vs invalid account
# If "enter your MFA code" only appears for valid accounts while
# invalid accounts get "incorrect password" immediately, you have enumeration.

# Also test the OTP verification endpoint directly with nonexistent account IDs
POST /api/mfa/verify
{"user_id": "nonexistent", "code": "123456"}
# vs
{"user_id": "valid-user", "code": "123456"}

# Response differences (timing, body, status) = enumeration

Test 9: TOTP Shared Secret Exposure

When setting up an authenticator app, applications display a QR code that encodes a TOTP shared secret. That secret, once established, should not be retrievable again. Test whether:

Test 10: MFA Enrollment Bypass

If MFA is mandatory for an account type, test whether enrollment can be skipped:

# Post-registration flow: new accounts are forced to enroll in MFA
# 1. Create new account
# 2. Note the "enroll MFA" redirect
# 3. Directly navigate to /dashboard before completing enrollment
# 4. Test API endpoints directly with the pre-enrollment session token

# Also test: can you remove MFA from an account without re-authentication?
DELETE /api/auth/mfa
# Should require: current password + valid MFA code
# Vulnerable: only requires session token

Automated vs Manual Testing

Automated scanners catch some of these — rate limiting failures, response header analysis, and session token entropy checks can be automated. But most 2FA bypass testing is flow-based and requires understanding the specific authentication sequence.

Test Automated Manual Required
Rate limiting Yes No
Response manipulation Partial Flow-specific
OTP reuse No Yes
Step skipping No Yes
OTP in response Yes (pattern matching) No
Account enumeration Partial Timing analysis

What Secure 2FA Looks Like

A well-implemented 2FA system:

Test your 2FA implementation before attackers do. Ironimo runs automated security scanning using real Kali Linux tools — including authentication flow testing, rate limit checks, and response analysis. Get continuous coverage without scheduling a pentester.

Start free scan

Key Takeaways

← Back to Blog