Quick Answer
Adversary-in-the-Middle (AiTM) reverse proxies intercept session cookies by proxying real-time authentication prompts, completely bypassing SMS, TOTP, and standard push notifications. Only cryptographic origin-bound credentials—specifically FIDO2 passkeys, Certificate-Based Authentication (CBA), and Windows Hello for Business—defeat AiTM attacks because the client browser cryptographically signs the authentic domain origin.

This technical guide is part of our comprehensive Zero Trust Identity & Threat Defense Hub, providing production architecture blueprints, step-by-step implementation standards, and real-world failure troubleshooting for modern enterprise identity teams.
Adversary-in-the-Middle (AiTM) reverse proxy toolsets like Evilginx 3, Modlishka, and Muraena have fundamentally broken traditional multi-factor authentication. By sitting transparently between a victim and the genuine identity provider (such as Microsoft Entra ID or Okta), AiTM proxies intercept not only static credentials but also dynamic TOTP codes and mobile push approvals, capturing authenticated session cookies and Primary Refresh Tokens (PRTs) in real time. Defeating AiTM attacks requires understanding why legacy MFA fails at the network transport layer and implementing FIDO2 cryptographic origin binding alongside modern Token Protection (Proof-of-Possession). In this technical deep-dive, we deconstruct the packet-level flow of an AiTM attack, analyze how FIDO2 origin verification neutralizes proxying at Layer 7, and deploy production KQL hunting queries to detect session hijacking in Microsoft Sentinel.
1. The Problem: How Reverse Proxy Frameworks Hijack Authenticated Sessions
Adversary-in-the-Middle (AiTM) phishing is a sophisticated cyberattack wherein a threat actor deploys a reverse proxy server utilizing a lookalike domain with valid TLS certificates to transparently broker all HTTP requests and responses between the target user and the legitimate identity provider.
Security teams often mistakenly believe that enabling Microsoft Authenticator Number Matching or SMS OTP provides immunity against phishing. In an AiTM attack scenario, however, traditional MFA provides zero defense:
- Transparent Relay Mechanism: The proxy server fetches the authentic Microsoft login page (
login.microsoftonline.com) and serves it to the victim under a spoofed domain (e.g.,login.micros0ft-portal.online). Every credential entered by the victim is forwarded to the real Microsoft server in milliseconds. - Dynamic MFA Passthrough: When Microsoft requests a TOTP code or push notification approval, the proxy displays the exact prompt to the user. When the user enters the code or approves the push on their phone, the proxy forwards the completed challenge to Microsoft.
- Session Cookie Exfiltration: Upon successful authentication, Microsoft issues the sensitive authentication cookies (such as
ESTSAUTH,ESTSAUTHPERSISTENT, andESTSAUTHLIGHT). The reverse proxy captures these cookies from the HTTP response headers before delivering the final redirect to the user. - MFA-Bypassed Account Takeover: The attacker imports the stolen session cookies into their own browser. Because the cookies represent an already authenticated, MFA-verified session, the attacker gains full access to SharePoint, Exchange Online, and Azure without triggering any new MFA prompts.
| Authentication Factor | AiTM Phishing Vulnerable? | Underlying Failure Mechanism | Enterprise Security Posture |
|---|---|---|---|
| SMS / Voice OTP | Yes (100% Vulnerable) | Transmitted via unencrypted telecommunications; user easily types code into proxy. | Deprecated (NIST SP 800-63B) |
| TOTP (Authenticator App 6-digit) | Yes (100% Vulnerable) | Time-based code is valid for 30–60 seconds; easily captured and forwarded by proxy. | Weak (Insufficient against modern threats) |
| Push Notification (Number Match) | Yes (100% Vulnerable) | Proxy displays the exact 2-digit number from Microsoft; victim enters number in app. | Vulnerable to AiTM (Stops push bombing only) |
| FIDO2 / Passkey / WebAuthn | No (Cryptographically Immune) | Hardware binds private key signature to browser origin (domain); proxy cannot forge origin. | Mandatory (Zero Trust Baseline) |
| Windows Hello / Entra CBA | No (Cryptographically Immune) | Mutual TLS and client certificate cryptographic challenge response. | Mandatory (Zero Trust Baseline) |
2. The Cryptographic Defense: FIDO2 WebAuthn Origin Binding Explained
The mathematical breakthrough that renders FIDO2 and passkeys immune to AiTM attacks is Origin Binding. During the WebAuthn assertion ceremony, the client browser creates an immutable cryptographic data structure called clientDataJSON:
{
"type": "webauthn.get",
"challenge": "dGhpcy1pcy1hLXJhbmRvbS1jaGFsbGVuZ2Uta2V5",
"origin": "https://login.micros0ft-portal.online",
"crossOrigin": false
}
Notice the origin field. The web browser inspects the URL currently in the browser’s address bar. Even if the webpage looks identical to Microsoft, the browser knows the real hostname is login.micros0ft-portal.online.
When the browser sends this structure to the hardware authenticator (e.g. YubiKey):
- The hardware key hashes the
clientDataJSONusing SHA-256. - The hardware key signs the hash using the private key registered specifically for that service.
- The attacker’s reverse proxy intercepts this signature and forwards it to the genuine Microsoft IdP (
https://login.microsoftonline.com). - Microsoft computes the expected hash of its own legitimate origin (
https://login.microsoftonline.com) and verifies the cryptographic signature. - Result: The signature fails verification because the private key signed a hash containing the attacker’s fake domain string. The sign-in attempt is rejected immediately, and the attacker receives zero usable session cookies.
3. Configuring Phishing-Resistant Authentication Strengths in Entra ID
To eliminate AiTM vulnerability across your tenant, you must configure a Conditional Access policy that strictly requires Phishing-resistant MFA for all users accessing cloud applications.
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "Policy.ReadWrite.ConditionalAccess"
# Retrieve the tenant-wide Phishing-resistant MFA built-in policy ID
$PhishingResistantPolicy = Get-MgIdentityConditionalAccessAuthenticationStrengthPolicy |
Where-Object { $_.DisplayName -eq "Phishing-resistant MFA" }
# Define the Conditional Access Policy structure
$CAParams = @{
DisplayName = "CA001: Enforce Phishing-Resistant MFA for Enterprise Apps"
State = "enabled"
Conditions = @{
Users = @{
IncludeUsers = @("All")
ExcludeUsers = @("f731a556-9b54-46c5-a13f-breakglass1") # Break-glass exclusion
}
Applications = @{
IncludeApplications = @("All")
}
ClientAppTypes = @("browser", "mobileAppsAndDesktopClients")
}
GrantControls = @{
Operator = "OR"
BuiltInControls = @()
AuthenticationStrength = @{
Id = $PhishingResistantPolicy.Id
}
}
}
# Create and enforce policy
New-MgIdentityConditionalAccessPolicy -BodyParameter $CAParams
Write-Host "Phishing-Resistant Conditional Access Policy successfully deployed." -ForegroundColor Green
4. Protecting Authenticated Sessions: Entra ID Token Protection (Proof-of-Possession)
Even with phishing-resistant MFA, what happens if an attacker compromises an endpoint and extracts existing session cookies or tokens directly from browser memory? Microsoft Entra ID solves this through Token Protection (Proof-of-Possession).
Token Protection cryptographically binds the Primary Refresh Token (PRT) and session tokens to the device’s hardware TPM. When a client application (such as Outlook or Teams) calls Microsoft Graph or Exchange Online, it must sign the request with a local hardware key. If an adversary steals the token and attempts to replay it from a remote command-and-control server, the token is rejected because the attacker lacks the device’s physical TPM chip.
5. Hunting AiTM Phishing Attacks with Microsoft Sentinel KQL
Security Operations Center (SOC) analysts can detect in-progress or successful AiTM attacks by hunting for anomalous sign-ins that display user agent anomalies, impossible travel, and MFA claim mismatches:
// Microsoft Sentinel KQL Query: Detecting Stolen Session Token Usage & AiTM Anomalies
SigninLogs
| where TimeGenerated > ago(24h)
| where ResultType == 0 // Successful sign-ins
| extend DeviceDetail = tostring(DeviceDetail.operatingSystem)
| summarize
DistinctIPs = dcount(IPAddress),
IPList = make_set(IPAddress),
DistinctUserAgents = dcount(UserAgent),
UserAgentList = make_set(UserAgent),
Locations = make_set(LocationDetails.countryOrRegion)
by UserPrincipalName, bin(TimeGenerated, 1h)
| where DistinctIPs > 1 and array_length(Locations) > 1
| project TimeGenerated, UserPrincipalName, DistinctIPs, IPList, Locations, UserAgentList
| order by TimeGenerated desc
6. Enterprise Hardening Checklist
- [ ] Replace SMS and push notifications with FIDO2 passkeys and Windows Hello for Business.
- [ ] Deploy Conditional Access requiring “Phishing-resistant MFA” authentication strengths.
- [ ] Enable Microsoft Entra ID Token Protection for Windows, Exchange Online, and SharePoint Online.
- [ ] Block legacy authentication protocols (POP3, IMAP, SMTP, Basic Auth) tenant-wide.
- [ ] Ingest Entra ID SigninLogs into Microsoft Sentinel and configure automated alert triggers for suspicious session cookie usage.
Frequently Asked Questions
How do Evilginx reverse proxies bypass multi-factor authentication (MFA)?
Evilginx terminates TLS on a lookalike domain and acts as a transparent proxy between the victim and the legitimate identity provider. When the user enters their credentials and approves their push notification or TOTP code, the proxy captures the issued ESTSAUTH and ESTSAUTHPERSISTENT session cookies, allowing the attacker to hijack the authenticated session without needing passwords.
Why does FIDO2 WebAuthn cryptographic origin binding prevent reverse proxy interception?
In FIDO2/WebAuthn, the browser securely passes the window.location.origin to the hardware authenticator. The authenticator signs the SHA-256 hash of this origin. Because the proxy domain does not match the expected tenant authority domain, the identity provider detects origin mismatch and aborts authentication.
How do Entra ID Authentication Strengths enforce phishing resistance?
Authentication Strengths is a Conditional Access grant control that lets administrators require specific MFA method combinations. By selecting ‘Phishing-resistant MFA’, Entra ID rejects SMS, voice, TOTP, and standard push notifications, only accepting FIDO2 security keys, CBA, or Windows Hello for Business.
What role does Continuous Access Evaluation (CAE) play if an authenticated token is stolen?
CAE allows resource providers (such as Exchange Online and SharePoint Online) to intercept and revoke sessions within minutes when critical security events occur—such as user account disablement, password reset, or IP address shift outside trusted locations.
Can number matching in Microsoft Authenticator prevent AiTM phishing?
No. While number matching prevents accidental push fatigue approvals, an attacker running a real-time AiTM proxy simply captures the number displayed by Microsoft Entra ID and renders it on the phishing site, prompting the victim to type it correctly.
Official Architecture & Vendor References
- Microsoft Learn: What Are Authentication Strengths in Microsoft Entra ID
- CISA Cybersecurity Alert: Implementing Phishing-Resistant MFA
- Microsoft Learn: Continuous Access Evaluation in Microsoft Entra
- W3C WebAuthn: Origin Binding Security Considerations
- Microsoft Learn: Token Protection (Proof-of-Possession) for Conditional Access
Recommended Hardware & Reference Architecture Literature
Tested tools and authoritative documentation to implement the architectures covered in this lab: