oauth-sso-attack

$npx mdskill add wgpsec/AboutSecurity/oauth-sso-attack

Exploit OAuth SSO flaws to hijack tokens and escalate scopes.

  • Steal credentials via redirect_uri hijacking and missing state CSRF.
  • Depends on OAuth 2.0 endpoints and third-party login buttons.
  • Analyzes request parameters to identify specific attack vectors.
  • Executes automated payloads to extract tokens and elevate permissions.

SKILL.md

.github/skills/oauth-sso-attackView on GitHub ↗
---
name: oauth-sso-attack
description: "OAuth 2.0 / SSO / OpenID Connect 认证流程攻击。当目标有「使用 Google/GitHub/微信 登录」按钮、redirect_uri 参数、authorization_code 流程、或 /.well-known/openid-configuration 端点时使用。覆盖 redirect_uri 劫持、state 缺失 CSRF、token 泄露、scope 提升"
metadata:
  tags: "oauth,sso,openid,oidc,redirect_uri,authorization,token,login,认证,第三方登录,cas,saml"
  category: "exploit"
---

# OAuth/SSO 攻击方法论

OAuth 2.0 是现代 Web 应用最常见的第三方认证协议。攻击面集中在认证流程的各个跳转环节——redirect_uri 校验、state 参数、token 传递。

## ⛔ 深入参考(必读)

- redirect_uri 完整 payload、Token 泄露途径、账户接管流程 → [references/oauth-attack-vectors.md](references/oauth-attack-vectors.md)

## Phase 1: 识别 OAuth 流程

点击「第三方登录」,观察重定向 URL 中的 `client_id`, `redirect_uri`, `response_type`, `scope`, `state`。

检查端点:`/.well-known/openid-configuration`, `/oauth/authorize`, `/api/auth/providers`

## Phase 2: redirect_uri 劫持(最常见)

目标:让 code/token 发到攻击者 URL。快速测试:
```
redirect_uri=https://target.com/callback/../evil
redirect_uri=https://evil.target.com/callback
redirect_uri=https://target.com/callback?next=https://evil.com
redirect_uri=https://evil.com/steal
```
→ 完整 payload 列表 → [references/oauth-attack-vectors.md](references/oauth-attack-vectors.md)

## Phase 3: state 缺失 → CSRF 攻击

无 `state` 参数时:攻击者获取 code → 构造 callback 链接 → 诱导受害者点击 → 账户绑定攻击者第三方账户

## Phase 4: Token 泄露

- **Referer 泄露**:回调页含外部资源 → token 通过 Referer 头外泄
- **Implicit Flow**:`response_type=token` → access_token 在 URL fragment
- **日志**:code 在 URL query,可能被记录

## Phase 5: 其他攻击面

- Scope 提升:`scope=openid profile email admin`
- client_secret 泄露:检查 JS 源码/GitHub/配置文件
- 账户接管:邮箱匹配合并 → [references/oauth-attack-vectors.md](references/oauth-attack-vectors.md)

## Phase 6: CTF 与账户接管

### 6.1 CTF 中的 OAuth
- 重点考察 redirect_uri 绕过,Flag 在管理员 token 或高权限 scope API 中

### 6.2 账户接管 — 邮箱预关联攻击
1. 攻击者注册 `attacker@target.com`(后缀匹配利用)
2. 在第三方平台修改邮箱为受害者邮箱
3. 受害者 OAuth 登录时自动关联到已有账户(邮箱匹配)
4. 关键:检查目标是否验证邮箱(绕过邮箱验证)

More from wgpsec/AboutSecurity

SkillDescription
401-403-bypass401/403 访问拒绝绕过方法论。当遇到管理后台、API 端点返回 401/403 Forbidden 时使用。覆盖路径操纵、HTTP 方法篡改、Header 注入、协议降级、组合攻击
ad-acl-abuseActive Directory ACL 滥用攻击方法论。当 BloodHound 发现 GenericAll/WriteDACL/WriteOwner/GenericWrite/ForceChangePassword 等危险 ACE 时使用。覆盖 ACE 枚举、权限滥用链、Shadow Credentials、RBCD 攻击
ad-delegation-attackKerberos 委派攻击(非约束/约束/RBCD)。当 BloodHound 发现委派配置、或已获取有 SPN 的服务账号/机器账号控制权时使用。通过 S4U 协议滥用可实现跨服务模拟任意用户,常用于域内权限提升和横向移动。
ad-domain-attackActive Directory 域环境攻击全链路。当目标主机在域环境中(systeminfo 显示 Domain 非 WORKGROUP)、发现 88/389/636 端口、或获取到域用户凭据时使用。覆盖域信息收集、用户枚举、Kerberoasting、AS-REP Roasting、委派攻击、ACL 滥用、DCSync、Golden/Silver Ticket
ad-persistenceAD 域环境持久化技术。当已获取域管/本地管理员权限、需要建立持久访问以确保重启或密码更改后仍能回到目标环境时使用。覆盖主机级持久化(计划任务/注册表Run/COM劫持/WMI事件订阅/Windows服务/启动文件夹)、域级持久化(Golden Ticket/Silver Ticket/Skeleton Key/DSRM/AdminSDHolder)、DCShadow/GoldenGMSA高级技术、清理命令与检测规避
ad-trust-attack域信任关系攻击。当目标存在多域/多林环境时使用。包含父子域提权(Golden Ticket + ExtraSid)、跨林攻击(SID History/MSSQL Trust Links)、单向信任利用。已获取子域 Domain Admin 或发现信任关系时优先加载。
adcs-certipy-attackActive Directory Certificate Services (ADCS) 证书攻击。当发现域内有 CA 服务器、ADCS Web Enrollment、证书模板配置错误时使用。覆盖 ESC1-ESC11 所有证书滥用路径、Certipy 工具链、证书伪造、NTLM 中继到 ADCS。发现 ADCS/CA/证书/certsrv 相关内容时一定要使用此技能
adinfo-enum使用 Adinfo 进行 Active Directory 信息收集。当获得域用户凭据后需要快速收集域环境信息时使用。Adinfo 是一个快速 AD 信息收集工具,一条命令输出域控列表、域管用户、信任关系、GPO、SPN、委派配置等关键信息——比手动 LDAP 查询快得多。发现域环境后第一步信息收集使用此技能
agent-security|
ai-data-security|