[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D82XWT3WNJ689ZE55GWMHF":3,"skill-same:01M7D82XWT3WNJ689ZE55GWMHF":113},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":74,"commitSha":75,"skillDirectory":76,"forksCount":77,"repositoryHtmlUrl":78,"repositoryHomepageUrl":6,"ownerHtmlUrl":79,"ownerBlogUrl":80,"ownerDescription":81,"updatedAt":82,"install":83,"resources":96},"01M7D82XWT3WNJ689ZE55GWMHF","detecting-oauth-token-theft",null,"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 Azure\u002FM365.","SaiVatsal\u002FSkills-I-Use","SaiVatsal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F242597752?v=4","01M7D5YM1T4VXW9203M0GFAHZ1","SaiVatsalPolimera","01M7D5YM2D61ST39XVR2V7B7ZJ",3,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-oauth-token-theft\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-oauth-token-theft\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: detecting-oauth-token-theft\ndescription: 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 Azure\u002FM365.\ndomain: cybersecurity\nsubdomain: cloud-security\ntags:\n- oauth\n- token-theft\n- azure-ad\n- entra-id\n- conditional-access\n- token-replay\n- identity-security\n- PRT\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.IR-01\n- ID.AM-08\n- GV.SC-06\n- DE.CM-01\nmitre_attack:\n- T1078.004\n- T1530\n- T1537\n- T1580\nmitre_f3:\n  version: '1.1'\n  tactics:\n  - initial-access\n  - positioning\n  techniques:\n  - id: F1004\n    name: Access with Stolen Session Cookie\n    tactic: initial-access\n    source: f3\n  - id: T1539\n    name: Steal Web Session Cookie\n    tactic: positioning\n    source: attack\n  - id: T1557\n    name: Adversary-in-the-Middle\n    tactic: initial-access\n    source: attack\n  - id: T1550.001\n    name: 'Use Alternate Authentication Material: Application Access Token'\n    tactic: initial-access\n    source: attack\n  - id: F1006\n    name: Account Takeover\n    tactic: initial-access\n    source: f3\n  - id: T1185\n    name: Browser Session Hijacking\n    tactic: positioning\n    source: attack\n---\n\n# Detecting OAuth Token Theft\n\n## When to Use\n\n- Investigating alerts for impossible travel or anomalous token usage in Microsoft Entra ID\n- Responding to a suspected session hijacking or pass-the-cookie attack\n- Configuring proactive defenses against OAuth token theft in an Azure\u002FM365 environment\n- Detecting OAuth device code phishing campaigns that bypass MFA\n- Analyzing sign-in logs for token replay indicators\n- Implementing Token Protection conditional access policies to bind tokens to devices\n\n**Do not use** for on-premises Kerberos ticket attacks (pass-the-ticket, golden ticket); use Active Directory-specific investigation techniques for those scenarios.\n\n## Prerequisites\n\n- Microsoft Entra ID P2 license (required for Identity Protection risk detections and conditional access)\n- Global Administrator or Security Administrator role in the Entra admin center\n- Microsoft Defender for Cloud Apps (MDCA) license for session anomaly detection\n- Access to Entra ID Sign-in Logs and Audit Logs (requires Diagnostic Settings configured to Log Analytics or Sentinel)\n- Familiarity with OAuth 2.0 authorization flows (authorization code, device code, client credentials)\n- Microsoft Sentinel or equivalent SIEM ingesting Entra ID sign-in and audit logs\n\n## Workflow\n\n### Step 1: Understand the Token Theft Attack Surface\n\nIdentify which token types are at risk and how they are stolen:\n\n```\nToken Type            | Lifetime     | Theft Vector                    | Impact\n----------------------|-------------|----------------------------------|------------------\nAccess Token          | 60-90 min   | Memory dump, proxy interception  | API access for token lifetime\nRefresh Token         | Up to 90 days| Browser cookie theft, malware   | Persistent access, new access tokens\nPrimary Refresh Token | Session-based| Mimikatz, AADInternals, malware | Full SSO to all M365\u002FAzure apps\nSession Cookie        | Varies      | XSS, browser exploit, AitM proxy | Full session hijacking\nDevice Code Token     | 15 min auth | Phishing (device code flow abuse)| Attacker gets refresh token via social engineering\n```\n\nCommon attack techniques:\n- **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\n- **Device Code Phishing**: Attacker generates a device code, sends it to the victim via email\u002FTeams, victim authenticates, attacker receives the token\n- **PRT Extraction**: Attacker with local admin on a device extracts the Primary Refresh Token using Mimikatz (`sekurlsa::cloudap`) or AADInternals\n- **Browser Cookie Theft**: Malware or infostealer exfiltrates browser cookies containing session tokens\n\n### Step 2: Configure Entra ID Sign-in Risk Detection\n\nEnable Identity Protection to flag anomalous token usage:\n\n```\nEntra Admin Center > Protection > Identity Protection > Risk Detections\n\nKey risk detections for token theft:\n- Anomalous Token        : Token has unusual characteristics (claim anomalies)\n- Token Issuer Anomaly   : Token issued by an unusual token issuer\n- Unfamiliar Sign-in     : Sign-in from a location not seen before for the user\n- Impossible Travel      : Sign-ins from geographically distant locations in impossible time\n- Malicious IP Address   : Sign-in from a known malicious IP\n- Suspicious Browser     : Sign-in from a suspicious or attacker-controlled browser\n```\n\nConfigure risk-based conditional access:\n\n```\nEntra Admin Center > Protection > Conditional Access > New Policy\n\nPolicy Name: \"Block High-Risk Sign-ins - Token Theft Protection\"\nAssignments:\n  Users: All users (exclude break-glass accounts)\n  Cloud Apps: All cloud apps\nConditions:\n  Sign-in Risk: High\nGrant:\n  Block access\n\nPolicy Name: \"Require MFA for Medium-Risk Sign-ins\"\nAssignments:\n  Users: All users\n  Cloud Apps: All cloud apps\nConditions:\n  Sign-in Risk: Medium\nGrant:\n  Require multifactor authentication\n  Require password change\n```\n\n### Step 3: Enable Token Protection (Preview)\n\nConfigure Token Protection to bind sign-in session tokens to the device:\n\n```\nEntra Admin Center > Protection > Conditional Access > New Policy\n\nPolicy Name: \"Enforce Token Protection for Desktop Sessions\"\nAssignments:\n  Users: All users (start with a pilot group)\n  Cloud Apps: Office 365 Exchange Online, Office 365 SharePoint Online\n  Conditions:\n    Device Platforms: Windows\nSession:\n  Require token protection for sign-in sessions (Preview): Enabled\nGrant:\n  Require device to be marked as compliant\n  OR Require Hybrid Azure AD joined device\n```\n\nToken Protection ensures that access tokens are cryptographically bound to the device's Trusted Platform Module (TPM). If an attacker steals a token and replays it from a different device, the token is rejected because the proof-of-possession key does not match.\n\n### Step 4: Detect Token Replay in Sign-in Logs\n\nQuery Entra sign-in logs for indicators of token theft:\n\n```kusto\n\u002F\u002F KQL query for Microsoft Sentinel or Log Analytics\n\u002F\u002F Detect sign-ins where the token was issued in one location and used in another\nSigninLogs\n| where TimeGenerated > ago(7d)\n| where RiskDetail contains \"token\" or RiskEventTypes_V2 has \"anomalousToken\"\n| project TimeGenerated, UserPrincipalName, IPAddress, Location,\n          RiskDetail, RiskLevelDuringSignIn, AppDisplayName,\n          DeviceDetail, ClientAppUsed, TokenIssuerType\n| sort by TimeGenerated desc\n\n\u002F\u002F Detect impossible travel with token reuse\nSigninLogs\n| where TimeGenerated > ago(7d)\n| where ResultType == 0  \u002F\u002F Successful sign-ins only\n| summarize Locations=make_set(Location), IPs=make_set(IPAddress),\n            Count=count() by UserPrincipalName, bin(TimeGenerated, 1h)\n| where array_length(Locations) > 1\n| sort by TimeGenerated desc\n\n\u002F\u002F Detect device code flow abuse (often used in phishing)\nSigninLogs\n| where TimeGenerated > ago(7d)\n| where AuthenticationProtocol == \"deviceCode\"\n| project TimeGenerated, UserPrincipalName, IPAddress, Location,\n          AppDisplayName, DeviceDetail, ResultType\n| sort by TimeGenerated desc\n\n\u002F\u002F Detect token replay: same token used from multiple IPs\nAADNonInteractiveUserSignInLogs\n| where TimeGenerated > ago(7d)\n| where ResultType == 0\n| summarize IPs=make_set(IPAddress), IPCount=dcount(IPAddress)\n            by UserPrincipalName, CorrelationId\n| where IPCount > 1\n| sort by IPCount desc\n```\n\n### Step 5: Investigate and Respond to Token Theft\n\nWhen a token theft event is detected, follow this response procedure:\n\n```powershell\n# Step 5a: Revoke all refresh tokens for the compromised user\n# Microsoft Graph PowerShell\nConnect-MgGraph -Scopes \"User.ReadWrite.All\"\nRevoke-MgUserSignInSession -UserId \"user@contoso.com\"\n\n# Step 5b: Force password reset\nUpdate-MgUser -UserId \"user@contoso.com\" -PasswordProfile @{\n    ForceChangePasswordNextSignIn = $true\n}\n\n# Step 5c: Review and revoke OAuth app consent grants\n# Check for malicious app consent (common post-compromise persistence)\nGet-MgUserOauth2PermissionGrant -UserId \"user@contoso.com\" |\n    Select-Object ClientId, ConsentType, Scope\n\n# Remove suspicious OAuth grants\nRemove-MgOauth2PermissionGrant -OAuth2PermissionGrantId \"\u003Cgrant-id>\"\n\n# Step 5d: Review enterprise app registrations for rogue apps\nGet-MgServicePrincipal -Filter \"displayName eq 'Suspicious App'\" |\n    Select-Object AppId, DisplayName, SignInAudience\n\n# Step 5e: Check for mail forwarding rules (common post-compromise action)\nGet-MgUserMailFolderRule -UserId \"user@contoso.com\" -MailFolderId \"Inbox\" |\n    Where-Object { $_.Actions.ForwardTo -ne $null -or $_.Actions.RedirectTo -ne $null }\n```\n\n### Step 6: Implement Continuous Access Evaluation (CAE)\n\nEnable CAE to revoke tokens in near-real-time when conditions change:\n\n```\nEntra Admin Center > Protection > Conditional Access > Continuous Access Evaluation\n\nSettings:\n  Strictly enforce location policies: Enabled\n\nCAE ensures that when you revoke a user's session or change their\nrisk level, the enforcement happens within minutes rather than waiting\nfor the access token to naturally expire (60-90 minutes).\n\nCritical events that trigger immediate token revocation with CAE:\n- User account disabled or deleted\n- Password changed or reset\n- MFA enabled for the user\n- Admin explicitly revokes refresh tokens\n- Azure AD Identity Protection detects elevated user risk\n- Network location change violates conditional access policy\n```\n\n### Step 7: Configure Defender for Cloud Apps Session Policies\n\nSet up real-time session monitoring to detect and block suspicious token usage:\n\n```\nMicrosoft Defender for Cloud Apps > Policies > Session Policies\n\nPolicy: \"Block download from unmanaged device with stolen token\"\n  Session Control Type: Monitor and block activities\n  Activity Source: App = Office 365, SharePoint Online\n  Activity Filter: Device tag does not equal \"Compliant\"\n  Activity Type: Download\n  Action: Block\n\nPolicy: \"Alert on mass file download (exfiltration via stolen token)\"\n  Session Control Type: Monitor only\n  Activity Source: App = Office 365\n  Activity Filter: Repeated activity > 10 downloads in 5 minutes\n  Action: Alert administrators\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Primary Refresh Token (PRT)** | A long-lived token issued to a registered device that provides SSO to all Azure AD-integrated applications, cryptographically bound to the device's TPM |\n| **Token Protection** | Entra ID conditional access feature that binds sign-in session tokens to the device, preventing replay from other devices |\n| **Continuous Access Evaluation (CAE)** | Protocol that enables near-real-time enforcement of security policies by allowing resource providers to subscribe to Entra ID critical events |\n| **AitM (Adversary-in-the-Middle)** | Phishing technique where an attacker proxies the legitimate authentication flow to capture session cookies after the victim completes MFA |\n| **Device Code Flow** | OAuth 2.0 authorization grant for input-constrained devices; abused by attackers who send device codes to victims via phishing |\n| **Proof of Possession (PoP)** | Cryptographic mechanism where a token includes a claim tied to a device key, ensuring the token can only be used by the device that obtained it |\n| **Refresh Token** | Long-lived OAuth token (up to 90 days) used to obtain new access tokens without re-authentication; primary target for persistent access |\n\n## Verification\n\n- [ ] Identity Protection risk detections are enabled and generating alerts for anomalous token activity\n- [ ] Conditional access policies block high-risk sign-ins and require MFA for medium-risk\n- [ ] Token Protection policy is applied to pilot group and confirmed working (test from unregistered device fails)\n- [ ] KQL queries in Sentinel return results when tested against synthetic token anomaly events\n- [ ] Continuous Access Evaluation is enabled and verified (revoke session, confirm access blocked within minutes)\n- [ ] Defender for Cloud Apps session policies are active and monitoring download activity\n- [ ] Device code flow is restricted via conditional access (block or require compliant device)\n- [ ] Incident response runbook includes token revocation, password reset, and OAuth consent review steps\n- [ ] Mail forwarding rules and OAuth app grants are audited for compromised accounts\n","# Detecting OAuth Token Theft\n\n## When to Use\n\n- Investigating alerts for impossible travel or anomalous token usage in Microsoft Entra ID\n- Responding to a suspected session hijacking or pass-the-cookie attack\n- Configuring proactive defenses against OAuth token theft in an Azure\u002FM365 environment\n- Detecting OAuth device code phishing campaigns that bypass MFA\n- Analyzing sign-in logs for token replay indicators\n- Implementing Token Protection conditional access policies to bind tokens to devices\n\n**Do not use** for on-premises Kerberos ticket attacks (pass-the-ticket, golden ticket); use Active Directory-specific investigation techniques for those scenarios.\n\n## Prerequisites\n\n- Microsoft Entra ID P2 license (required for Identity Protection risk detections and conditional access)\n- Global Administrator or Security Administrator role in the Entra admin center\n- Microsoft Defender for Cloud Apps (MDCA) license for session anomaly detection\n- Access to Entra ID Sign-in Logs and Audit Logs (requires Diagnostic Settings configured to Log Analytics or Sentinel)\n- Familiarity with OAuth 2.0 authorization flows (authorization code, device code, client credentials)\n- Microsoft Sentinel or equivalent SIEM ingesting Entra ID sign-in and audit logs\n\n## Workflow\n\n### Step 1: Understand the Token Theft Attack Surface\n\nIdentify which token types are at risk and how they are stolen:\n\n```\nToken Type            | Lifetime     | Theft Vector                    | Impact\n----------------------|-------------|----------------------------------|------------------\nAccess Token          | 60-90 min   | Memory dump, proxy interception  | API access for token lifetime\nRefresh Token         | Up to 90 days| Browser cookie theft, malware   | Persistent access, new access tokens\nPrimary Refresh Token | Session-based| Mimikatz, AADInternals, malware | Full SSO to all M365\u002FAzure apps\nSession Cookie        | Varies      | XSS, browser exploit, AitM proxy | Full session hijacking\nDevice Code Token     | 15 min auth | Phishing (device code flow abuse)| Attacker gets refresh token via social engineering\n```\n\nCommon attack techniques:\n- **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\n- **Device Code Phishing**: Attacker generates a device code, sends it to the victim via email\u002FTeams, victim authenticates, attacker receives the token\n- **PRT Extraction**: Attacker with local admin on a device extracts the Primary Refresh Token using Mimikatz (`sekurlsa::cloudap`) or AADInternals\n- **Browser Cookie Theft**: Malware or infostealer exfiltrates browser cookies containing session tokens\n\n### Step 2: Configure Entra ID Sign-in Risk Detection\n\nEnable Identity Protection to flag anomalous token usage:\n\n```\nEntra Admin Center > Protection > Identity Protection > Risk Detections\n\nKey risk detections for token theft:\n- Anomalous Token        : Token has unusual characteristics (claim anomalies)\n- Token Issuer Anomaly   : Token issued by an unusual token issuer\n- Unfamiliar Sign-in     : Sign-in from a location not seen before for the user\n- Impossible Travel      : Sign-ins from geographically distant locations in impossible time\n- Malicious IP Address   : Sign-in from a known malicious IP\n- Suspicious Browser     : Sign-in from a suspicious or attacker-controlled browser\n```\n\nConfigure risk-based conditional access:\n\n```\nEntra Admin Center > Protection > Conditional Access > New Policy\n\nPolicy Name: \"Block High-Risk Sign-ins - Token Theft Protection\"\nAssignments:\n  Users: All users (exclude break-glass accounts)\n  Cloud Apps: All cloud apps\nConditions:\n  Sign-in Risk: High\nGrant:\n  Block access\n\nPolicy Name: \"Require MFA for Medium-Risk Sign-ins\"\nAssignments:\n  Users: All users\n  Cloud Apps: All cloud apps\nConditions:\n  Sign-in Risk: Medium\nGrant:\n  Require multifactor authentication\n  Require password change\n```\n\n### Step 3: Enable Token Protection (Preview)\n\nConfigure Token Protection to bind sign-in session tokens to the device:\n\n```\nEntra Admin Center > Protection > Conditional Access > New Policy\n\nPolicy Name: \"Enforce Token Protection for Desktop Sessions\"\nAssignments:\n  Users: All users (start with a pilot group)\n  Cloud Apps: Office 365 Exchange Online, Office 365 SharePoint Online\n  Conditions:\n    Device Platforms: Windows\nSession:\n  Require token protection for sign-in sessions (Preview): Enabled\nGrant:\n  Require device to be marked as compliant\n  OR Require Hybrid Azure AD joined device\n```\n\nToken Protection ensures that access tokens are cryptographically bound to the device's Trusted Platform Module (TPM). If an attacker steals a token and replays it from a different device, the token is rejected because the proof-of-possession key does not match.\n\n### Step 4: Detect Token Replay in Sign-in Logs\n\nQuery Entra sign-in logs for indicators of token theft:\n\n```kusto\n\u002F\u002F KQL query for Microsoft Sentinel or Log Analytics\n\u002F\u002F Detect sign-ins where the token was issued in one location and used in another\nSigninLogs\n| where TimeGenerated > ago(7d)\n| where RiskDetail contains \"token\" or RiskEventTypes_V2 has \"anomalousToken\"\n| project TimeGenerated, UserPrincipalName, IPAddress, Location,\n          RiskDetail, RiskLevelDuringSignIn, AppDisplayName,\n          DeviceDetail, ClientAppUsed, TokenIssuerType\n| sort by TimeGenerated desc\n\n\u002F\u002F Detect impossible travel with token reuse\nSigninLogs\n| where TimeGenerated > ago(7d)\n| where ResultType == 0  \u002F\u002F Successful sign-ins only\n| summarize Locations=make_set(Location), IPs=make_set(IPAddress),\n            Count=count() by UserPrincipalName, bin(TimeGenerated, 1h)\n| where array_length(Locations) > 1\n| sort by TimeGenerated desc\n\n\u002F\u002F Detect device code flow abuse (often used in phishing)\nSigninLogs\n| where TimeGenerated > ago(7d)\n| where AuthenticationProtocol == \"deviceCode\"\n| project TimeGenerated, UserPrincipalName, IPAddress, Location,\n          AppDisplayName, DeviceDetail, ResultType\n| sort by TimeGenerated desc\n\n\u002F\u002F Detect token replay: same token used from multiple IPs\nAADNonInteractiveUserSignInLogs\n| where TimeGenerated > ago(7d)\n| where ResultType == 0\n| summarize IPs=make_set(IPAddress), IPCount=dcount(IPAddress)\n            by UserPrincipalName, CorrelationId\n| where IPCount > 1\n| sort by IPCount desc\n```\n\n### Step 5: Investigate and Respond to Token Theft\n\nWhen a token theft event is detected, follow this response procedure:\n\n```powershell\n# Step 5a: Revoke all refresh tokens for the compromised user\n# Microsoft Graph PowerShell\nConnect-MgGraph -Scopes \"User.ReadWrite.All\"\nRevoke-MgUserSignInSession -UserId \"user@contoso.com\"\n\n# Step 5b: Force password reset\nUpdate-MgUser -UserId \"user@contoso.com\" -PasswordProfile @{\n    ForceChangePasswordNextSignIn = $true\n}\n\n# Step 5c: Review and revoke OAuth app consent grants\n# Check for malicious app consent (common post-compromise persistence)\nGet-MgUserOauth2PermissionGrant -UserId \"user@contoso.com\" |\n    Select-Object ClientId, ConsentType, Scope\n\n# Remove suspicious OAuth grants\nRemove-MgOauth2PermissionGrant -OAuth2PermissionGrantId \"\u003Cgrant-id>\"\n\n# Step 5d: Review enterprise app registrations for rogue apps\nGet-MgServicePrincipal -Filter \"displayName eq 'Suspicious App'\" |\n    Select-Object AppId, DisplayName, SignInAudience\n\n# Step 5e: Check for mail forwarding rules (common post-compromise action)\nGet-MgUserMailFolderRule -UserId \"user@contoso.com\" -MailFolderId \"Inbox\" |\n    Where-Object { $_.Actions.ForwardTo -ne $null -or $_.Actions.RedirectTo -ne $null }\n```\n\n### Step 6: Implement Continuous Access Evaluation (CAE)\n\nEnable CAE to revoke tokens in near-real-time when conditions change:\n\n```\nEntra Admin Center > Protection > Conditional Access > Continuous Access Evaluation\n\nSettings:\n  Strictly enforce location policies: Enabled\n\nCAE ensures that when you revoke a user's session or change their\nrisk level, the enforcement happens within minutes rather than waiting\nfor the access token to naturally expire (60-90 minutes).\n\nCritical events that trigger immediate token revocation with CAE:\n- User account disabled or deleted\n- Password changed or reset\n- MFA enabled for the user\n- Admin explicitly revokes refresh tokens\n- Azure AD Identity Protection detects elevated user risk\n- Network location change violates conditional access policy\n```\n\n### Step 7: Configure Defender for Cloud Apps Session Policies\n\nSet up real-time session monitoring to detect and block suspicious token usage:\n\n```\nMicrosoft Defender for Cloud Apps > Policies > Session Policies\n\nPolicy: \"Block download from unmanaged device with stolen token\"\n  Session Control Type: Monitor and block activities\n  Activity Source: App = Office 365, SharePoint Online\n  Activity Filter: Device tag does not equal \"Compliant\"\n  Activity Type: Download\n  Action: Block\n\nPolicy: \"Alert on mass file download (exfiltration via stolen token)\"\n  Session Control Type: Monitor only\n  Activity Source: App = Office 365\n  Activity Filter: Repeated activity > 10 downloads in 5 minutes\n  Action: Alert administrators\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Primary Refresh Token (PRT)** | A long-lived token issued to a registered device that provides SSO to all Azure AD-integrated applications, cryptographically bound to the device's TPM |\n| **Token Protection** | Entra ID conditional access feature that binds sign-in session tokens to the device, preventing replay from other devices |\n| **Continuous Access Evaluation (CAE)** | Protocol that enables near-real-time enforcement of security policies by allowing resource providers to subscribe to Entra ID critical events |\n| **AitM (Adversary-in-the-Middle)** | Phishing technique where an attacker proxies the legitimate authentication flow to capture session cookies after the victim completes MFA |\n| **Device Code Flow** | OAuth 2.0 authorization grant for input-constrained devices; abused by attackers who send device codes to victims via phishing |\n| **Proof of Possession (PoP)** | Cryptographic mechanism where a token includes a claim tied to a device key, ensuring the token can only be used by the device that obtained it |\n| **Refresh Token** | Long-lived OAuth token (up to 90 days) used to obtain new access tokens without re-authentication; primary target for persistent access |\n\n## Verification\n\n- [ ] Identity Protection risk detections are enabled and generating alerts for anomalous token activity\n- [ ] Conditional access policies block high-risk sign-ins and require MFA for medium-risk\n- [ ] Token Protection policy is applied to pilot group and confirmed working (test from unregistered device fails)\n- [ ] KQL queries in Sentinel return results when tested against synthetic token anomaly events\n- [ ] Continuous Access Evaluation is enabled and verified (revoke session, confirm access blocked within minutes)\n- [ ] Defender for Cloud Apps session policies are active and monitoring download activity\n- [ ] Device code flow is restricted via conditional access (block or require compliant device)\n- [ ] Incident response runbook includes token revocation, password reset, and OAuth consent review steps\n- [ ] Mail forwarding rules and OAuth app grants are audited for compromised accounts\n",{"name":5,"tags":25,"author":34,"domain":35,"license":15,"version":36,"mitre_f3":37,"nist_csf":63,"subdomain":68,"description":7,"mitre_attack":69},[26,27,28,29,30,31,32,33],"oauth","token-theft","azure-ad","entra-id","conditional-access","token-replay","identity-security","PRT","mahipal","cybersecurity","1.0.0",{"tactics":38,"version":41,"techniques":42},[39,40],"initial-access","positioning","1.1",[43,47,51,54,57,60],{"id":44,"name":45,"source":46,"tactic":39},"F1004","Access with Stolen Session Cookie","f3",{"id":48,"name":49,"source":50,"tactic":40},"T1539","Steal Web Session Cookie","attack",{"id":52,"name":53,"source":50,"tactic":39},"T1557","Adversary-in-the-Middle",{"id":55,"name":56,"source":50,"tactic":39},"T1550.001","Use Alternate Authentication Material: Application Access Token",{"id":58,"name":59,"source":46,"tactic":39},"F1006","Account Takeover",{"id":61,"name":62,"source":50,"tactic":40},"T1185","Browser Session Hijacking",[64,65,66,67],"PR.IR-01","ID.AM-08","GV.SC-06","DE.CM-01","cloud-security",[70,71,72,73],"T1078.004","T1530","T1537","T1580","main","8a3b3de73262a4c4db64523949360f3c599c2fb1","Anthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-oauth-token-theft",0,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use","https:\u002F\u002Fgithub.com\u002FSaiVatsal","https:\u002F\u002Fsaivatsal.github.io\u002FPortfolio\u002F","The Longer It Takes The Stronger It Becomes ","2026-09-21 22:45:58",{"source":8,"skillName":5,"commands":84,"prompt":94,"zipAvailable":95},[85,88,91],{"tool":86,"command":87},"npx","npx skills add SaiVatsal\u002FSkills-I-Use --skill detecting-oauth-token-theft",{"tool":89,"command":90},"bunx","bunx skills add SaiVatsal\u002FSkills-I-Use --skill detecting-oauth-token-theft",{"tool":92,"command":93},"pnpm","pnpm dlx skills add SaiVatsal\u002FSkills-I-Use --skill detecting-oauth-token-theft","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-oauth-token-theft\u002FSKILL.md",true,[97,101,107],{"path":98,"resourceType":98,"resourceTypeDesc":99,"sizeBytes":100,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":102,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":105,"sourceHtmlUrl":106},"references\u002Fapi-reference.md","REFERENCE","参考文档",1629,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-oauth-token-theft\u002Freferences\u002Fapi-reference.md",{"path":108,"resourceType":109,"resourceTypeDesc":110,"sizeBytes":111,"sourceHtmlUrl":112},"scripts\u002Fagent.py","SCRIPT","脚本",7214,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-oauth-token-theft\u002Fscripts\u002Fagent.py",[114,122,130,139,146,153],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":118,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":20},"01M7DJZP6E6KMBQV4CZSDPZEZ8","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":126,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":20},"01M7DJZFTS5TS06K2TV3MDTE67","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fweb-artifacts-builder\u002FSKILL.md",[],[],{"skillNo":131,"name":132,"nameZh":6,"description":133,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":134,"licenseFileUrl":135,"sourceHtmlUrl":136,"categories":137,"keywords":138,"publishedAt":20},"01M7DJRK4SRQ908F2TJM6EZ7EV","ui-styling","Create beautiful, accessible user interfaces with shadcn\u002Fui components (built on Radix UI + Tailwind), Tailwind CSS utility-first styling, and canvas-based visual designs. Use when building user interfaces, implementing design systems, creating responsive layouts, adding accessible components (dialogs, dropdowns, forms, tables), customizing themes and colors, implementing dark mode, generating visual designs and posters, or establishing consistent styling patterns across applications.","MIT","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fui-styling\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fui-styling\u002FSKILL.md",[],[],{"skillNo":140,"name":141,"nameZh":6,"description":142,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":134,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":145,"publishedAt":20},"01M7DJR902059VEQP23PVM2WA0","design","Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social\u002Fads\u002Fweb\u002Fprint), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fdesign\u002FSKILL.md",[],[],{"skillNo":147,"name":148,"nameZh":6,"description":149,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":134,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":20},"01M7DJR56QF5N6XYTCPCFHFMNP","design-system","Token architecture, component specifications, and slide generation. Three-layer tokens (primitive→semantic→component), CSS variables, spacing\u002Ftypography scales, component specs, strategic slide creation. Use for design tokens, systematic design, brand-compliant presentations.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fdesign-system\u002FSKILL.md",[],[],{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":134,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":20},"01M7DJQXB6M0SFF7NX8J5N01AH","banner-design","Design banners for social media, ads, website heroes, creative assets, and print. Multiple art direction options with AI-generated visuals. Actions: design, create, generate banner. Platforms: Facebook, Twitter\u002FX, LinkedIn, YouTube, Instagram, Google Display, website hero, print. Styles: minimalist, gradient, bold typography, photo-based, illustrated, geometric, retro, glassmorphism, 3D, neon, duotone, editorial, collage. Uses ui-ux-pro-max, frontend-design, ai-artist, ai-multimodal skills.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fbanner-design\u002FSKILL.md",[],[]]