The Service Principal Hadn't Signed In for Months — Then It Changed a Privileged Role
The service principal had been quiet for months.
No recent workload sign-ins.
No obvious operational reason for it to suddenly become interesting.
Then privileged role activity appeared in the Microsoft Entra audit trail.
A non-human identity was now part of the investigation.
Agent Foskett needed to answer two separate questions:
What changed the privileged role — and why had this dormant workload identity suddenly become active?

Dormant Did Not Mean Harmless.
Service principals are workload identities. When one that has been quiet suddenly authenticates or appears around privileged directory activity, the investigation needs both sign-in evidence and audit evidence.
The role change was the trigger — not the conclusion
But Agent Foskett did not assume the service principal itself had directly performed the change simply because it appeared in the same investigation.
First he separated the actors in the audit record: the identity that initiated the operation, the identity that received or lost privilege, and any Microsoft or automation service involved in processing it.
In cloud identity investigations, the initiator and the target are not necessarily the same thing.
Start with privileged role activity in AuditLogs
AuditLogs. Agent Foskett searched for successful operations associated with adding members to roles, then preserved the complete target and initiator context.- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
AuditLogs
| where TimeGenerated > ago(30d)
| where OperationName has "Add member to role"
| where Result =~ "success"
| project TimeGenerated,
OperationName,
Category,
InitiatedBy,
TargetResources,
AdditionalDetails,
CorrelationId
| order by TimeGenerated descWas the service principal the initiator or the target?
TargetResources can contain the principal affected by the role operation and information about the role itself. InitiatedBy provides context about the identity or application that initiated the audited operation.Agent Foskett expanded the target resources instead of assuming that the first object in the array told the whole story.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
AuditLogs
| where TimeGenerated > ago(30d)
| where OperationName has "Add member to role"
| where Result =~ "success"
| mv-expand Target = TargetResources
| extend TargetType = tostring(Target.type),
TargetName = tostring(Target.displayName),
TargetId = tostring(Target.id)
| project TimeGenerated,
OperationName,
TargetType,
TargetName,
TargetId,
InitiatedBy,
CorrelationId
| order by TimeGenerated descThe service principal had a history — even if that history was mostly silence
Where Microsoft Entra service-principal sign-in logs had been exported to Log Analytics, he pivoted to
AADServicePrincipalSignInLogs.The absence of recent records was useful context only if the required telemetry had actually been collected and retained.
Find the workload identity's sign-in history
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
let ServicePrincipalObjectId =
"11111111-2222-3333-4444-555555555555";
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(90d)
| where ServicePrincipalId =~ ServicePrincipalObjectId
| summarize FirstSeen = min(TimeGenerated),
LastSeen = max(TimeGenerated),
Attempts = count(),
SourceIPs = make_set(IPAddress, 20),
Resources = make_set(ResourceDisplayName, 20)
by AppId, ServicePrincipalName
| order by LastSeen descObject ID and application ID are not interchangeable
ServicePrincipalId identifies the service principal object in the tenant, while AppId represents the application's client ID.Confusing them can produce incomplete searches or lead the investigation toward the wrong object.
Know which identity identifier your telemetry actually contains.
The first new sign-in mattered
Agent Foskett wanted to know when activity resumed, which resource was requested and which source IP addresses appeared around that change.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
let ServicePrincipalObjectId =
"11111111-2222-3333-4444-555555555555";
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(30d)
| where ServicePrincipalId =~ ServicePrincipalObjectId
| project TimeGenerated,
ServicePrincipalName,
AppId,
IPAddress,
ResourceDisplayName,
ResultType,
ResultDescription,
CorrelationId
| order by TimeGenerated ascA successful token request did not prove the role change
It does not automatically prove that the same authentication directly caused a particular directory change.
Agent Foskett correlated timestamps, identifiers, audit records and surrounding operations before linking the events.
Temporal proximity is a lead. Correlation is the investigation.
Did the service principal receive the privileged role?
Agent Foskett specifically looked for service-principal targets in role-management events.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
AuditLogs
| where TimeGenerated > ago(30d)
| where OperationName has "Add member to role"
| where Result =~ "success"
| mv-expand Target = TargetResources
| extend TargetType = tostring(Target.type),
TargetName = tostring(Target.displayName),
TargetId = tostring(Target.id)
| where TargetType =~ "ServicePrincipal"
| project TimeGenerated,
OperationName,
TargetName,
TargetId,
InitiatedBy,
CorrelationId
| order by TimeGenerated descThen investigate the identity that actually initiated the change
InitiatedBy.Was it an administrator? Another application? A governance workflow? A Microsoft-managed service involved in a legitimate PIM process?
Agent Foskett preserved the raw audit context before deciding what the initiator represented.
Do not accuse the target of performing the operation that changed the target.
Was the service principal expected to be active again?
Agent Foskett checked ownership, change records and the expected purpose of the application.
He also asked whether the workload identity still needed the permissions it retained.
Dormancy is not compromise. Unexpected reactivation is a reason to investigate.
What else did the workload identity access?
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
let ServicePrincipalObjectId =
"11111111-2222-3333-4444-555555555555";
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(30d)
| where ServicePrincipalId =~ ServicePrincipalObjectId
| summarize Attempts = count(),
FirstSeen = min(TimeGenerated),
LastSeen = max(TimeGenerated)
by ResourceDisplayName, IPAddress
| order by LastSeen descCheck for credential changes around the reactivation
Agent Foskett searched the Entra audit trail for updates involving the same application or service principal and reviewed the exact operation names and modified properties returned by the tenant.
Credential changes, renewed sign-ins and privileged activity belong on the same timeline when they occur together.
Build the workload identity timeline
What Agent Foskett checked
What the evidence can and cannot prove
AuditLogs can establish the directory operation Microsoft Entra recorded and provide initiator and target context. AADServicePrincipalSignInLogs can establish observed service-principal authentication activity where those logs are collected.Neither table alone automatically proves malicious intent, and a missing sign-in record is not proof of inactivity if collection or retention was incomplete.
Likewise, a service principal appearing as the target of a privileged role assignment does not mean it initiated that assignment.
Identify the actor. Identify the target. Then correlate the workload activity.
The lesson
Then workload activity returned and privileged role activity appeared in the same investigation window.
Agent Foskett did not collapse those facts into a conclusion. He separated the initiator from the target, examined the workload sign-in history and reconstructed the surrounding identity changes.
A non-human identity can remain dormant while retaining powerful access. When it suddenly becomes active, investigate the identity — not just the operation.
Related investigations
Final thought
But service principals can hold credentials, request tokens and participate in highly privileged automation.
When one that has been quiet suddenly becomes relevant, start with the evidence.
Find the workload sign-ins. Preserve the role event. Separate the initiator from the target. Then follow every related identity change until the timeline makes sense.
The service principal had been quiet.
The audit trail wasn't.
Follow the evidence. Build the timeline.
The Logs Already Knew! 🔎

