[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E3FK9FPPRGDYS3JCBG1023":3,"skill-same:01M7E3FK9FPPRGDYS3JCBG1023":112},{"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":6,"ownerDescription":80,"updatedAt":81,"install":82,"resources":95},"01M7E3FK9FPPRGDYS3JCBG1023","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.","sanjeevafk\u002Fagent-skills","sanjeevafk","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F230678117?v=4","01M7C540EFY46ETG1NNWKS5X3Q","Sanjeev","01M7C540F366J5C1D587BMKH9Q",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fdetecting-oauth-token-theft\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\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","4e084e84eb42fc53e144c89c0f7f48b39c8a4b0f","collections\u002Fcybersecurity-skills\u002Fskills\u002Fdetecting-oauth-token-theft",1,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fsanjeevafk","First make it work. Then make it right. Then make it fast.","2026-11-14 13:36:16",{"source":8,"skillName":5,"commands":83,"prompt":93,"zipAvailable":94},[84,87,90],{"tool":85,"command":86},"npx","npx skills add sanjeevafk\u002Fagent-skills --skill detecting-oauth-token-theft",{"tool":88,"command":89},"bunx","bunx skills add sanjeevafk\u002Fagent-skills --skill detecting-oauth-token-theft",{"tool":91,"command":92},"pnpm","pnpm dlx skills add sanjeevafk\u002Fagent-skills --skill detecting-oauth-token-theft","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fdetecting-oauth-token-theft\u002FSKILL.md",true,[96,100,106],{"path":97,"resourceType":97,"resourceTypeDesc":98,"sizeBytes":99,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":101,"resourceType":102,"resourceTypeDesc":103,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Fapi-reference.md","REFERENCE","参考文档",1629,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fdetecting-oauth-token-theft\u002Freferences\u002Fapi-reference.md",{"path":107,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":110,"sourceHtmlUrl":111},"scripts\u002Fagent.py","SCRIPT","脚本",7214,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fdetecting-oauth-token-theft\u002Fscripts\u002Fagent.py",[113,121,129,137,145,152],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":117,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":20},"01M7EFHX67M3KKXT1BXVPA5ADT","zarr-python","Chunked N-D arrays for cloud storage (Zarr-Python 3). Compressed arrays, parallel I\u002FO, S3\u002FGCS via fsspec, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","MIT","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":117,"licenseFileUrl":125,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":20},"01M7EFFQGM51TZBGRENXY50ZYM","whiteboard-diagrams","Create accurate, simple, hand-drawn whiteboard diagrams from a user's process, system, architecture, learning workflow, comparison, or causal explanation. Use when the user asks for a scribbly whiteboard visual, educational workflow graphic, hand-drawn explainer, or diagram like the bundled reference; ask one focused clarification question when the subject or relationships are missing, then generate and visually verify the final image.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FSKILL.md",[],[],{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":133,"sourceHtmlUrl":134,"categories":135,"keywords":136,"publishedAt":20},"01M7EFF1CSQNTDMHFK4ZGY6NYK","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\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":141,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":20},"01M7EFE8106X6C28FT8PA74427","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\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FSKILL.md",[],[],{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":117,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":20},"01M7EFCSNZM9G7ZHS6F127Q71X","verification-loop","A comprehensive verification system for Claude Code sessions.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":117,"licenseFileUrl":156,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":20},"01M7EFCE7EZMKPRYDDNKBQ9EEH","vercel-deploy","Deploy applications and websites to Vercel. Use when the user requests deployment actions like \"deploy my app\", \"deploy and give me the link\", \"push this live\", or \"create a preview deployment\".","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FSKILL.md",[],[]]