Sunday, October 18, 2026

Hackers Exploit OAuth 2.0 Code Flow Using AiTM Attack on Microsoft Azure AD

Security enthusiasts and professionals are turning their focus towards a new angle on phishing attacks in the identity and access management space.

During the “Offensive Entra ID (Azure AD) and Hybrid AD Security” training, a clever demonstration showcased how a modified EvilGinx phishlet could enable adversary-in-the-middle (AiTM) phishing to directly extract access and refresh tokens.

This method eliminates the need for capturing ESTS cookies and swapping them later, providing a more efficient attack vector for malicious actors.

Leveraging OAuth 2.0 Authorization Code Flow

The OAuth 2.0 authorization code flow is widely used for accessing Microsoft resources such as MS Graph, OneDrive, and other M365 applications.

Typically, this flow involves a backend acquiring resource access through user consent.

While the redirect URIs are not under an attacker’s control, an AiTM attack effectively positions itself as a middleman, controlling communications between the victim and Microsoft’s backend.

The key for attackers lies in intercepting the authorization code returned during this process.

Once obtained, this code can be exchanged at the endpoint /oauth2/token to acquire both an access token and a refresh token.

The unsuspecting victim, meanwhile, is seamlessly redirected to legitimate Microsoft services, such as portal.office.com, remaining oblivious to the breach.

Exploiting the Microsoft Teams Client ID

In the demonstrated attack, the Teams client ID, 1fec8e78-bce4-4aaf-ab1b-5451cc387264, was used as part of the authorization request to MS Graph.

This client ID is particularly versatile, granting access to 64 different resources, including Teams, OneDrive, Exchange, and Azure DevOps.

The stolen refresh token can be further exploited to pivot to other clients and resources.

For instance, it is possible to use the “roadtx” tool to access DevOps repositories or Azure services using the victim’s authentication.

OAuth 2.0
Using the stolen refreshtoken for teams to access the victims devops repositories.

A proof-of-concept (PoC) tool to facilitate such attacks has been created, based on Wesley’s earlier publication, “Building an AiTM Attack Tool in Cloudflare Workers.”

This modified worker script intercepts the authorization flow, focusing less on cookies and more on capturing the authorization code directly.

Detecting this novel attack vector requires careful monitoring of anomalies.

One indicator is tracking logins originating from Cloudflare IP ranges, as AiTM tools often utilize Cloudflare Workers.

According to the Zolder report, organizations can analyze sign-in logs for activity associated with the autonomous system number (ASN) 13335. Another telltale sign is unusual user-agent strings.

For example, logins for mobile or desktop applications that oddly exhibit browser-like user agents (such as those containing “Mozilla/”) should raise red flags.

Though this method is still in the proof-of-concept stage and lacks production-level maturity, it underscores the evolving sophistication of AiTM phishing techniques.

Organizations must remain proactive in securing their environments against such emerging threats.

Are you from SOC/DFIR Teams? – Analyse Malware Files & Links with ANY.RUN Sandox -> Try for Free

Aman Mishra
Aman Mishra
Aman Mishra is a Security and privacy Reporter covering various data breach, cyber crime, malware, & vulnerability.

Hot this week

How To Access Dark Web Anonymously and know its Secretive and Mysterious Activities

What is Deep Web The deep web, invisible web, or...

How to Build and Run a Security Operations Center (SOC Guide) – 2023

Today’s Cyber security operations center (CSOC) should have everything...

Russian Hackers Bypass EDR to Deliver a Weaponized TeamViewer Component

TeamViewer's popularity and remote access capabilities make it an...

Web Server Penetration Testing Checklist – 2026

Web server pentesting is performed under three significant categories: identity,...

ATM Penetration Testing – Advanced Testing Methods to Find The Vulnerabilities

ATM Penetration testing, Hackers have found different approaches to...

Hackers Use ConnectWise SkyKick Credentials to Access Microsoft 365, Halting Cloud Backups

Attackers abused compromised ConnectWise Cloud Backup credentials to access...

Anthropic’s Claude AI Uncovers Origins of NSA-Provided Cryptographic Keys After 25 Years

Anthropic says an internal Claude research model reconstructed how...

OpenBSD Kernel Flaw Dating Back 37 Years Enables Local Privilege Escalation to Root

A newly disclosed OpenBSD kernel exploitation chain combines a...

GhostAction Hackers Hide Credential-Stealing Malware in Fake Font Files Across 94 GitHub Repositories

GhostAction attackers have expanded their GitHub credential theft campaign...

SideCopy Hackers Target Indian Organizations With ReverseRAT Malware to Steal Data

Indian authorities have warned that SideCopy hackers are targeting...

New GhostBat Android Malware Targets 60 Banking and UPI Apps to Steal PINs

A new GhostBat RAT variant targets 60 Android financial...

New ROMULUS Malware Platform Uses Six Servers to Deliver Multiple Malicious Payloads

ROMULUS, a shared ClickFix delivery platform operating across six...

Related Articles

Recent News