Before you run
Data & scope
- Required tables
- Time window
- 7 days
- Microsoft Entra ID connector with AuditLogs collected throughout the stated lookback and access to audit payloads.
- Any Microsoft Entra ID license supports audit ingestion; workspace query permissions and appropriate directory evidence access are required.
Documentation review by Codex (AI). No live-tenant execution or detection-performance claim. Validate schema, data coverage and expected results in your workspace.
// Hunting starter. Documentation checked 2026-11-13; not tenant-tested.
AuditLogs
| where TimeGenerated >= ago(7d) and TimeGenerated <= now()
| extend AuditOperation = coalesce(ActivityDisplayName, OperationName)
| where AuditOperation in~ ("Add owner to service principal", "Remove owner from service principal")
| where Result =~ "success"
| extend ActorObjectId = coalesce(tostring(InitiatedBy.user.id),
tostring(InitiatedBy.app.servicePrincipalId)),
ActorName = coalesce(tostring(InitiatedBy.user.userPrincipalName),
tostring(InitiatedBy.app.displayName)),
ActorIP = coalesce(tostring(InitiatedBy.user.ipAddress), tostring(InitiatedBy.app.ipAddress))
| project TimeGenerated, AADTenantId, AuditId = Id, AuditOperation,
ActorObjectId, ActorName, ActorIP, TargetResources, AdditionalDetails, CorrelationId
| order by TimeGenerated desc
| take 200
Read-only query. Run in your own authorized workspace after checking prerequisites.
This hunt reviews successful owner additions and removals for service-principal objects in a directory. It is useful for enterprise application administration, including SaaS and AI integrations. Ownership is an administrative relationship that deserves review, but the event alone is not a record of API permission consent or a resource role assignment.
Respect the local object boundary
A service principal represents an application’s local identity in a tenant. Its object ID differs from the application registration object and from the application client ID. A multi-tenant application can therefore have multiple local instances with different administrative contexts. Application and service-principal model.
The operation list selects service-principal ownership events only. The target payload is preserved intact so investigators can resolve the owned object and affected owner without relying on a fixed array position. InitiatedBy describes the actor performing the change, not necessarily the new owner. Target-resource structure.
A familiar application name does not establish that the local instance is the expected one. Resolve the service-principal object ID in the recorded directory and confirm the associated application ID and publisher context before linking the event to a workload.
Investigate the administrative change
Compare the ownership relationship with an approved onboarding, handover or decommissioning record. Determine the affected owner’s identity, the service principal’s purpose, and its current permissions. Review credential or configuration changes separately when they are relevant to the same object.
Automated enterprise application provisioning and administrative cleanup can produce legitimate changes. An owner removal can be protective maintenance or an attempt to remove oversight; a new owner can be an expected support team or an unexplained administrator. The difference requires context beyond the operation name.
Validate and bound the conclusion
Test a known addition, a removal and an application-registration ownership change. Only the first two should appear. Confirm that a service principal and an application sharing a client ID are not treated as the same directory object during follow-up.
The query reads seven days and shows the latest 200 collected rows. It does not enumerate standing owners, inherited administrative permissions or application data access. This documentation-checked hunt has not been tenant-tested. Before using it in scheduled detection, define the approved owner-change population, account for ingestion delay and test entity mapping against representative raw payloads.
Verify the source
Microsoft references
Measure normal activity, validate known test cases, account for ingestion delays, choose a threshold and entity mapping, and assign an owner. Results require investigation.
Follow the detection learning path →