The Art of Breaking OAuth: Real-World Exploit and Misuses
OAuth 2.0作为现代数字身份验证标准,广泛应用于登录流程中。然而,其配置错误和漏洞使其成为攻击目标。常见攻击包括重定向URI操控、流氓应用欺骗用户授权、授权码泄露及会话固定等,可能导致账户接管或绕过多重认证。文章分析了这些攻击手法及其影响,并提供了防御建议如严格验证重定向URI、加强应用治理和提升用户意识等。
2025-10-17 09:44:58
Author: infosecwriteups.com(查看原文)
阅读量:31
收藏
Overview
OAuth 2.0 is the invisible backbone of modern digital life. From “Login with Google” bottoms on e-commerce platforms to enterprise-wide Microsoft Entra ID integrations, OAuth has become the de facto standard for delegated authentication and authorization. But while OAuth was designed to simplify identity and access management, its widespread adoption has made it a prime hunting ground for attackers.
Over a decade since its standardization, OAuth vulnerabilities and misconfigurations are still rampant. In the wild, attackers regularly exploit subtle flaws in OAuth flows — sometimes to bypass multi-factor authentication (MFA), sometimes to steal refresh tokens for persistent access, and sometimes to trick users into granting them access outright.
We unpacks the real-world exploitation of OAuth, the most common attack patterns observed, and the mitigations necessary to stay secure in an OAuth-driven ecosystem.
Redirect URI Manipulation and Open Redirects
Method:
As its core, OAuth relies on redirecting a user from the identity provider back to the application with an authorization code or token. If the redirect_uri is not validated strictly, attackers can hijack this flow.
Press enter or click to view image in full size
Real-world case:
CVE-2020–26878 (Azure Active Directory OAuth redirect URI law) — allowed attackers to manipulate redirect URIs for token theft.
Multiple financial platforms have been found vulnerable to OAuth chains with open redirects, leading to account takeover.
Impact:
Full account takeover.
In some configurations, 2FA bypass.
Rogue Applications and Consent Phishing
Method:
Instead of stealing credentials, attackers create malicious OAuth apps that look legitimate — often imitating Teams, Outlook, or internal IT tools.
Press enter or click to view image in full size
Real Breaches:
In 2020, Microsoft disclosed that state-sponsored ctors abused rogue OAuth apps to maintain persistence across enterprise tenants.
In 2022, the Storm-0558 attack leveraged OAuth token theft to access Microsoft Exchange Online mailboxes.
Impact:
Passwordless access to sensitive resources.
Long-term persistence without triggering
Authorization Code Leakage
Method:
OAuth’s authorization codes are designed to be short-lived intermediaries. But if they leak — via malicious redirect URIs, compromised logs, or open redirect vulnerabilities — attackers can exchange them for valid access token.
Press enter or click to view image in full size
Notable CVEs:
CVE-2021–26708 (OAuth implementation flaw in social login platforms) allowed leakage of codes into logs.
CVE-2019–3778 (Cloud Foundry UAA) exposed OAuth authorized codes to attackers via improper validation.
Impact:
Account takeover.
Persistence even with stateor nonce protections.
Session Fixations and Token Misuse
Method:
Even when the OAuth flow is correct, session handling can break security guarantees. If applications trust toekens blindly or fail to validate sessions properly, attackers can hijack valid sessions or reuse codes.
Press enter or click to view image in full size
Case Study:
CVE-2022–23521 (GitHub OAuth app issue) — attackers could reuse token in improper session handling scenarios.
Some fintect apps with weak SSO integrations were found to attackers persistent access even after MFA.
Device Code Flow Abuse: Phishing attacks tricking users into entering device codes that authorize attacker-controlled apps.
Multi-tenant Exploitation: One malicious app can be scaled across many organizations.
Press enter or click to view image in full size
Defensive Strategies and Mitigations
Strict Redirect URI Validation
No wildcards.
Require byte-for-byte matches.
OAuth App Governance
Audit and revoke unused apps.
Require clear consent prompts.
Session & Token Hygiene
Single-use codes.
Rotate refresh tokens.
Re-authenticate for sensitive actions.
User & Admin Awareness
Phishing drills with rogue consent flows.
Educate users on third-party app risks.
API and Token Monitoring
Detect unusual scopes or abnormal API calls.
Altert on long-lived refresh token persistence.
Real-World CVEs, Zero-Days, and Breaches from OAuth
Despite OAuth being a well-documented standard, history shows a recurring theme: subtle misconfigurations, weak validations, and creative attacker abuse. Here’s a non-exhaustive list of OAuth-related incidents that made headlines:
CVEs and Zero-Days
CVE-2019–3778 — Cloud Foundry UAA OAuth authorization codes could be improperly validated, exposing tokens to attackers.
CVE-2020–26878 — Microsoft Azure Active Directory A flaw in redirect URI handling allowed attackers to manipulate OAuth flows and steal tokens.
CVE-2021–26708 — Misconfigured OAuth in social logins Allowed code leakage through client-side logs, enabling attackers to redeem stolen codes.
CVE-2022–23521 — GitHub OAuth Token Reuse Weak session handling in GitHub OAuth applications enabled token replay and persistent unauthorized access.
CVE-2023–36049 — Microsoft Entra ID OAuth Misuse Token validation weakness enabled attackers to bypass certain authorization checks.
Major Breaches & Exploits
Storm-0558 (2022–2023) A China-linked group compromised Microsoft Exchange Online mailboxes by forging OAuth tokens using a stolen signing key.
Evilginx AiTM Campaigns (2022+) OAuth tokens stolen in the wild using adversary-in-the-middle phishing proxies, bypassing MFA protections at scale.
Consent Phishing in Office 365 Tenants (2020) Attackers registered rogue Azure AD apps mimicking Microsoft Teams and Outlook, tricking users into granting OAuth consent and exfiltrating data.
Facebook OAuth Abuse (2018) Attackers chained redirect URI misconfigurations with “Login with Facebook” integrations to take over accounts on third-party sites.
Google OAuth Zero-Day Exploit (2017) The infamous “Google Docs worm” spread via malicious OAuth consent requests disguised as document-sharing links.
Labs: Hands-On with OAuth Exploitation
Learning OAuth security means breaking OAuth safely. Here are paths to practice:
Manual Setup
Build a demo app with improper redirect_uri validation.
Configure an attacker-controlled redirect endpoint to capture tokens.
Extend it by simulating a fake OAuth consent screen to practice consent phishing.
Hack The Box (HTB)
Look for boxes like “Schooled” or “Academy” where OAuth-like flows are part of the exploitation path.
Pro Lab environments often replicate OAuth/OpenID misconfigurations in enterprise-like setups.
TryHackMe (THM)
Rooms such as “OAuth Playground”, “SSO Attack”, and “Advent of Cyber (OAuth challenges)” provide guided exercises.
Practice scenarios around token leakage, session misuse, and MFA bypass via OAuth flows.
PortSwigger Web Security Academy
Free OAuth labs including:
“OAuth authentication vulnerabilities”
“Stealing OAuth access tokens via open redirect”
“Exploiting OAuth implicit flow”
“Abusing OAuth for account takeover”
Closing Thoughts
OAuth is everywhere — yet still fragile. History shows the same themes: weak validation, misconfigured redirects, rogue apps, and attackers willing to bend flows in unexpected ways.
OAuth security is less about the spec and more about the implementation and in that gap — attackers thrive.