iac.htora.dev · security templates

Home/For responders/Incident response on Azure

Incident response on Azure

Azure keeps 90 days of changes to your resources without being asked. How far back you can see sign-ins, reads of your data, and calls to Microsoft Graph depends on licences and settings chosen before the incident.

1An alert or a reporta Defender alert, a risky sign-in, a tip2Scope from the logsEntra sign-ins and audit, the Activity Log, resource logs3Contain by what was compromiseda user, an app, a managed identity, a VM4Preserve before you rebuildsnapshots, exported and hashed
The first hour on Azure. Identity comes first, because most Azure intrusions start with a sign-in.

What Azure records, and what it leaves out

LogOn by defaultKept
Activity LogYes. Writes, deletes, and actions through Resource Manager. No reads90 days, unless a diagnostic setting sends it somewhere else
Resource logsNo. Reads of blobs, secrets, and other data appear only after you add a diagnostic setting to each resourceAs long as the destination keeps them
Entra sign-in and audit logsYesSeven days on the Free licence, 30 days with P1 or P2
Microsoft Graph activity logsNo. Every request to Graph, reads included, once a diagnostic setting routes them. Needs P1 or P2As long as the destination keeps them

The Entra logs are the short ones, and most Azure incidents begin there. Send them and the Activity Log to a workspace or storage account before you need them. The audit log template keeps the Activity Log where nobody in the subscription can delete it.

Reading an identity out of the logs

  • The Activity Log names the caller. caller contains a user's email or UPN, or a service principal's ID. claims contains the token the call was made with.
  • Sign-ins come in four logs. Interactive user, non-interactive user, service principal, and managed identity. An attacker replaying a stolen refresh token appears in the non-interactive log.
  • A managed identity sign-in names the resource that used it, such as the VM, and carries no IP address, because the request comes from inside Azure.
  • New credentials on an app are audit events. Look for Update application events that change certificates and secrets, and Add service principal credentials, in the Entra audit log. They are how an attacker keeps access after a user is disabled.
  • A pod using Workload ID signs in through a federated credential. The sign-in carries FederatedCredentialId; the credential's subject, system:serviceaccount:<namespace>:<name>, names the pod's service account.
az monitor activity-log list --caller <upn or app id> --offset 7d
az monitor activity-log list --resource-group <group> --offset 7d --query "[?authorization.action=='Microsoft.Authorization/roleAssignments/write']"

Containment, by what was compromised

The containment refresher puts the first move for each kind of compromise on one printable page.

CompromisedFirst moveWatch out
A userDisable the account, then Revoke-MgUserSignInSession, which invalidates refresh tokens and browser sessionsAccess tokens already issued last about an hour. Services that support continuous access evaluation, such as Exchange Online, SharePoint, Teams, and Graph, drop them sooner
An app or service principalSet the service principal's accountEnabled to false, then remove the credentials the attacker addedOther credentials on the same app, and permissions it was granted by consent
A managed identityRemove its role assignments, and stop or isolate the resource that has itIts tokens are cached for around 24 hours and cannot be refreshed early. Microsoft says role changes may take several hours to reach it
A VMA CanNotDelete lock, snapshots of every disk, then a deny-all network security group. The evidence template does all three when someone tags the VMRemoving a rule that allowed a connection leaves existing connections running. A ReadOnly lock would also stop the VM being started or restarted
A device with Defender for EndpointIsolate the device. It keeps its connection to Defender, so you can still collect an investigation packageIsolation is part of Defender for Endpoint Plan 1 and above; a VM without the agent needs the network security group instead

Saved queries

30 saved queries from four templates open in this cloud's console, named as the console lists them. The Standard and Hardened levels install them; the Quick start installs none. They are written in KQL, the Kusto Query Language that Log Analytics reads.

