Microsoft Graph PowerShell & App-Only Token Abuse Detection in Audit Logs
Attackers regularly import stolen tokens or authenticate via Microsoft Graph Command Line Tools (AppId 14d82eec-204b-4c2f-b7e8-296a70dab67e) or Azure CLI (04b07795-8ddb-461a-bbee-02f9e1bf7b46) to enumerate users, dump Entra groups, or read emails via Graph API—leaving ClientAppId 14d82eec and Client=REST;Client=Microsoft.Graph telemetry across Entra and Purview logs.
Detection Objective & Threat Scope
Modern cloud attackers don’t click slowly through Entra web portals once inside an employee account—they immediately automate directory reconnaissance, SharePoint enumeration, and mailbox extraction using Microsoft’s own first-party CLI applications.
Because Microsoft Graph Command Line Tools (`14d82eec-204b-4c2f-b7e8-296a70dab67e`) and Azure CLI (`04b07795-8ddb-461a-bbee-02f9e1bf7b46`) exist as trusted Microsoft first-party apps inside every tenant, attackers abuse them heavily in both Device Code phishing and post-compromise scripts—unless defenders explicitly monitor and restrict who can use them.
Look in two places when hunting CLI/API abuse: in Entra ID Sign-In JSON, inspect `appId` and `appDisplayName`; in Purview Unified Audit Logs (`MailItemsAccessed`, `FileDownloaded`), inspect `AuditData.AppAccessContext.ClientAppId` and `ClientInfoString` (`Client=REST;Client=Microsoft.Graph`).
Seeing a marketing manager, HR coordinator, or finance clerk suddenly authenticate to `Microsoft Graph Command Line Tools` or `Microsoft Azure PowerShell` is almost always an indicator of automated compromise or Device Code phish.
Forensic Telemetry Fields & High-Signal Indicators
| Telemetry Field / Pattern | Meaning in M365 / Entra | High-Signal Threat Indicator |
|---|---|---|
14d82eec-204b-4c2f-b7e8-296a70dab67e | Microsoft Graph Command Line Tools (PowerShell) | Major red flag on non-IT/non-security employees |
04b07795-8ddb-461a-bbee-02f9e1bf7b46 | Microsoft Azure CLI (`az login`) | Heavily abused in Device Code phishing & cloud recon |
1950a258-227b-4e31-a9cf-717495945fc2 | Microsoft Azure PowerShell | Used for Entra & Azure resource enumeration |
00b41c95-dab0-4487-9791-b9d2c32c80f2 | Office 365 Management / Exchange REST | Watch alongside unexpected REST calls |
Client=REST;Client=Microsoft.Graph | Exchange Online access via Graph API | Reveals programmatic mail access rather than Outlook |
Assignment Required = Yes | Enterprise App setting locking CLI access | Limits Graph PowerShell solely to vetted IT/SecOps |
Hunt Non-IT Graph CLI Logins & Lock Down Graph PowerShell Access
// Sentinel KQL hunt for CLI/PowerShell cloud app usage:
SigninLogs
| where AppId in ("14d82eec-204b-4c2f-b7e8-296a70dab67e","04b07795-8ddb-461a-bbee-02f9e1bf7b46","1950a258-227b-4e31-a9cf-717495945fc2")
| summarize Hits=count(), IPs=make_set(IPAddress), UAs=make_set(UserAgent) by UserPrincipalName, AppDisplayName
# PowerShell: Require explicit user assignment on Microsoft Graph Command Line Tools!
$sp = Get-MgServicePrincipal -Filter "appId eq '14d82eec-204b-4c2f-b7e8-296a70dab67e'"
Update-MgServicePrincipal -ServicePrincipalId $sp.Id -AppRoleAssignmentRequired:$true
Sample Graph CLI Detection Table
UserPrincipalName AppDisplayName Hits IPs
----------------- -------------- ---- ---
marketing.mgr@contoso.invalid Microsoft Graph Command Line Tools 12 ["185.220.101.45"]
First-Party Microsoft CLI App IDs Every SOC Should Monitor
| App Display Name | Canonical AppId GUID | Hardening Recommendation |
|---|---|---|
| Microsoft Graph Command Line Tools | 14d82eec-204b-4c2f-b7e8-296a70dab67e | Set AppRoleAssignmentRequired = True; assign vetted admins only |
| Microsoft Azure CLI | 04b07795-8ddb-461a-bbee-02f9e1bf7b46 | Restrict via Conditional Access or Assignment Required |
| Microsoft Azure PowerShell | 1950a258-227b-4e31-a9cf-717495945fc2 | Require Compliant Device + Phishing-Resistant MFA via CA |
Microsoft Graph Command Line Tools Sign-In JSON Event
{
"createdDateTime": "2026-12-03T12:10:05Z",
"userPrincipalName": "marketing.mgr@contoso-demo.invalid",
"appDisplayName": "Microsoft Graph Command Line Tools",
"appId": "14d82eec-204b-4c2f-b7e8-296a70dab67e",
"resourceDisplayName": "Microsoft Graph",
"ipAddress": "185.220.101.45",
"userAgent": "PowerShell/7.4.6",
"status": { "errorCode": 0 }
}
A marketing manager authenticating to `14d82eec-204b-4c2f-b7e8-296a70dab67e` with `PowerShell/7.4.6` from `185.220.101.45` is a clear compromise—and triggers `AV-003` (`PowerShell` UA) inside AuditVane.
Real-World Incident Walkthrough
After compromising a finance analyst via Device Code phishing, an attacker connects via `Connect-MgGraph` from `185.220.101.45` and dumps the entire Global Address List (`Get-MgUser -All`), admin role memberships, and inbox emails over Graph REST API.
Dropping Entra Sign-In JSON + Purview UAL CSV into AuditVane surfaces `appId: 14d82eec-204b-4c2f-b7e8-296a70dab67e` in the ClientApp column alongside `Client=REST;Client=Microsoft.Graph` inside `MailItemsAccessed` (`AV-007`).
Step-by-Step Triage, Containment & Verification
- Load Entra Sign-In JSON and Purview UAL CSV exports into AuditVane and search for `14d82eec`, `04b07795`, `Graph Command Line`, or `Client=Microsoft.Graph`.
- Flag every sign-in from non-IT/non-DevOps accounts or external untrusted IP addresses.
- Revoke sessions immediately via `Revoke-MgUserSignInSession` and audit `OAuth2PermissionGrant` scopes granted to `14d82eec` on behalf of the user (standard users can inadvertently consent to `User.Read.All` inside Graph CLI unless restricted!).
- In Entra Enterprise Applications, locate **Microsoft Graph Command Line Tools**, **Microsoft Azure CLI**, and **Microsoft Azure PowerShell**, and set **Assignment required? = Yes** (assigning only your vetted admin security group).
- Layer a Conditional Access policy targeting Microsoft Admin Portals / CLI apps requiring Compliant Devices + Phishing-Resistant MFA.
How to Verify Containment Completed Cleanly
- Microsoft Graph Command Line Tools (`14d82eec`) restricted via Assignment Required = Yes.
- Zero non-IT employees holding historical OAuth grants under Graph PowerShell.
- Conditional Access policy covering Azure CLI and PowerShell verified active.
Analyst Blind Spots, Licensing Quirks & False Positives
Setting "Do not allow user consent for apps" in Entra ID still may NOT stop users from authenticating to Microsoft Graph Command Line Tools with default pre-consented scopes unless **Assignment required? = Yes** is enforced on that Enterprise Application!
Don’t lock yourself out when enabling Assignment Required—explicitly assign your DevOps/IAM admin group to `14d82eec` BEFORE flipping `AppRoleAssignmentRequired` to `$true`.
Frequently Asked Questions
Why do attackers love AppId 14d82eec-204b-4c2f-b7e8-296a70dab67e?
It is Microsoft’s official pre-registered Graph PowerShell client ID—allowing attackers to query directories and mailboxes without deploying custom apps.
How can I block regular employees from using Graph PowerShell or Azure CLI?
Open the Enterprise Application in Entra ID, set "Assignment required?" to Yes, and assign only authorized IT/SecOps security groups (plus apply Conditional Access).
Does AuditVane show AppId fields from both Purview and Entra logs?
Yes! AuditVane normalizes AppId/appDisplayName into the ClientApp column and displays full AppAccessContext keys in the Event Inspector.
Can standard users read the entire employee directory via Graph CLI?
Yes—unless Entra "Restrict access to Microsoft Entra administration portal" and directory enumeration restrictions are configured, default User permissions allow reading basic profiles of other users.