Adversary-in-the-Middle (AiTM) phishing has transformed credential security. Organizations widely deployed Multi-Factor Authentication (MFA) expecting that secondary verification tokens—such as Time-based One-Time Passwords (TOTP), SMS codes, and mobile push notifications—would render stolen passwords useless. However, modern reverse-proxy toolkits like Evilginx 3 execute automated, real-time relays between victims and legitimate identity providers (IdPs), capturing both credentials and authenticated session cookies.
Once session tokens such as ESTSAUTH, ESTSAUTHPERSISTENT, or OAuth bearer credentials are intercepted, adversaries inject them into an unmanaged browser instance. This grants direct cloud access without requiring additional authentication challenges. Defending against this attack surface requires an integrated architecture combining cryptographic phishing-resistant authentication (FIDO2 / WebAuthn) with Layer 3 VPN protective DNS sinkholing and newly registered domain (NRD) isolation.
+-------------------------------------------------------------------------------+
| ADVERSARY-IN-THE-MIDDLE (AiTM) REVERSE PROXY RELAY ARCHITECTURE |
| |
| Victim Workstation Evilginx 3 Proxy Server Genuine IdP (Azure / Okta)|
| +------------------+ +---------------------+ +------------------------+|
| | Target Browser | | Reverse Proxy Node | | Identity Provider ||
| | IP: 203.0.113.45 | | FQDN: auth-corp.net | | FQDN: login.target.com ||
| +--------+---------+ +----------+----------+ +-----------+------------+|
| | | | |
| | 1. HTTP GET /login (Spoofed Link) | | |
| +------------------------------------>| 2. Proxied TLS Handshake | |
| | +------------------------------>| |
| | 3. Genuine Login Page Relayed | | |
| |<------------------------------------+ 4. Render Server Response | |
| | |<------------------------------+ |
| | 5. User Enters Password & TOTP Code | | |
| +------------------------------------>| 6. Forward Credentials & MFA | |
| | +------------------------------>| |
| | | 7. Session Cookie Issued | |
| | 8. Session Established & Redirect |<------------------------------+ |
| |<------------------------------------+ | |
| | | [!] Stolen ESTSAUTH Cookie | |
| | | Exfiltrated to Adversary C2 | |
+-------------------------------------------------------------------------------+
The Architecture of Adversary-in-the-Middle Phishing Proxies
Conventional credential harvesting relied on static clone pages that replicated login portal designs. Because static pages could not dynamically generate cryptographic challenges or evaluate incoming SMS/TOTP codes, they were ineffective against modern MFA deployments. In contrast, an AiTM deployment operates as an intelligent dynamic proxy forwarding HTTP/HTTPS traffic in both directions.
When an employee opens a link pointing to an attacker-controlled domain (such as login.microsoftonline.corp-auth[.]net), Evilginx 3 initiates a concurrent TLS session toward the genuine authentication endpoint (login.microsoftonline.com). The proxy terminates the user TLS handshake, inspects request parameters, modifies host headers, and sends the payload to the real identity provider. The server’s authentic response—including tenant branding, user avatars, and localized challenge strings—is streamed back to the victim’s browser without noticeable delay.
Session Cookie Interception and Real-Time MFA Relay Mechanics
The critical exposure occurs at the culmination of the authentication exchange. When the user fulfills their secondary factor—whether entering an authenticator app numeric code or tapping an approval prompt on a smartphone—the genuine identity provider validates the token and issues an HTTP response containing authorization headers.
These headers establish the persistent session:
HTTP/1.1 302 Found
Set-Cookie: ESTSAUTH=0.AXEA...[TRUNCATED]...; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None
Set-Cookie: ESTSAUTHPERSISTENT=1.AXEA...; domain=.login.microsoftonline.com; expires=Wed, 16-Dec-2026 12:00:00 GMT; path=/; secure; HttpOnly
Location: https://portal.office.com/landing
Because the reverse proxy decrypts inbound and outbound TLS traffic traversing its socket, it monitors response headers for specific session keys defined in its configuration. Evilginx 3 captures the full cookie string along with user metadata, commits the token to its local database, triggers an automated webhook notification to the adversary's command-and-control (C2) server, and redirects the victim to the legitimate enterprise dashboard. To the user, the login appeared authentic.
Threat Vectors: Evilginx Phishlets and Session Hijacking
The modularity of modern AiTM frameworks is powered by configuration templates known as phishlets. Written in YAML, a phishlet specifies target hosts, proxy domains, credential extraction regex patterns, and session cookie identifiers needed to compromise a specific SaaS application or identity ecosystem.
A typical configuration block illustrates this mechanism:
# Conceptual Evilginx 3 Phishlet Configuration Block
name: 'enterprise-idp-auth'
author: 'Research Analysis'
min_ver: '3.3.0'
proxy_hosts:
- {phish_sub: 'login', orig_sub: 'login', domain: 'target-identity.com', session: true, is_landing: true}
- {phish_sub: 'portal', orig_sub: 'portal', domain: 'target-identity.com', session: false, is_landing: false}
auth_tokens:
- domain: '.target-identity.com'
keys: ['ESTSAUTH', 'ESTSAUTHPERSISTENT', 'SignInStateCookie']
credentials:
username:
key: 'loginfmt'
search: '(.*)'
type: 'post'
password:
key: 'passwd'
search: '(.*)'
type: 'post'
Why Traditional MFA Fails Against Reverse Proxy Relay Attacks
Traditional MFA mechanisms are vulnerable to AiTM proxies because they establish trust between the user and the prompt, rather than binding authentication to the specific TLS server identity of the browser’s active address bar.
- Shared Secret Asymmetry (TOTP): An RFC 6238 TOTP algorithm calculates a 6-digit string based on an HMAC-SHA1 calculation over a 30-second epoch. The code carries no contextual metadata regarding the URL, domain, or TLS certificate of the requesting host. When entered into an Evilginx form, the proxy relays the identical digits to the authentic server within the valid window, satisfying verification.
- Push Notification Blindness: Out-of-band push authentication transmits an approval request to the user’s mobile device. Because the proxy initiates the upstream transaction toward the genuine IdP, the IdP dispatches an authentic prompt displaying matching numbers. The victim, believing they initiated the login, approves the prompt.
- Pass-the-Cookie Exfiltration: Once the session token is logged, the attacker imports it into a dedicated browser profile. Because cloud applications treat a valid session cookie as proof of authentication, the adversary gains access without re-prompting for MFA.
Network Defense: Intercepting Phishing Infrastructure via RiceGuard Layer 3
While application-level authentication upgrades are essential, organizations cannot rely solely on end-user vigilance to identify spoofed domain names. Attackers register homoglyph domains, deceptive subdomains, and newly registered domains (NRDs) that closely mimic enterprise portals. Deploying network-level protective DNS sinkholing and encrypted Layer 3 VPN routing establishes an automated perimeter that terminates malicious connections before an AiTM TLS handshake can initiate.
+-------------------------------------------------------------------------------+
| LAYER 3 PROTECTIVE DNS SINKHOLE & ISOLATION PIPELINE |
| |
| Workstation Client RiceGuard WireGuard Tunnel DoH Threat Intelligence Sinkhole|
| +--------------------+ +-------------------------+ +-------------------------------+|
| | User clicks lure: | | Layer 3 Kernel Device | | Recursive DoH Resolver ||
| | auth.corp-sso.xyz | | wg0 Interface Routing | | Threat DB: NRDs, Phishing DGAs||
| +---------+----------+ +------------+------------+ +---------------+---------------+|
| | | | |
| | 1. DNS Query: auth.corp-sso.xyz | | |
| +-------------------------------------->| 2. Encapsulated DoH Packet | |
| | +---------------------------------->| |
| | | | 3. Evaluate: |
| | | | - Domain age < 14d|
| | | | - Homoglyph check |
| | | 4. Return Sinkhole (0.0.0.0 / NX) | |
| | 5. Connection Blocked (ERR_NAME) |<----------------------------------+ |
| |<--------------------------------------+ |
| | [!] TCP SYN Never Leaves Workstation |
+-------------------------------------------------------------------------------+
1. Protective DNS Sinkholing and Newly Registered Domain Blocking
Because AiTM phishing campaigns depend on throwaway domain infrastructure that is frequently stood up hours before an attack, inspecting DNS resolution at Layer 3 provides decisive early interception.
When traffic routes through RiceGuard’s encrypted WireGuard tunnel, DNS requests are encapsulated and directed to an internal recursive DoH resolver equipped with real-time heuristic feeds:
- Newly Registered Domain (NRD) Blackholing: Domains registered within the preceding 14 to 30 days are automatically quarantined or resolved to
0.0.0.0. Most active Evilginx 3 phishing campaigns operate on NRDs to evade domain reputation filters. - Typosquatting and Homoglyph Entropy Analysis: Algorithms evaluate the Levenshtein distance between requested hostnames and critical corporate enterprise services. High-entropy matches trigger immediate sinkholing.
- Zero-RTT Response Neutralization: By returning an
NXDOMAINor0.0.0.0response at the resolver layer, the client browser never initiates a TCP handshake or TLS Client Hello toward the phishing proxy IP address, preventing any credential or session leakage.
2. Linux Kernel Egress Filtering and Zero-Trust Endpoint Isolation
To ensure that rogue applications cannot evade protective DNS routing via hardcoded IP addresses or external DoH servers, workstations enforce strict kernel-level egress boundaries using Netfilter (nftables):
# nftables configuration enforcing RiceGuard DNS and Tunnel Egress
table inet filter {
chain output {
type filter hook output priority 0; policy drop;
# Allow loopback communication
oif "lo" accept
# Allow established and related traffic
ct state established,related accept
# Allow encrypted WireGuard tunnel endpoint traffic on UDP 51820
oif "eth0" udp dport 51820 accept
# Force all DNS traffic strictly through internal VPN sinkhole resolver
oif "wg0" udp dport 53 accept
oif "wg0" tcp dport 53 accept
oif "wg0" tcp dport 853 accept
# Allow standard web egress strictly inside WireGuard interface
oif "wg0" tcp dport { 80, 443 } accept
# Drop any direct outbound DNS traffic outside the VPN tunnel
udp dport 53 counter drop
udp dport 853 counter drop
}
}
This ruleset guarantees that any outbound packet attempting to communicate with external DNS resolvers outside the WireGuard virtual interface is dropped by the kernel before transmission.
Technical Verification and Egress Traffic Inspection
Validating workstation protection against AiTM reverse proxies involves auditing both the DNS resolution layer and network socket behavior during external authentication attempts.
Auditing Suspicious Inbound TLS Handshakes and Domain Routing
Security engineers can evaluate DNS sinkhole efficacy and identify malicious reverse proxy traits by performing systematic diagnostic queries from the command line:
# Test 1: Verify DNS sinkhole resolution against a simulated suspicious phishing domain
$ dig +short @10.10.0.1 login.corporate-sso-verify.xyz
0.0.0.0
# Test 2: Inspect TLS certificate details and Subject Alternative Names (SAN)
$ echo | openssl s_client -servername login.corporate-sso-verify.xyz \
-connect 198.51.100.22:443 2>/dev/null | openssl x509 -noout -dates -issuer -subject
notBefore=Nov 16 04:12:00 2026 GMT
notAfter=Feb 14 04:12:00 2027 GMT
issuer=C = US, O = Let's Encrypt, CN = R3
subject=CN = login.corporate-sso-verify.xyz
When an audit reveals an SSL certificate issued within hours of the domain's registration date alongside mismatched root ownership, the domain matches typical automated Evilginx deployment signatures.
Security Posture Comparison Across Defense Tiers
| Authentication & Defense Tier | Vulnerability to AiTM Relays | Phishing Resistance Mechanism | Session Token Protection | Deployment Complexity |
|---|---|---|---|---|
| Passwords + SMS / Email OTP | Critical (100% Vulnerable) | None; shared secret digits are proxied directly to IdP in real time. | None; tokens vulnerable to theft. | Low (Legacy standard) |
| Mobile Push Notifications | High (Vulnerable to Relay) | Weak; users approve push prompts triggered concurrently by proxy. | None; session cookies intercepted. | Medium (App enrollment) |
| Layer 3 VPN + DNS Sinkhole | Robust Network Defense | High; resolves phishing domains to 0.0.0.0, cutting connection pre-TLS. |
Mitigates exposure by preventing connection. | Medium (WireGuard client) |
| FIDO2 / WebAuthn Hardware Keys | Cryptographically Immune | Absolute; client binds signature to browser origin URL; proxy fails. |
Pre-authentication interception blocked. | High (Security key roll-out) |
| Device Bound Session Credentials (DBSC) | Robust Endpoint Defense | High; binds session cookie to local TPM hardware cryptographic key. | Complete; stolen cookies unusable on attacker host. | Emerging (OS/Browser integration) |
Practical Guidelines for Deploying Phishing-Resistant Authentication
Mitigating AiTM credential interception requires transitioning away from legacy authentication models while reinforcing transport-layer boundaries:
- Mandate FIDO2 / WebAuthn Hardware Security Keys: Migrate privileged identities to physical cryptographic keys (such as YubiKeys or platform authenticators like Windows Hello and Passkeys). WebAuthn signs a challenge combined with the exact origin URL reported by the browser engine (
https://login.microsoftonline.com). When passed through an Evilginx domain (https://login.corporate-sso-verify.xyz), origin validation fails cryptographically at the client layer, aborting the transaction. - Implement Device Bound Session Credentials (DBSC): Enable DBSC protocols across supported browsers and identity platforms. DBSC binds active HTTP session tokens to a private key stored within the workstation's Trusted Platform Module (TPM). Even if an attacker captures the session cookie via an AiTM proxy, the cookie cannot be used on an adversary workstation lacking the matching hardware private key.
- Enforce Conditional Access and Managed Device Compliance: Configure cloud IdPs to reject authentication requests originating from non-compliant, unmanaged machines. Requiring Mutual TLS (mTLS) device certificates ensures that even if an adversary acquires a valid session token, the token cannot be redeemed from an external, untrusted IP space without a valid client certificate.
- Deploy Always-On Layer 3 Protective Tunneling: Ensure workstations route all external traffic through WireGuard tunnels equipped with real-time protective DNS intelligence. By automatically sinkholing newly registered domains and known proxy nodes, the network layer intercepts phishing attacks long before users encounter deceptive login interfaces.



