AiTM Detector
Modeled on PingOne's AiTM predictor: a Post-Login Action checks a hostname-mismatch signal and, on mismatch, denies the login and revokes the user's existing sessions and refresh tokens via the Management API — automatically, server-side.
The “Evil Login” button below does not read a real hostname from a live browser script, and this demo does notdefeat Evilginx or any other reverse-proxy phishing toolkit. It simulates a mismatch signal via a server-side query parameter this demo's own route sets, so you can see the Action's response to that signal without needing a live phishing proxy.
An earlier design for this demo called for a client-side script on the Universal Login page that would read window.location.hostname, obfuscate it, and submit it as a hidden form field. A spike against this tenant found that approach doesn't work as intended on this tenant's Universal Login experience — the injected script never rendered in the real login widget, and the Post-Login Action never received the field even when it tried. More importantly, even a working version of that design wouldn't have been robust: Evilginx is a full inline reverse proxy that can strip injected scripts, rewrite their source, or rewrite submitted form fields on the way upstream — the same mechanism it already uses to harvest passwords. A client can't prove anything to a server through a channel an inline proxy sits inside of.
The mechanism that actually survives this attack class is origin-bound credentials — WebAuthn/passkeys. A passkey's signature is cryptographically bound to the real origin at the browser/authenticator level; a phishing proxy on a different domain cannot produce a valid assertion for it, because there is no content or data in that exchange for a proxy to rewrite its way around. This demo illustrates the automated response side of AiTM detection (deny + revoke), not a working detection mechanism — see Security Implications below for the full picture.
Both buttons force a fresh Universal Login prompt (prompt=login), so an existing session never silently skips the check. “Evil Login” appends a simulated mismatch signal that isn't on this demo's allowlist — it's a query parameter this route sets, not anything read from your actual browser.
Strengths
- Demonstrates the server-side consequence of a hostname-mismatch signal accurately: a Post-Login Action can deny a login and revoke all existing sessions/refresh tokens in a single transaction before any token is ever issued — this is the correct architectural level for automated mitigation.
- The server-side mitigation (deny + revoke) is real and testable. Even though the detection signal in this demo is simulated, what happens when the Action triggers is the actual Management API behavior — not a mock.
- Directly comparable to PingOne's documented AiTM predictor response: block + sessions revoked. The demo accurately illustrates that half.
- Correctly scoped to this demo's own Auth0 application via a client_id gate in the Action — does not affect other demos on the same shared tenant, even though Post-Login Actions are tenant-wide.
Risks & Considerations
- The detection signal in this demo is NOT a real client-side hostname probe. The original design called for a browser script reading window.location.hostname and submitting it via a hidden form field on the Universal Login page. That approach was tested against this tenant and found not to work as designed on New Universal Login (the injected script never rendered in the managed widget DOM; event.request.body was empty even for real form POSTs). This demo uses an authorize-time query param the server itself sets instead — it never reads an actual hostname from a real browser.
- Even if the original browser-script design had worked end-to-end: Evilginx (the canonical AiTM phishing toolkit) is a full inline reverse proxy that can strip injected <script> tags, rewrite JS source, or rewrite submitted POST body fields before they reach the real server — the same mechanism it uses to harvest credentials. A client-side script reading window.location.hostname is not undetectable or unspoofable once a targeted attacker notices it. The honest characterization is "adds friction against off-the-shelf phishlets that don't specifically target this probe," not "prevents AiTM."
- Revoking all sessions and refresh tokens on a single client-reported signal (whether real or simulated) is an aggressive automated response that could disrupt legitimate users whose signal is false-positive (network proxy, custom domain misconfiguration, browser extension). Real IdP risk systems contribute such signals to a risk score feeding a step-up or gentle challenge, not an instant nuke — this demo's binary block is intentionally simplified for clarity, not recommended as a production pattern.
- The deny reason includes the exact fake hostname that triggered the check ("you reported evil-phishing-proxy.example"). In production, telling an attacker exactly which field triggered which check and what value they need to fake would help them iterate around the detection. For a demo, the extra detail is a teaching asset; for a real control, stay vague.
Hardening Checklist
- The actual phishing-resistant mechanism for AiTM attacks is origin-bound credentials — WebAuthn/passkeys. A credential's public key is registered against a specific origin (e.g. auth0.yourdomain.com), and the authenticator's signing step runs in the browser's own origin-verification layer. A phishing proxy on a different domain cannot produce a valid assertion for a credential bound to the real origin, because there is no content or data it can intercept and replay through that exchange. Passkeys are immune to this attack class by construction, without any server-side detection heuristic needed. See the upcoming Passkey Origin Binding demo in this same section.
- If a real hostname-mismatch signal is added to a production IdP in the future, treat it as one input to a risk score — not a sole trigger for hard mitigation. Combine with other signals (IP/ASN anomaly, device fingerprint jump, impossible travel) before automatically revoking everything.
- The dedicated M2M application provisioned for this Action's Management API calls should use the narrowest possible scopes (delete:sessions + delete:refresh_tokens only). Do not reuse the app-wide M2M credentials from lib/mgmt.ts — that credential has broader permissions and is provisioned for the Next.js app server, not for an Action running in Auth0's own tenant-side runtime.