Saved queryWhat it answersTemplate that installs itWhere to open it
ai-keys-fetchedThe search behind the keys-fetched alert, over the last seven days.Know who is using your AI modelsLog Analytics workspace, Logs, Queries, category AI model logging
ai-filters-changedThe search behind the filters-changed alert, over the last seven days.Know who is using your AI modelsLog Analytics workspace, Logs, Queries, category AI model logging
ai-deployment-changedThe search behind the deployment-changed alert, over the last seven days.Know who is using your AI modelsLog Analytics workspace, Logs, Queries, category AI model logging
ai-account-changedThe search behind the account-changed alert, over the last seven days.Know who is using your AI modelsLog Analytics workspace, Logs, Queries, category AI model logging
ai-logging-weakenedThe search behind the logging-weakened alert, over the last seven days.Know who is using your AI modelsLog Analytics workspace, Logs, Queries, category AI model logging
ai-calls-by-callerInference calls in the last seven days, by account, caller object ID, and deployment.Know who is using your AI modelsLog Analytics workspace, Logs, Queries, category AI model logging
ai-calls-without-object-idInference calls in the last seven days with no caller object ID. An empty value suggests a key and needs checking.Know who is using your AI modelsLog Analytics workspace, Logs, Queries, category AI model logging
insider-keys-or-sasThe search behind the keys-or-sas alert, over the last seven days.Notice data walking out the doorLog Analytics workspace, Logs, Queries, category Insider data theft
insider-decrypt-rightsThe search behind the decrypt-rights alert, over the last seven days.Notice data walking out the doorLog Analytics workspace, Logs, Queries, category Insider data theft
insider-logging-weakenedThe search behind the logging-weakened alert, over the last seven days.Notice data walking out the doorLog Analytics workspace, Logs, Queries, category Insider data theft
insider-bulk-readCallers who read the most from the sensitive accounts in the last hour.
Only when sensitive_storage_account_ids is set.
Notice data walking out the doorLog Analytics workspace, Logs, Queries, category Insider data theft
malicious-flowsFlows to or from addresses Microsoft rates malicious.Keep network records long enough to be usefulLog Analytics workspace, Logs, Queries, category Investigation
top-outbound-destinationsBusiest outbound destinations on the internet, last day.Keep network records long enough to be usefulLog Analytics workspace, Logs, Queries, category Investigation
one-addressEverything one private address talked to. Replace the address first.Keep network records long enough to be usefulLog Analytics workspace, Logs, Queries, category Investigation
entra-role-grantedThe search behind the role-granted alert, over the last seven days.Catch account takeover at the identity provider
Entra ID
Log Analytics workspace, Logs, Queries, category Identity provider signals
entra-app-credentialsThe search behind the app-credentials alert, over the last seven days.Catch account takeover at the identity provider
Entra ID
Log Analytics workspace, Logs, Queries, category Identity provider signals
entra-sign-in-changedThe search behind the sign-in-changed alert, over the last seven days.Catch account takeover at the identity provider
Entra ID
Log Analytics workspace, Logs, Queries, category Identity provider signals
entra-mfa-changed-by-adminThe search behind the mfa-changed-by-admin alert, over the last seven days.Catch account takeover at the identity provider
Entra ID
Log Analytics workspace, Logs, Queries, category Identity provider signals
entra-break-glass-sign-inThe search behind the break-glass-sign-in alert, over the last seven days.
Only when break_glass_object_ids is set.
Catch account takeover at the identity provider
Entra ID
Log Analytics workspace, Logs, Queries, category Identity provider signals
entra-risky-sign-inThe search behind the risky-sign-in alert, over the last seven days.
Only when risky_sign_in_alerts is true.
Catch account takeover at the identity provider
Entra ID
Log Analytics workspace, Logs, Queries, category Identity provider signals
entra-one-userEverything one user did and every sign-in they made, last seven days. Replace the UPN first.Catch account takeover at the identity provider
Entra ID
Log Analytics workspace, Logs, Queries, category Identity provider signals
entra-sign-ins-by-sourceSign-ins by user, address, and result, last 24 hours.Catch account takeover at the identity provider
Entra ID
Log Analytics workspace, Logs, Queries, category Identity provider signals
m365-mail-forwardedThe search behind the mail-forwarded alert, over the last seven days.Catch account takeover at the identity provider
Microsoft 365
Log Analytics workspace, Logs, Queries, category Identity provider signals
m365-transport-rule-redirectThe search behind the transport-rule-redirect alert, over the last seven days.Catch account takeover at the identity provider
Microsoft 365
Log Analytics workspace, Logs, Queries, category Identity provider signals
m365-mailbox-access-grantedThe search behind the mailbox-access-granted alert, over the last seven days.Catch account takeover at the identity provider
Microsoft 365
Log Analytics workspace, Logs, Queries, category Identity provider signals
m365-audit-weakenedThe search behind the audit-weakened alert, over the last seven days.Catch account takeover at the identity provider
Microsoft 365
Log Analytics workspace, Logs, Queries, category Identity provider signals
m365-guest-added-to-teamThe search behind the guest-added-to-team alert, over the last seven days.Catch account takeover at the identity provider
Microsoft 365
Log Analytics workspace, Logs, Queries, category Identity provider signals
m365-bulk-downloadUsers ranked by distinct files downloaded or synced in the last hour.Catch account takeover at the identity provider
Microsoft 365
Log Analytics workspace, Logs, Queries, category Identity provider signals
m365-signals-silentWhen each Microsoft 365 workload last sent a record.Catch account takeover at the identity provider
Microsoft 365
Log Analytics workspace, Logs, Queries, category Identity provider signals
m365-one-userEverything one user did in Microsoft 365, last seven days. Replace the UPN first.Catch account takeover at the identity provider
Microsoft 365
Log Analytics workspace, Logs, Queries, category Identity provider signals

Forensics on an Azure VM

  • Disks. A snapshot covers one disk, so take one of the OS disk and each data disk. Export with az snapshot grant-access, which returns a read URL valid for at most 60 days.
  • Memory. Azure has no managed memory capture. Run Command runs a script as root or SYSTEM for up to 90 minutes, and returns only 4 KB of output, so have the capture tool write the image to storage.
  • Chain of custody. Microsoft's reference architecture copies snapshots to immutable blob storage in a separate security subscription, under a legal hold, and keeps each hash in Key Vault.
  • Where to look at it. An analysis machine with no route to the internet, reached through Bastion.

Detection you can switch on

ServiceWhat it adds
Defender for Cloud plansServers (Plan 1 brings Defender for Endpoint; Plan 2 adds agentless scanning, file integrity monitoring, and just-in-time access), Resource Manager, Storage, Key Vault, Containers, and more. Foundational posture management is free
Defender for Resource ManagerSuspicious management operations, known attack toolkits, and moves from the control plane into data
Entra ID ProtectionRisky users and sign-ins. Most detections need P2; without it you see leaked credentials, anonymous IP addresses, and a generic "additional risk detected"
Workload identity riskLeaked credentials and anomalous activity for service principals. Managed identities are not covered
Microsoft SentinelThe SIEM, now run from the Defender portal. Microsoft ends support in the Azure portal after March 31, 2027

Containers on Azure

AKS adds a cluster audit log that is off until you add a diagnostic setting, nodes that repair and upgrades reimage, and OS disks that cannot be snapshotted. Containers on AKS and OKE covers each of these, and the container evidence template captures a compromised pod.

Registry 0.23.0. Built 2026-11-17.

Made by Habibullah Tora. Source on GitHub. Code under the MIT licence, writing under CC BY 4.0.