Query Details
# *Microsoft Dynamics 365 Privilege Escalation via Role or Team Modification*
## Query Information
#### MITRE ATT&CK Technique(s)
| Technique ID | Title | Link |
| --- | --- | --- |
| T1098 | Account Manipulation | https://attack.mitre.org/techniques/T1098 |
| T1078 | Valid Accounts | https://attack.mitre.org/techniques/T1078 |
#### Description
This rule detects suspicious activity in Microsoft Dynamics 365 where an account, from outside the corporate IP range, first performs inquiries about user privileges and then subsequently modifies or creates roles or teams within a short time frame. This could indicate an attempt to escalate privileges or gain unauthorized access.
#### Author <Optional>
- **Name: Benjamin Zulliger**
- **Github: https://github.com/benscha/KQLAdvancedHunting**
- **LinkedIn: https://www.linkedin.com/in/benjamin-zulliger/**
#### Possible false positives
- Legitimate administrative actions performed by users
## Defender XDR
```KQL
let CorporateIPRange = "147.86.0.0/16";
let ThreatWindow = 10m;
let SuspiciousInquiries =
CloudAppEvents
| where TimeGenerated > ago(1d)
| where Application == "Microsoft Dynamics 365"
| where not(ipv4_is_in_range(IPAddress, CorporateIPRange ))
| where IsAdminOperation == 0
| where ActionType in ("RetrieveUserPrivileges", "RetrieveUserPrivilegeByPrivilegeName", "RetrievePrivilegeMaxDepthFromTeamRoles")
| project TargetTime = TimeGenerated, AccountId, IPAddress, CorrelationId = tostring(parse_json(RawEventData).CorrelationId);
CloudAppEvents
| where TimeGenerated > ago(1d)
| where Application == "Microsoft Dynamics 365"
| where not(ipv4_is_in_range(IPAddress, CorporateIPRange ))
| where ActionType has_any ("Update", "Create") and (ObjectName has "role" or ObjectName has "team" or parse_json(RawEventData).EntityName has_any ("role", "systemuserroles", "teamroles"))
| project ModificationTime = TimeGenerated, AccountId, ActionType, ObjectName, RawEventData
| join kind=inner SuspiciousInquiries on AccountId
| where ModificationTime between (TargetTime .. (TargetTime + ThreatWindow))
| project ModificationTime, AccountId, ActionType, ObjectName, IPAddress, TargetTime
```
This KQL query is designed to detect potentially suspicious activities in Microsoft Dynamics 365 that could indicate privilege escalation attempts. Here's a simplified explanation:
Objective: The query aims to identify instances where an account, accessing the system from outside the corporate IP range, first checks user privileges and then quickly modifies or creates roles or teams. This behavior might suggest an attempt to gain unauthorized access or escalate privileges.
Key Components:
147.86.0.0/16), focusing on external accesses.Detection Logic:
Potential False Positives: Legitimate administrative actions by users might trigger this detection, so further investigation is necessary to confirm any malicious intent.
Overall, this query helps security teams monitor and respond to potential privilege escalation attempts in Microsoft Dynamics 365 by identifying unusual patterns of behavior from external accounts.

Benjamin Zulliger
Released: June 24, 2026
Tables
Keywords
Operators