Query Details
// Critical Identities Privilege Escalation on Entra Service Principal // https://www.linkedin.com/posts/0x534c_defenderxdr-customdetection-exposuremanagement-activity-7182618135659692032-HsE5/ //Custom DefenderXDR privilege escalation detection rule for critical identities marked by exposure management for adding Entra service principal credentials. It is vital for SecOps to monitor organization's critical identities for any potential privilege escalation in Entra service principals. let CriticalIdentities = ExposureGraphNodes | where set_has_element(Categories, "identity") | where isnotnull(NodeProperties.rawData.criticalityLevel) and NodeProperties.rawData.criticalityLevel.criticalityLevel < 4 | extend AccountID = tostring(NodeProperties.rawData.accountObjectId) | distinct AccountID; CloudAppEvents | where ActivityType == "Add" | where ActionType == @"Add service principal credentials." | where AccountId has_any(CriticalIdentities)
This KQL query is designed to detect privilege escalation activities involving critical identities within an organization's Entra service principals. Here's a simplified summary:
Identify Critical Identities:
ExposureGraphNodes table.AccountIDs of these critical identities.Monitor for Privilege Escalation:
CloudAppEvents table for events where the activity type is "Add" and the action type is "Add service principal credentials."In essence, the query helps security operations teams monitor and detect when critical identities are involved in adding credentials to Entra service principals, which could indicate a potential privilege escalation.

Steven Lim
Released: August 2, 2024
Tables
Keywords
Operators