CCyberwiki

Adversary-in-the-middle phishing

Adversary-in-the-middle phishing
ClassAuthentication
Also known asAiTM phishing, reverse-proxy phishing
OWASP Top 10A07:2025 Authentication Failures
MITRE ATT&CKT1557 Adversary-in-the-Middle
Typical severityHigh
AffectsAccounts protected by a password plus a typed or approved second factor; any site whose session lives in a cookie
Common kitsEvilginx, Modlishka, Muraena

A person clicks a link to example-login.net and sees the real sign-in page of a service they use, fetched from that service by a server the attacker runs and passed back one request at a time.1 The person types a password and a code from an authenticator app, both reach the real service through the attacker's server, and the service replies with a session cookie. The attacker keeps a copy of that cookie, loads it into their own browser and is signed in, without needing the password or the code again.1 This is adversary-in-the-middle phishing (AiTM phishing), a form of Phishing built to get past multi-factor authentication.

The relay

An AiTM kit is a reverse proxy. It forwards each HTTP request from the victim to the real site and each response back, so the attacker builds no copy of the page. The page looks and behaves like the original, and the address bar is the one visible difference.1

Victim's browserexample-login.netAttacker's proxykeeps a copy of allReal servicelogin.example.comTLS session 1: browser to proxy, on the proxy's own domain.TLS session 2: proxy to the real service, which sees the proxy as the user.The password, the one-time code and the session cookie all pass through the middle box.
Figure 1. The proxy holds two separate encrypted connections, one with the victim and one with the real service, and reads everything that crosses between them.

The proxy runs one TLS session with the victim and a second with the real service, so the victim's encrypted connection ends at the attacker's server.1 Evilginx, the kit used in the campaign below, was first released in 2017 on a modified nginx web server and now ships as a Go program with its own HTTP and DNS servers.2 Its author describes it as a tool for capturing passwords together with session cookies to get around two-factor sign-in, to be used only in penetration tests with written permission.2

Why typed codes do not help

A TOTP code and a one-time code sent by text message both prove that the person holds a device. Neither records which website asked for it. Under NIST's authentication guideline, no method where the user copies a code by hand counts as phishing-resistant authentication, because nothing ties the code to the session it was meant for, and a fake verifier can pass it on to the real one.3 To the service, the cookie that comes back is proof of a completed sign-in; in Microsoft's 2022 investigation, several stolen cookies carried a claim that MFA had been passed.1 The theft happens after the sign-in has finished, so the method used to sign in makes no difference to it.1 The attacker then uses the cookie the way any hijacked session is used.

Naming

The name is shared with a network technique. The ATT&CK entry for adversary-in-the-middle covers placing a machine between two devices by abusing network protocols such as ARP, DNS and LLMNR, or through a fake Wi-Fi access point; Evilginx appears in the same entry as an example, a relay that captures passwords, tokens and session cookies.4

The 2022 Office 365 campaign

In July 2022 Microsoft described a run of AiTM campaigns that had tried to reach more than 10,000 organizations since September 2021. The phishing sites proxied the Office online sign-in page using Evilginx2.1 With a stolen cookie the attackers opened the victim's mailbox in Outlook on the web, and in some cases began payment fraud within five minutes of the theft. They searched for email threads about invoices and payments, deleted the original phishing message, and created an inbox rule that moved mail from the company chosen for the fraud to the Archive folder and marked it as read, so the victim would not see the replies. They then answered the payment threads and deleted their own replies from Sent Items and Deleted Items.1 Rules of this kind, and how to find them, are the subject of Email forwarding rules.

Defences

Origin-bound sign-in

Passkeys and security keys stop the relay at the protocol level. Under WebAuthn the browser writes the full origin of the page into the data the authenticator signs, so a signature made on one origin cannot be replayed on another.5 Each passkey is also tied to a relying party ID, a domain name, and the browser rejects a request whose ID is not the page's own domain or a parent of it. A page on example-login.net cannot ask for the passkey made for example.com.5 On the server, the check is the expected origin and relying party ID passed to the verifier:6

// Node.js with @simplewebauthn/server 14.x
const verification = await verifyAuthenticationResponse({
  response: body,
  expectedChallenge: currentOptions.challenge,
  expectedOrigin: "https://example.com", // no trailing slash
  expectedRPID: "example.com",
  credential: { id: passkey.id, publicKey: passkey.publicKey,
                counter: passkey.counter, transports: passkey.transports },
});

Standard Evilginx configurations usually stop with an error when they reach a passkey prompt.7 The protection holds only while the account has no weaker way in. In August 2025 Proofpoint researchers built a configuration that posed as Safari on Windows, a browser Microsoft's sign-in service, Entra ID, does not support for passkeys, so the sign-in page offered the user's other method instead. The attack needs an account that keeps such a fallback, and the researchers had not seen it used by criminals.7 Fallbacks are usual because most administrators keep a practical way to recover accounts; see Account recovery.7

Checks on each session

In the 2022 campaign the attackers reached the stolen sessions through proxies and VPNs whose addresses were uncommon for the victims, which raised alerts for activity from an infrequent country and for tokens played from an unfamiliar location. Conditions such as a compliant device or a trusted IP range, checked every time a session cookie is used, protect against that kind of replay.1 An application can store the IP address and user agent a session started with, treat a change as a sign of hijacking, and ask for a fresh sign-in when a session appears from a new IP address or device.8 A sign-out that revokes every session of the user, such as the default global scope of supabase.auth.signOut(), ends a stolen session once the theft is noticed.9

Prompt for a coding agent

Review how users sign in to this app. 1) If passkeys (WebAuthn) are not offered, add them as a sign-in method and list the library and version you used. 2) In the WebAuthn verification code, check that the expected origin is the exact production origin with no trailing slash and the expected RP ID is our domain; do not accept a list built from request headers. 3) Show me every other way an account that has a passkey can still sign in (password plus code, SMS, email link, account recovery) so I can decide which to remove. 4) Store the IP address and user agent each session started with and require a new sign-in when a session is used from a different country or user agent. 5) Add a "Sign out of all devices" action that revokes every session for the user. List each file you changed.

In SecFlash

A proxy needs a domain that people will mistake for the real one. SecFlash lists registered domains that look like the app's own as SF-EML-202 on the Email and domain page; see Look-alike domains. When a page on the app's own site starts showing another brand's sign-in form, as phishing kits planted on a broken-into site do, it reports SF-DET-607 on the Detections page.

See also

References

  1. a b c d e f g h i Microsoft Threat Intelligence (12 July 2022). "From cookie theft to BEC: Attackers use AiTM phishing sites as entry point to further financial fraud". Microsoft Security Blog.
  2. a b Gretzky, K. "evilginx2" (README, Evilginx 3.0). GitHub.
  3. back "NIST SP 800-63B-4, Digital Identity Guidelines: Authentication and Authenticator Management". NIST (2025).
  4. back "Adversary-in-the-Middle, Technique T1557". MITRE ATT&CK. Version 2.5.
  5. a b W3C Web Authentication Working Group (25 August 2026). "Web Authentication: An API for accessing Public Key Credentials Level 3". W3C Recommendation.
  6. back "@simplewebauthn/server", version 14.1.x. SimpleWebAuthn documentation.
  7. a b c Miron, Y. (12 August 2025). "Don't Phish-let Me Down: FIDO Authentication Downgrade". Proofpoint Threat Insight.
  8. back "Session Management Cheat Sheet". OWASP Cheat Sheet Series. OWASP Foundation.
  9. back "Signing out". Supabase Docs. Supabase.