detecting-oauth-token-theft
できること
このツールは、Microsoftのシステムにおけるトークンの盗難を検出し、対応するのに役立ちます。トークンを盗んだり再利用したりして、情報に不正にアクセスしようとする攻撃から守ります。
使う場面
- ✓不正アクセスが発生したと疑われるとき。
- ✓ログインログで普段と違う活動を調査するとき。
- ✓トークン盗難への防御を設定するとき。
スキルのリンク
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-oauth-token-theft/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Microsoft Entra IDで、トークンに関する異常なアクセス警告を調査して。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このツールは、Microsoft Entra IDのログインログとセキュリティ設定を分析します。盗難や不正利用を示すトークンの使用パターン、例えば「ありえない移動」によるログインや、再利用されたトークンなどを確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Detecting OAuth Token Theft
When to Use
- Investigating alerts for impossible travel or anomalous token usage in Microsoft Entra ID
- Responding to a suspected session hijacking or pass-the-cookie attack
- Configuring proactive defenses against OAuth token theft in an Azure/M365 environment
- Detecting OAuth device code phishing campaigns that bypass MFA
- Analyzing sign-in logs for token replay indicators
- Implementing Token Protection conditional access policies to bind tokens to devices
Do not use for on-premises Kerberos ticket attacks (pass-the-ticket, golden ticket); use Active Directory-specific investigation techniques for those scenarios.
Prerequisites
- Microsoft Entra ID P2 license (required for Identity Protection risk detections and conditional access)
- Global Administrator or Security Administrator role in the Entra admin center
- Microsoft Defender for Cloud Apps (MDCA) license for session anomaly detection
- Access to Entra ID Sign-in Logs and Audit Logs (requires Diagnostic Settings configured to Log Analytics or Sentinel)
- Familiarity with OAuth 2.0 authorization flows (authorization code, device code, client credentials)
- Microsoft Sentinel or equivalent SIEM ingesting Entra ID sign-in and audit logs
Workflow
Step 1: Understand the Token Theft Attack Surface
Identify which token types are at risk and how they are stolen:
Token Type | Lifetime | Theft Vector | Impact
----------------------|-------------|----------------------------------|------------------
Access Token | 60-90 min | Memory dump, proxy interception | API access for token lifetime
Refresh Token | Up to 90 days| Browser cookie theft, malware | Persistent access, new access tokens
Primary Refresh Token | Session-based| Mimikatz, AADInternals, malware | Full SSO to all M365/Azure apps
Session Cookie | Varies | XSS, browser exploit, AitM proxy | Full session hijacking
Device Code Token | 15 min auth | Phishing (device code flow abuse)| Attacker gets refresh token via social engineering
Common attack techniques:
- AitM Phishing (Adversary-in-the-Middle): Attacker proxies the legitimate login page via tools like Evilginx2, capturing session cookies and tokens after the user completes MFA
- Device Code Phishing: Attacker generates a device code, sends it to the victim via email/Teams, victim authenticates, attacker receives the token
- PRT Extraction: Attacker with local admin on a device extracts the Primary Refresh Token using Mimikatz (
sekurlsa::cloudap) or AADInternals - Browser Cookie Theft: Malware or infostealer exfiltrates browser cookies containing session tokens
Step 2: Configure Entra ID Sign-in Risk Detection
Enable Identity Protection to flag anomalous token usage:
Entra Admin Center > Protection > Identity Protection > Risk Detections
Key risk detections for token theft:
- Anomalous Token : Token has unusual characteristics (claim anomalies)
- Token Issuer Anomaly : Token issued by an unusual token issuer
- Unfamiliar Sign-in : Sign-in from a location not seen before for the user
- Impossible Travel : Sign-ins from geographically distant locations in impossible time
- Malicious IP Address : Sign-in from a known malicious IP
- Suspicious Browser : Sign-in from a suspicious or attacker-controlled browser
Configure risk-based conditional access:
Entra Admin Center > Protection > Conditional Access > New Policy
Policy Name: "Block High-Risk Sign-ins - Token Theft Protection"
Assignments:
Users: All users (exclude break-glass accounts)
Cloud Apps: All cloud apps
Conditions:
Sign-in Risk: High
Grant:
Block access
Policy Name: "Require MFA for Medium-Risk Sign-ins"
Assignments:
Users: All users
Cloud Apps: All cloud apps
Conditions:
Sign-in Risk: Medium
Grant:
Require multifactor authentication
Require password change
Step 3: Enable Token Protection (Preview)
Configure Token Protection to bind sign-in session tokens to the device:
Entra Admin Center > Protection > Conditional Access > New Policy
Policy Name: "Enforce Token Protection for Desktop Sessions"
Assignments:
Users: All users (start with a pilot group)
Cloud Apps: Office 365 Exchange Online, Office 365 SharePoint Online
Conditions:
Device Platforms: Windows
Session:
Require token protection for sign-in sessions (Preview): Enabled
Grant:
…
よくある質問
アクセストークンとリフレッシュトークンとは何ですか?
アクセストークンは、リソースにアクセスするための一時的な鍵のようなものです。リフレッシュトークンは、期限切れになった古いアクセストークンの代わりに新しいものを取得するために使われ、より長くアクセスできるようにします。
「ありえない移動」とは何ですか?
地理的に離れた場所から、短時間のうちに同じユーザーがログインしたことをシステムが検出する状態です。アカウントが侵害されている可能性を示します。
なぜKerberos攻撃には使わないのですか?
このツールはMicrosoft Entra ID(クラウド)専用です。Kerberos攻撃は社内のオンプレミスネットワークで発生するため、別の調査方法が必要です。
詳細
作者による元の説明
Detect and respond to OAuth token theft and replay in Microsoft Entra ID (Azure AD), covering access token theft, refresh token replay, Primary Refresh Token (PRT) abuse, pass-the-cookie attacks, and Token Protection conditional access policies. Use for impossible-travel or anomalous token-usage alerts, suspected session hijacking, sign-in log analysis, or configuring token-binding defenses in Azu
人気
- GitHubのスター
- 35k
- ランキング
- #7856
- ライセンス
- Apache-2.0
- 更新日
- 2026/8/31
コメント
- …
このリポジトリの他のスキル
abusing-dpapi-for-credential-access
35k特定のタスク向けに用意された指示をAIエージェントに与え、より良く、より速く作業できるようにします。
abusing-shadow-credentials-for-privesc
35kAIエージェントに、明確で構成のしっかりした文章の書き方を教えます。
achieving-cmmc-level-2-compliance
35kエージェントがCMMC Level 2への準拠に向けた環境を整えられるようにします。セキュリティ要件を実装し、必要なドキュメントを管理します。
acquiring-disk-image-with-dd-and-dcfldd
35kエージェントがハードディスクの完全なコピーを作成できるようにします。調査中に情報が失われたり改変されたりしないようにするのに役立ちます。
似ているスキル
add-model-provider
394k安全なセットアップコマンドで新しいAIモデルプロバイダーをOpenClawに接続し、APIキーを平文で残さず、ライブテストを行うようエージェントを支援します。
acp-router
394kClaude CodeやCursorなどのコーディングアシスタントに、OpenClaw経由でタスクを渡し、その作業がそのツール内で行われるようエージェントを支援します。
browser-automation
394kログイン、タブ、応答しなくなったページからの復旧を含め、Webページを段階的に操作するようエージェントに教えます。