Adversary-in-the-Middle (AiTM) phishing kits like Evilginx, Modlishka, and Tycoon 2FA routinely defeat password-plus-OTP authentication by proxying live login traffic between victims and legitimate identity providers. Because the attacker captures authenticated session cookies and OAuth tokens in real time, SMS codes, email OTPs, and even TOTP authenticator apps no longer stop account takeovers.
Key Takeaways
- AiTM reverse proxies terminate TLS on a lookalike domain, relay passwords and 6-digit OTPs in real time, and harvest the resulting session cookie without ever cracking MFA cryptography.
- FIDO2 WebAuthn passkeys cryptographically bind every assertion signature to the exact browser-verified origin and Relying Party ID (rpId), causing proxied assertions to fail automatically.
- Allowing phishable fallback factors such as TOTP or SMS alongside passkeys enables AiTM toolkits to trigger silent downgrade attacks by suppressing WebAuthn JavaScript.
- Production WebAuthn verification must validate the exact origin, SHA-256 rpIdHash, single-use 32-byte challenge, and User Verification (UV) bit flag on every login.
Anatomy of an AiTM Reverse-Proxy Phishing Attack
Traditional credential harvesting pages captured static usernames and passwords on cloned HTML forms, which made time-based one-time passwords (TOTP) and SMS codes effective secondary barriers. Modern Adversary-in-the-Middle frameworks replace static clones with a live HTTP reverse proxy configured via domain-specific phishlets. When a targeted employee clicks a lure pointing to a lookalike hostname such as login-sso-verify.com, the proxy fetches the genuine login page from the real identity provider, rewrites response headers and links on the fly, and serves it over a valid Let's Encrypt TLS certificate.
As the victim submits their email, password, and 6-digit authenticator code, the reverse proxy relays every HTTP POST directly to the legitimate authorization server within milliseconds. The identity provider validates the genuine credentials and OTP, then returns an authenticated Set-Cookie header or OAuth authorization code. The proxy intercepts and persists those session tokens for the attacker while transparently redirecting the victim to the real corporate portal so nothing appears broken.
- Real-time Host and Origin header rewriting masks the proxy domain while maintaining live upstream session state with the legitimate IdP.
- Both RFC 6238 TOTP codes and SMS/Email OTPs are bearer secrets: they contain zero cryptographic awareness of the TLS hostname displayed in the browser address bar.
- Captured session cookies allow attackers to import authenticated browser sessions immediately, bypassing subsequent MFA checks for the lifetime of the cookie.
- Phishing-as-a-Service platforms such as Tycoon 2FA and EvilProxy add Cloudflare Turnstile gates and residential exit nodes to evade email scanners and IP reputation filters.
# 1. Victim submits real password + TOTP code to attacker's reverse proxy
POST /oauth/mfa/verify HTTP/1.1
Host: login-sso-verify.com
Origin: https://login-sso-verify.com
Content-Type: application/json
{"challengeId":"ch_94f1c2","factorType":"TOTP","code":"482910"}
# 2. Evilginx rewrites Host/Origin and relays verbatim to genuine IdP
POST /oauth/mfa/verify HTTP/1.1
Host: auth.sso.id
Origin: https://auth.sso.id
# 3. Genuine IdP accepts valid OTP and returns session cookie -> HARVESTED
HTTP/1.1 200 OK
Set-Cookie: .SSO.Session=eyJhbGciOiJSUzI1NiIs...; HttpOnly; Secure; SameSite=Lax
How WebAuthn Cryptographic Origin Binding Breaks Proxies
FIDO2 WebAuthn eliminates the shared-secret flaw that makes OTPs relayable by replacing user-typed codes with browser-mediated asymmetric cryptography. During enrollment, the user's authenticator generates a unique ECDSA P-256 or RSA key pair scoped strictly to the Relying Party identifier (rpId), such as sso.id or a tenant's verified custom domain auth.company.com. Only the public key is transmitted to the server; the private key never leaves the device's Secure Enclave, TPM, or hardware security token.
When an AiTM proxy intercepts a WebAuthn sign-in flow and forwards the server's PublicKeyCredentialRequestOptions challenge to the victim's browser, the browser inspects the actual top-level TLS origin in the address bar before invoking the authenticator. If the proxy leaves rpId set to sso.id while serving from login-sso-verify.com, the browser immediately throws a SecurityError because the origin is not a valid subdomain of the rpId. Even if the proxy rewrites rpId to login-sso-verify.com, the authenticator finds zero matching credentials for the attacker's domain—and even if a rogue credential were signed, the resulting clientDataJSON origin and authenticatorData rpIdHash would not match the real identity provider's expected values.
- The browser constructs clientDataJSON independently of page JavaScript, embedding the immutable top-level origin, server challenge, and ceremony type (webauthn.get).
- The authenticator computes authenticatorData containing the 32-byte SHA-256 hash of the requested rpId alongside presence, verification, and signature counter flags.
- The hardware key signs the concatenation authenticatorData || SHA-256(clientDataJSON), making post-hoc tampering by a reverse proxy mathematically impossible.
- Because the browser enforces Same-Origin Policy and effective-domain checks outside the attacker's JavaScript execution context, users do not need to spot subtle homoglyph URLs.
{
"authBeginResponse": {
"challenge": "m1n2b3v4c5x6z7l8k9j0h1g2f3d4s5a6q7w8e9r0t1y",
"rpId": "auth.cloudpulse.io",
"timeout": 60000,
"userVerification": "required",
"allowCredentials": [
{
"type": "public-key",
"id": "cred_881920394857abcdef112233"
}
]
},
"browserSignedClientDataJSON": {
"type": "webauthn.get",
"challenge": "m1n2b3v4c5x6z7l8k9j0h1g2f3d4s5a6q7w8e9r0t1y",
"origin": "https://auth.cloudpulse.io",
"crossOrigin": false
}
}
Hardening Assertion Verification and Eliminating MFA Downgrades
Deploying passkeys without enforcing strict server-side verification and policy lockdown leaves two dangerous gaps. First, a careless relying party implementation that verifies the signature over clientDataJSON without checking the parsed origin and authenticatorData rpIdHash against an explicit server-side allowlist can accidentally accept assertions minted for unintended subdomains. Second, real-world AiTM campaigns actively perform MFA downgrade attacks: the proxy injects JavaScript that deletes navigator.credentials or advertises an outdated User-Agent header, tricking the identity provider into falling back to TOTP or SMS.
To guarantee genuine phishing resistance, high-privilege accounts and sensitive applications must enforce a phishing-resistant policy tier where phishable factors are completely disabled as fallback options. On the server side, every WebAuthn assertion endpoint must consume single-use challenges with a strict 60-second TTL, verify both the User Present (UP) and User Verification (UV) flags when biometric or PIN verification is required, and reject cross-origin assertions unless explicitly authorized.
- Bind each WebAuthn challenge to a short-lived server-side nonce store and atomically delete it upon first verification to block replay attempts.
- Assert exact string equality on clientData.origin against the tenant's verified origin (e.g., https://auth.cloudpulse.io) and compare SHA-256(rpId) in constant time.
- Inspect authenticatorData byte 32 flags: require UP (0x01) and UV (0x04) bits to confirm a live human unlocked the authenticator locally.
- Remove TOTP, SMS, and Email OTP from the allowed factor list on protected apps so AiTM proxies cannot force a silent protocol downgrade.
public VerificationResult VerifyAssertion(
WebAuthnAssertion assertion,
StoredPasskey storedKey,
ExpectedCeremony expected)
{
var clientData = JsonSerializer.Deserialize<ClientData>(assertion.ClientDataJson);
if (clientData is null || clientData.Type != "webauthn.get")
return VerificationResult.Fail("Invalid ceremony type");
if (!CryptographicOperations.FixedTimeEquals(
Encoding.UTF8.GetBytes(clientData.Challenge),
Encoding.UTF8.GetBytes(expected.Challenge)))
return VerificationResult.Fail("Challenge mismatch or expired");
if (!string.Equals(clientData.Origin, expected.Origin, StringComparison.Ordinal))
return VerificationResult.Fail($"Origin mismatch: {clientData.Origin}");
var expectedRpIdHash = SHA256.HashData(Encoding.UTF8.GetBytes(expected.RpId));
var actualRpIdHash = assertion.AuthenticatorData[..32];
if (!CryptographicOperations.FixedTimeEquals(actualRpIdHash, expectedRpIdHash))
return VerificationResult.Fail("rpIdHash mismatch");
byte flags = assertion.AuthenticatorData[32];
bool userPresent = (flags & 0x01) != 0;
bool userVerified = (flags & 0x04) != 0;
if (!userPresent || (expected.RequireUv && !userVerified))
return VerificationResult.Fail("User presence or biometric verification missing");
byte[] clientDataHash = SHA256.HashData(assertion.ClientDataJson);
byte[] signedPayload = [.. assertion.AuthenticatorData, .. clientDataHash];
bool validSig = storedKey.VerifySignature(signedPayload, assertion.Signature);
return validSig ? VerificationResult.Ok() : VerificationResult.Fail("Invalid signature");
}
Always lock down your custom authentication domain (such as auth.yourcompany.com) before enrolling users into FIDO2 passkeys. Because WebAuthn credentials are permanently scoped to the rpId chosen at registration, switching domains later forces users to re-enroll every passkey.
Enforcing Phishing-Resistant Policies Across Tenants and Apps
Migrating an active enterprise or B2B SaaS user base to phishing-resistant passkeys succeeds when policy enforcement follows risk tiers rather than an all-or-nothing flip. Start by enforcing passkey-only authentication for tenant administrators, security engineers, and billing owners while using a time-boxed enrollment grace period for standard users. Require every user to register at least two distinct passkeys—for example, a platform authenticator like MacBook TouchID paired with a smartphone passkey or USB-C security key—before removing legacy OTP factors.
As adoption crosses 90% on a given application or customer organization, apply scoped factor overrides that restrict sign-ins on sensitive consoles exclusively to FIDO2 WebAuthn while keeping controlled fallback paths for low-risk legacy integrations. Pair this rollout with real-time SIEM webhook monitoring for failed WebAuthn origin checks or unexpected factor downgrade attempts, giving security teams immediate early warning when an AiTM campaign targets their workforce.
- Enforce phishing-resistant policies first on Tier-1 admin consoles, CI/CD portals, and financial applications where session hijacking carries maximum blast radius.
- Use scoped application and organization overrides so regulated B2B customers can mandate passkey-only MFA before smaller tenants complete onboarding.
- Provision white-labeled custom domains with automated DNS and TLS verification so employees recognize a consistent corporate rpId during every prompt.
- Audit sign-in telemetry weekly to identify remaining TOTP or SMS logins and convert stragglers before closing phishable fallback windows.
How SSO.ID Stops AiTM Phishing Natively with FIDO2 Passkeys
SSO.ID v2 implements W3C WebAuthn Level 2 natively on auth.sso.id and on your verified 1-click custom domains, enabling both passkey-as-primary passwordless login and phishing-resistant MFA enforcement across Tenants, Applications, Organizations, and Organization Units.
- ✓Native WebAuthn registration (/oauth/passkey/register-begin) and assertion (/oauth/passkey/auth-begin) with strict origin, rpIdHash, challenge, and signature counter validation.
- ✓Granular Tier 1-4 MFA overrides let you disable phishable SMS and TOTP factors on privileged applications and B2B organizations while enforcing fido2PasskeysEnabled.
- ✓1-click Custom Domain Auto-Connect (Cloudflare, GoDaddy, Hostinger, Namecheap) with managed TLS so passkeys bind cleanly to your corporate rpId.
- ✓Multi-Factor Step-Up (requireMultipleFactors) and real-time HMAC-signed SIEM webhooks surface anomalous login and impossible-travel events immediately.
Frequently Asked Questions
No. Even if an attacker rewrites the rpId field in the WebAuthn challenge to match the phishing domain, the user's browser and authenticator hold no passkey registered for that lookalike domain. If the attacker leaves the legitimate rpId untouched, the browser blocks the ceremony outright with a SecurityError because the active TLS origin does not match the rpId.
If the identity provider allows the user to choose TOTP as an alternative to their passkey, modern AiTM phishlets will hide the WebAuthn option or spoof an unsupported browser to force a TOTP downgrade. To block AiTM completely, disable phishable fallback factors for passkey-enrolled users and privileged applications.
Using a dedicated custom domain such as auth.yourcompany.com isolates authentication cookies and WebAuthn scope cleanly from marketing sites and third-party SaaS subdomains. Only choose the apex domain if multiple sibling subdomains independently execute WebAuthn ceremonies against shared passkeys.