← Sentinel query library

Identity governance · Microsoft Sentinel

Reconstruct application consent and permission grants

Preserve initiator identity and every target's permission-change evidence for successful app-role, delegated-permission and consent events.

Before you run

Data & scope

Required tables
AuditLogs
Time window
7 days
  • Microsoft Entra ID connector with AuditLogs and the relevant ApplicationManagement events collected.
  • Any Microsoft Entra ID license supports audit-log ingestion; permission to query the audit data and inspect application grants.

Documentation review by Codex (AI). No live-tenant execution or detection-performance claim. Validate schema, data coverage and expected results in your workspace.

Kusto Query Language
Download .kql
// 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 app role assignment to service principal",
    "Add app role assignment to the service principal",
    "Add delegated permission grant",
    "Consent to application")
| where Result =~ "success"
| extend GrantKind = case(AuditOperation in~ (
        "Add app role assignment to service principal",
        "Add app role assignment to the service principal"), "Application permission",
        AuditOperation =~ "Add delegated permission grant", "Delegated permission", "Consent event"),
    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)),
    TargetsToInspect = iff(array_length(TargetResources) > 0,
        TargetResources, dynamic([{}]))
| mv-expand Target = TargetsToInspect
| extend TargetType = tostring(Target.type), TargetObjectId = tostring(Target.id),
    TargetName = tostring(Target.displayName),
    PropertiesToInspect = iff(array_length(Target.modifiedProperties) > 0,
        Target.modifiedProperties, dynamic([{}]))
| mv-apply Property = PropertiesToInspect on (
    extend PropertyName = tostring(Property.displayName),
        OldValue = tostring(Property.oldValue), NewValue = tostring(Property.newValue)
    | summarize ChangedAttributes = make_list(
        bag_pack("name", PropertyName, "old", OldValue, "new", NewValue), 50)
)
| summarize TargetRows = count(), TargetEvidence = make_list(
        bag_pack("type", TargetType, "objectId", TargetObjectId,
            "name", TargetName, "changes", ChangedAttributes), 25)
    by TimeGenerated, AADTenantId, AuditId = Id, AuditOperation, GrantKind,
        ActorObjectId, ActorName, ActorIp, CorrelationId
| extend ActorIdentityPresent = isnotempty(ActorObjectId)
| order by TimeGenerated desc
| take 200

Read-only query. Run in your own authorized workspace after checking prerequisites.

Use this hunt to reconstruct a permission grant before deciding whether it was expected, excessive or unauthorized. It returns successful app-role assignments, delegated-permission grants and application-consent events, preserving the initiating identity and the changed attributes of every reported target. These are distinct audit activities; one approval workflow can produce more than one event. Microsoft’s permission-audit mapping.

This is an evidence collection query, not a list of currently effective permissions. It does not equate consent with compromise or assign a universal severity from an application’s display name.

Read the target evidence

Each result represents an audit event with up to 25 target entries, each retaining up to 50 changed properties. Those explicit limits keep the output manageable. Inspect the original audit record if a collection reaches its cap. Missing target or property collections produce an empty evidence object instead of silently dropping the event.

The query normalizes changed attributes into name, old value and new value. It preserves their serialized values because different operations use different payloads. A target might be the client application, the API exposing a permission, or another involved object. Do not automatically call the first target the recipient, and do not treat every target identifier as an application/client ID. The Graph targetResource schema defines the object ID and operation-dependent modifications.

The initiator is resolved from either the user or application branch of the audit identity. An empty initiating object ID remains visible. The label and IP address help triage but do not replace a stable identity or prove who physically approved the request.

Reconstruct the effective grant

Resolve the client service principal, resource service principal, permission identifier, and permission type from the event and authoritative directory state. For delegated access, determine the consent scope and whether it applies to one user or all users. For application permissions, resolve the app-role value against the resource API. Assess those permissions against the application’s documented job.

Compare the initiator, timing and requested authority with the approval record. Review related grants, subsequent credential changes and service-principal sign-ins as separate evidence. If a broad permission appeared unexpectedly, establish whether a later removal or modification changed its current effect before describing the entitlement as still active. Microsoft’s application monitoring guidance identifies permission changes that merit scrutiny; the appropriate severity depends on the resource and actual authority.

Tune and validate

New application onboarding, administrator consent campaigns, legitimate user consent and migration tooling can produce bursts. Group an investigation using audit IDs, correlation IDs and its approval record rather than counting every row as a distinct grant. Avoid excluding an entire publisher or administrator simply because some previous grants were legitimate.

The seven-day scan and latest 200 results are bounded starting points. Narrow the time range or investigated directory for complete review of a busy interval. This hunt does not calculate inherited access, cover every removal/update activity, or prove that any granted permission was used. Missing collection or retention can hide the preceding consent history.

The query is read-only and documentation-checked, with no tenant execution or detection-performance claim. Validate an authorized delegated grant and application-permission grant, including the actual target layout, before turning this evidence view into an alert.

Verify the source

Microsoft references

  1. Microsoft Learn — AuditLogs table schema ↗
  2. Microsoft Learn — Audit application permission changes ↗
  3. Microsoft Learn — Microsoft Graph targetResource ↗
  4. Microsoft Learn — Security operations for applications ↗
  5. Microsoft Learn — Microsoft Entra ID connector requirements ↗
Before turning a hunt into an alert

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 →