DFIR Investigation Runbooks
13 incident types. Every step with its query or command.
Step-by-step runbooks for the incidents responders handle most often: what to do in the first 15 minutes, the steps in order with what to expect and what to decide, the evidence to keep, containment, verification and the handoff. No account needed.
13 runbooks for the incidents analysts and responders handle most often, from the first alert to the handoff. Each one is a sequence of steps with the exact query or command, what you should expect to see, and the decision it leads to, for Microsoft 365, Entra ID, Defender XDR, Active Directory, Azure, AWS and Linux. The decisions behind them, and the process around them, are in the Incident Response reference.
How to use a runbook
Read the first 15 minutes before running anything. Then work the steps in order: each one narrows the scope, and the decision at the end of a step tells you whether to continue, branch to another runbook, or close. Replace the example values (accounts, addresses, hosts, times) with yours. Every query sets its own time window; widen it if the first attacker activity is older.
| Section | What it gives you |
|---|---|
| Starts with | The alerts or reports that should open this runbook. |
| First 15 minutes | What to do before the first query: ownership, preservation, the one call that cannot wait. |
| Steps | In order. Each has a query or command, what you should expect to see, and the decision it leads to. |
| Evidence to secure | What to keep, where it is, and how to collect it, before containment changes it. |
| Contain | The exact actions, and what each one does not do. |
| Verify | The query that proves containment held. |
| Common mistakes | What goes wrong most often on this incident type. |
| Hand off | What the next team needs from you, in writing. |
When to escalate
| Escalate to the incident commander when | Why |
|---|---|
| A privileged account (domain, cloud or Azure admin) is involved | The scope is the whole estate, not one host |
| More than one account or host is confirmed compromised | It is a campaign, and needs coordination |
| Data may have left, or personal data was read | Notification clocks may have started; legal must know |
| Encryption, destruction or a payment is in progress | Business decisions are needed now |
| You need to take a service offline to contain it | That is a business decision, not an analyst one |
Evidence in brief
- Capture before you contain: isolation ends running processes and connections, and purges remove the copies you need.
- Keep a hash of every file you collect, and a record of who collected it, when and how.
- Export cloud logs early; each source has its own retention limit.
- Work on copies. Never analyze the only copy of an item.
- The full chain-of-custody fields and legal hold are in the Incident Response reference.
The handoff template
Every runbook ends in a handoff. These are the fields to fill, whoever receives it.
| Field | Contents |
|---|---|
| Summary | What happened, in two sentences, and whether it is contained |
| Scope | Accounts, hosts, mailboxes, applications and cloud resources, each with how it was established |
| Timeline | First attacker activity to containment, in UTC, each line with its source |
| Indicators | Addresses, domains, hashes, session IDs, application IDs, access key IDs |
| Actions taken | Each containment and eradication step, with the time and who did it |
| Evidence | Each item, where it is stored, and its hash |
| Open questions | What is not yet known, and what would answer it |
| Recommendations | The control or detection gap that let it happen |
Which runbook?
| If you have | Start with |
|---|---|
| A risky sign-in, an impossible-travel or AiTM alert | 01 Identity compromise |
| Lockouts or failed sign-ins across many accounts | 02 Password spray |
| An application you do not recognize with mail or file access | 03 OAuth app |
| Changed bank details, or an invoice nobody sent | 04 Business email compromise |
| A reported message, or a malicious URL click | 05 Phishing campaign |
| An endpoint alert or antivirus detection | 06 Malware on an endpoint |
| Remote execution, PsExec, WMI, WinRM or RDP from an odd source | 07 Lateral movement |
| Kerberoasting, DCSync, or a privileged group change | 08 AD privilege escalation |
| Renamed or encrypted files, a ransom note, shadow copies deleted | 09 Ransomware |
| A large download, outside sharing, a departing employee | 10 Exfiltration and insider |
| An Azure role you did not grant, or compute you did not create | 11 Azure subscription |
| An exposed or misused AWS access key | 12 AWS access key |
| An alert on a Linux server, an unknown SSH login | 13 Linux server |
The pivots the runbooks share
Most steps are a pivot from one indicator to the others. The same few pivots appear across the runbooks; learning them once makes every runbook faster.
| Indicator | Pivot to | Runbooks that use it |
|---|---|---|
| IP address | Sign-ins for every account; network events for every device; CloudTrail and AzureActivity callers | 01, 02, 06, 11, 12 |
| Session ID | Every address the session was used from | 01 |
| Account | Its sign-ins, mailbox changes, directory changes, device logons | 01, 04, 07, 08, 10 |
| Host | Logons to and from it, process tree, network connections, persistence | 06, 07, 09, 13 |
| File hash | Every device where it was written or run, every message that carried it | 05, 06 |
| Message ID | Every recipient and click | 04, 05 |
| Application ID | Consents, grants, its own sign-ins and activity | 03 |
| Access key ID | Every API call, every resource it created | 12 |
The runbooks
| # | Runbook | Severity |
|---|---|---|
| 01 | Identity compromise: AiTM phishing and token theft | High |
| 02 | Password spray and brute force | Medium |
| 03 | Malicious OAuth app or consent grant | High |
| 04 | Business email compromise and payment fraud | High |
| 05 | Phishing campaign: scope, purge and contain | Medium |
| 06 | Malware on an endpoint | High |
| 07 | Lateral movement | High |
| 08 | Active Directory privilege escalation: Kerberoasting, DCSync, privileged groups | Critical |
| 09 | Ransomware, before and after encryption | Critical |
| 10 | Data exfiltration and insider cases | High |
| 11 | Azure subscription compromise | Critical |
| 12 | AWS access key compromise | Critical |
| 13 | Linux server compromise: SSH and web server | High |
01Identity compromise: AiTM phishing and token theftHigh
Starts with: an Entra ID Protection risky sign-in, a Defender XDR "suspicious session" or AiTM alert, or a user reporting a login page that looked wrong.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Name an owner and start the log with the alert time and the account.
- Do not reset the password yet. Find out what else the attacker added first, or you will reset around it.
- Note the suspicious sign-in's IP address, session ID and time; they are the pivots for every step below.
- Ask the user, by phone, whether they signed in at that time and from where.
Steps
Pull the account's successful sign-ins for the last 14 days and compare the suspicious one with the rest: address, country, device, browser and how MFA was satisfied.
// Successful sign-ins for one account, newest first
let upn = "compromised.user@yourdomain.com";
SigninLogs
| where TimeGenerated > ago(14d)
| where UserPrincipalName =~ upn and ResultType == "0"
| project TimeGenerated, IPAddress, Location, AppDisplayName,
ClientAppUsed, DeviceDetail, AuthenticationRequirement,
SessionId, RiskLevelDuringSignIn
| sort by TimeGenerated descExpect: the attacker's sign-in from an address and device the user does not use, often minutes after a click on a phishing link, with MFA shown as satisfied.
Decide: one unfamiliar sign-in the user confirms was them (travel, a new phone): close as benign and record why. Otherwise treat the account as compromised and continue.
AiTM phishing steals the session cookie, so the same SessionId appears from the attacker's address. Look for sessions used from more than one address or country.
let upn = "compromised.user@yourdomain.com";
SigninLogs
| where TimeGenerated > ago(14d)
| where UserPrincipalName =~ upn and isnotempty(SessionId)
| summarize IPs = make_set(IPAddress, 20), Countries = dcount(Location),
First = min(TimeGenerated), Last = max(TimeGenerated) by SessionId
| where array_length(IPs) > 1Expect: a session that starts at the user's address and continues from the attacker's.
Decide: if the attacker's address appears, pivot on it across all accounts in step 3.
Phishing campaigns rarely catch one person. Every account with a successful sign-in from the same address is in scope.
let badIP = "203.0.113.42";
SigninLogs
| where TimeGenerated > ago(14d)
| where IPAddress == badIP and ResultType == "0"
| summarize SignIns = count(), Apps = make_set(AppDisplayName, 10),
First = min(TimeGenerated) by UserPrincipalNameExpect: one row per compromised account.
Decide: run this runbook for each account found, in parallel if there are several.
MFA methods, consents, devices and role changes made by or for the account since the first bad sign-in.
let upn = "compromised.user@yourdomain.com";
let since = datetime(2026-03-14T08:00:00Z); // first attacker sign-in
AuditLogs
| where TimeGenerated > since
| where tostring(InitiatedBy.user.userPrincipalName) =~ upn
or tostring(TargetResources) has upn
| project TimeGenerated, OperationName, Result,
Target = tostring(TargetResources[0].displayName)
| sort by TimeGenerated ascExpect: entries such as "User registered security info", "Consent to application", or "Add registered owner to device".
Decide: each entry becomes an eradication item. A role or app change means escalating to runbook 3 or 11.
Inbox rules and forwarding keep working after a password reset, and they are the usual first move after an AiTM sign-in.
let upn = "compromised.user@yourdomain.com";
OfficeActivity
| where TimeGenerated > ago(14d)
| where UserId =~ upn
| where Operation in ("New-InboxRule", "Set-InboxRule", "UpdateInboxRules",
"Set-Mailbox")
| project TimeGenerated, Operation, ClientIP, ParametersExpect: a rule that moves or deletes mail, or forwarding to an outside address.
Decide: any rule that hides mail about payments or invoices: also run runbook 4.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Sign-in records for the account | Entra ID sign-in logs (30 days on P1 and P2) | Export from the portal, or keep the query results |
| Audit records for the account | Unified audit log | Search-UnifiedAuditLog with a session ID, to CSV |
| Inbox rules and forwarding as found | Exchange Online | Get-InboxRule and Get-Mailbox, to CSV, before removing anything |
| The phishing message | The user's mailbox | One copy as an .eml with headers |
| The attacker's registered methods and devices | Entra ID | Get-MgUserAuthenticationMethod and Get-MgUserRegisteredDevice output |
Contain
Disable the account, revoke its sessions and disable its devices. Access tokens already issued stay valid until they expire, one hour by default, unless the application supports Continuous Access Evaluation.
Connect-MgGraph -Scopes 'User.ReadWrite.All','Directory.AccessAsUser.All'
$u = Get-MgUser -UserId 'compromised.user@yourdomain.com'
Update-MgUser -UserId $u.Id -AccountEnabled:$false
Revoke-MgUserSignInSession -UserId $u.Id
Get-MgUserRegisteredDevice -UserId $u.Id -All | ForEach-Object {
Update-MgDevice -DeviceId $_.Id -AccountEnabled:$false
}Then list the authentication methods and remove the ones the user did not register:
Get-MgUserAuthenticationMethod -UserId $u.Id |
Select-Object Id, @{ n = 'Type'; e = { $_.AdditionalProperties['@odata.type'] } }
Get-MgUserAuthenticationMicrosoftAuthenticatorMethod -UserId $u.Id |
Select-Object Id, DisplayName, DeviceTag, CreatedDateTime
Remove-MgUserAuthenticationMicrosoftAuthenticatorMethod -UserId $u.Id `
-MicrosoftAuthenticatorAuthenticationMethodId 'Id from the list'Remove the inbox rules and consents found in steps 4 and 5, after exporting them. Then reset the password and re-enable the account with the user present to re-register MFA.
Verify
// Any successful sign-in after containment means it did not hold
let upn = "compromised.user@yourdomain.com";
let containedAt = datetime(2026-03-15T09:30:00Z);
SigninLogs
| where TimeGenerated > containedAt
| where UserPrincipalName =~ upn and ResultType == "0"
| project TimeGenerated, IPAddress, AppDisplayName, ClientAppUsedRe-run step 4 the next day: no new methods, consents or devices.
Common mistakes
- Resetting the password and stopping. The stolen session and the attacker's MFA method both survive a reset.
- Re-enabling before the persistence check in step 4.
- Investigating only the account that alerted, when step 3 would have found the others.
- Deleting the phishing message before keeping a copy.
A risky sign-in alert fires for a finance user at 08:14. The user, called on their mobile, says they opened a DocuSign link at 08:12 and signed in, but has not used the account since. Step 1 shows the 08:14 sign-in from a hosting provider in another country with MFA satisfied; step 2 shows the same session ID used from the user's home address at 08:12 and the hosting address from 08:14. Step 3 finds two more accounts signed in from that address in the same hour. Step 4 finds a new authenticator app registered at 08:20; step 5 finds an inbox rule moving mail from the accounts payable team to RSS Feeds. Three accounts are contained together, the rule and the authenticator are removed after export, and runbook 4 opens for the finance mailbox.
Before you close
- Do you know every account the attacker signed in to, and why you are sure there are no others?
- Is every item the attacker added removed, and was each one exported first?
- Has legal been told whether mail or files were read?
Hand off
- Accounts in scope, with the first attacker sign-in time for each.
- Attacker addresses and session IDs.
- Every item removed (rules, methods, consents, devices), with the export file for each.
- Whether mail or files were read: this decides the notification question for legal.
- The gap that let it happen (no phishing-resistant MFA, no token protection) as a recommendation.
02Password spray and brute forceMedium
Starts with: a spray alert from Entra ID Protection or Defender for Identity, account lockouts across many users, or a SIEM rule on failed sign-ins.
First 15 minutes
- Find out whether any account succeeded. A spray with no success is a tuning and blocking job; a spray with a success is an identity compromise.
- Note the source addresses and the time window.
- Check whether lockouts are hurting the business; if so, tell the service desk what is happening.
Steps
Error 50126 is a wrong username or password; 50053 is a locked account. Count accounts per source address.
SigninLogs
| where TimeGenerated > ago(1d)
| where ResultType in ("50126", "50053")
| summarize Accounts = dcount(UserPrincipalName), Failures = count(),
First = min(TimeGenerated), Last = max(TimeGenerated)
by IPAddress, AppDisplayName, ClientAppUsed
| where Accounts >= 10
| order by Accounts descExpect: a few addresses failing against many accounts, often through legacy protocols or a single application.
Decide: none above your threshold: probably a single user with a cached old password. Close.
This is the step that matters.
let spray = SigninLogs
| where TimeGenerated > ago(1d)
| where ResultType in ("50126", "50053")
| summarize Accounts = dcount(UserPrincipalName) by IPAddress
| where Accounts >= 10;
SigninLogs
| where TimeGenerated > ago(1d)
| where ResultType == "0"
| join kind=inner spray on IPAddress
| project TimeGenerated, UserPrincipalName, IPAddress, AppDisplayName,
AuthenticationRequirementExpect: nothing, ideally. A success with AuthenticationRequirement singleFactorAuthentication is a password working alone.
Decide: any success: run runbook 1 for that account.
Defender for Identity sees authentication on domain controllers, where Entra ID logs do not reach.
IdentityLogonEvents
| where Timestamp > ago(1d)
| where ActionType == "LogonFailed"
| summarize Accounts = dcount(AccountUpn), Failures = count()
by IPAddress, DeviceName, Protocol
| where Accounts >= 10Expect: a workstation or server address failing against many accounts over NTLM or Kerberos.
Decide: an internal source is a compromised host: run runbook 6 on it.
For a domain controller's 4771 or 4776 failures, the source workstation is in the event. On that host, find the process making the connections.
let src = "ws-fin-042";
DeviceNetworkEvents
| where Timestamp > ago(1d)
| where DeviceName =~ src and RemotePort in (88, 389, 445, 636)
| summarize Connections = count(), Targets = dcount(RemoteIP)
by InitiatingProcessFileName, InitiatingProcessCommandLine
| order by Connections descExpect: one process with thousands of connections to domain controllers.
Decide: contain the host (runbook 6).
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Failed and successful sign-ins for the window | Entra ID sign-in logs | Query results, exported |
| Domain controller failures | Security log on DCs (4771, 4776, 4625), Defender for Identity | IdentityLogonEvents query, or wevtutil epl on the DCs |
| The source host's process and network events | Defender XDR | Investigation package if internal |
Contain
Block the external addresses in Conditional Access (a named location set to block) or at the edge, if they are not shared infrastructure. Block legacy authentication if the spray used it.
For an internal source, isolate the host. For any account that succeeded, follow runbook 1.
Verify
Re-run step 1 an hour after blocking: the failures from those addresses should stop or show as blocked by Conditional Access.
Common mistakes
- Watching only Entra ID when the spray targets on-premises AD, or the reverse.
- Unlocking accounts in bulk while the spray is still running, so it can continue.
- Stopping at "blocked" without checking for a success.
Forty lockouts arrive at the service desk in an hour. Step 1 shows one address failing against 380 accounts through legacy authentication. Step 2 finds one success, a shared mailbox that had no MFA. Legacy authentication is blocked tenant-wide, the shared mailbox goes to runbook 1, and the 380 accounts are unlocked once the block is confirmed in step 1's rerun.
Before you close
- Did any account succeed, and is each one in runbook 1?
- Is the source blocked, and was the protocol it used closed?
Hand off
- Source addresses and hosts, the number of accounts tried, and any that succeeded.
- Blocks applied, and where.
- Accounts that need a forced password change.
03Malicious OAuth app or consent grantHigh
Starts with: a consent alert from Defender for Cloud Apps or Entra ID, a user reporting a strange "permissions requested" prompt, or an unfamiliar application found during another investigation.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Identify the application: name, application ID, publisher, and whether the consent is for one user or the whole tenant.
- Disable it before anything else if it holds mail or file permissions; disabling is reversible.
- Keep the application, its consents and its audit trail as evidence: do not delete it.
Steps
Microsoft's app consent playbook starts from the "Consent to application" activity and the IsAdminConsent value: true means tenant-wide access.
AuditLogs
| where TimeGenerated > ago(90d)
| where OperationName == "Consent to application"
| extend Props = tostring(TargetResources[0].modifiedProperties)
| project TimeGenerated, Result,
Actor = tostring(InitiatedBy.user.userPrincipalName),
App = tostring(TargetResources[0].displayName), Props
| sort by TimeGenerated descExpect: the consent, who granted it, and the scopes in the modified properties.
Decide: scopes rooted in Mail, Files, Contacts or MailboxSettings, or tenant-wide consent to a third-party app: treat as malicious until shown otherwise.
Delegated grants with ConsentType AllPrincipals cover every user.
$sp = Get-MgServicePrincipal -Filter "appId eq 'appId-from-the-audit-log'"
Get-MgServicePrincipalOauth2PermissionGrant -ServicePrincipalId $sp.Id -All |
Select-Object Id, ConsentType, PrincipalId, Scope
$sp | Select-Object DisplayName, AppId, AppOwnerOrganizationId, ReplyUrlsExpect: the scopes, and whether the app is owned by another tenant.
Decide: reply URLs on unfamiliar or newly registered domains strengthen the case.
The application signs in as itself, and its activity shows in Defender for Cloud Apps against its OAuth app ID.
let appId = "00000000-0000-0000-0000-000000000000"; // the app's appId
CloudAppEvents
| where Timestamp > ago(30d)
| where OAuthAppId == appId
| summarize Events = count(), Accounts = dcount(AccountObjectId)
by ActionType
| order by Events descExpect: MailItemsAccessed or file access actions across the accounts that consented.
Decide: mail or files accessed: that is a data exposure for legal and the notification decision.
An attacker with an admin role can add a secret to an existing application instead of registering a new one.
AuditLogs
| where TimeGenerated > ago(30d)
| where OperationName has_any ("Add service principal credentials",
"Certificates and secrets management")
| project TimeGenerated, OperationName,
Actor = tostring(InitiatedBy.user.userPrincipalName),
App = tostring(TargetResources[0].displayName)Expect: only credentials your administrators added, each matched to a change.
Decide: any unexplained one: remove it and treat the actor as compromised (runbook 1).
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Consent audit records | Entra ID audit log | Query export |
| The application's properties and grants | Entra ID | The PowerShell output above, to file |
| The application's activity | Defender for Cloud Apps, unified audit log | CloudAppEvents query export |
Contain
Disable the service principal. Microsoft's playbook prefers disabling to deleting, because a deleted app can come back when another user consents again; once disabled it cannot get tokens or be consented to.
Update-MgServicePrincipal -ServicePrincipalId $sp.Id -AccountEnabled:$false
Remove-MgOauth2PermissionGrant -OAuth2PermissionGrantId 'Id from the grant list'Revoke the sessions of the users who consented if they also entered credentials. Then restrict user consent to verified publishers and low-impact permissions, or require the admin consent workflow.
Verify
// The disabled app should not be signing in
let appId = "00000000-0000-0000-0000-000000000000";
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(1d)
| where AppId == appId and ResultType == "0"
| project TimeGenerated, IPAddress, ResourceDisplayNameCommon mistakes
- Resetting the users' passwords and calling it done: the grant does not depend on the password.
- Deleting the app instead of disabling it.
- Missing tenant-wide consent because one user reported it.
A user reports a prompt asking an application called "Document Viewer" to read their mail. Step 1 shows eleven consents in two days, all for Mail.Read and offline_access; step 2 shows the application is registered in an unfamiliar tenant with a reply URL on a domain registered last week. Step 3 shows MailItemsAccessed for nine of the eleven users. The service principal is disabled, the grants removed, user consent restricted to verified publishers, and the nine mailboxes go to legal.
Before you close
- Is the app disabled, with its grants removed?
- Do you know what data it reached?
- Has user consent been restricted?
Hand off
- The application ID, publisher tenant, scopes and consent type.
- Users who consented, and data accessed.
- Consent settings changed as a result.
04Business email compromise and payment fraudHigh
Starts with: finance reporting changed bank details, a supplier asking about an invoice they never sent, or an inbox rule alert.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Ask finance immediately: has a payment been made, to which account, and when? Recall is time-critical and runs through the bank, not through you.
- Find out whether the fraudulent messages came from your mailbox or a lookalike domain; the containment differs.
- Start runbook 1 on the mailbox owner in parallel.
Steps
Pivot on the subject, the sender and the recipient from the finance report.
EmailEvents
| where Timestamp > ago(30d)
| where Subject has "invoice" or Subject has "bank details"
| where SenderFromDomain != RecipientDomain or EmailDirection == "Outbound"
| project Timestamp, SenderFromAddress, RecipientEmailAddress, Subject,
EmailDirection, DeliveryAction, NetworkMessageId
| sort by Timestamp ascExpect: outbound messages from the compromised mailbox, or inbound ones from a domain one character away from a supplier's.
Decide: lookalike domain only: your mailbox may be clean; block the domain and warn finance. Messages from your own mailbox: the account is compromised.
The usual pattern moves replies from the supplier or finance to an RSS, Archive or Conversation History folder and marks them read.
OfficeActivity
| where TimeGenerated > ago(30d)
| where Operation in ("New-InboxRule", "Set-InboxRule")
| where Parameters has_any ("MoveToFolder", "DeleteMessage", "MarkAsRead",
"ForwardTo", "RedirectTo")
| project TimeGenerated, UserId, ClientIP, ParametersExpect: a rule created shortly after the attacker's first sign-in.
Decide: export, then remove after step 3.
Mailbox audit records the items accessed. Read access to many messages in finance threads widens the notification question.
Connect-ExchangeOnline
$upn = 'compromised.user@yourdomain.com'
$end = Get-Date
$start = $end.AddDays(-30)
Search-UnifiedAuditLog -StartDate $start -EndDate $end -UserIds $upn `
-Operations MailItemsAccessed -ResultSize 5000 |
Export-Csv .\mailitemsaccessed.csv -NoTypeInformationExpect: access from the attacker's address to the threads with invoices and payments.
Decide: personal data in the threads: hand to legal for the notification decision.
BEC actors reply inside existing threads and sometimes pivot to the supplier's side.
let upn = "compromised.user@yourdomain.com";
EmailEvents
| where Timestamp > ago(30d)
| where SenderFromAddress =~ upn and EmailDirection == "Outbound"
| summarize Messages = count(),
Recipients = make_set(RecipientEmailAddress, 50) by bin(Timestamp, 1d)Expect: a spike in outbound mail to suppliers or customers around the fraud.
Decide: warn each recipient by phone, using numbers you already had.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| The fraudulent messages with headers | Mailboxes | One .eml each |
| Payment instructions and bank details | Finance | Copies, with the time each was received and actioned |
| Inbox rules as found | Exchange Online | Get-InboxRule to CSV |
| MailItemsAccessed records | Unified audit log (Audit Premium for the longer window) | The export above |
Contain
Call finance and the bank about any payment in flight. Contain the mailbox owner's account as in runbook 1, remove the rules and forwarding, and block the lookalike domain at the mail gateway.
Verify
let upn = "compromised.user@yourdomain.com";
let containedAt = datetime(2026-03-15T09:30:00Z);
OfficeActivity
| where TimeGenerated > containedAt
| where UserId =~ upn
| where Operation in ("New-InboxRule", "Set-InboxRule", "Set-Mailbox")Common mistakes
- Treating it as an IT ticket while the money moves.
- Replying to the fraudulent thread to warn people.
- Missing that mail was read, which can be a personal data breach in its own right.
A supplier calls asking why their invoice was paid to a new account. Step 1 finds the change request sent from the accounts payable manager's own mailbox; step 2 finds a rule moving the supplier's replies to Conversation History. Finance asks the bank to recall the payment within the hour. Step 3 shows the attacker read 140 messages in finance threads. The mailbox is contained, the rule removed, and every supplier in those threads is warned by phone.
Before you close
- Is the payment status known, and the bank engaged?
- Have suppliers and customers in the threads been warned by phone?
- Has legal seen what was read?
Hand off
- Payment status and bank reference, if any.
- The attacker's rules, sign-ins and the threads read.
- Suppliers and customers warned, by whom and when.
05Phishing campaign: scope, purge and containMedium
Starts with: a user reporting a message, a Defender for Office 365 alert, or a click on a malicious URL.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Keep one copy of the reported message before anything is purged.
- Pull the indicators: sender, subject, URLs, attachment hashes.
- Find out whether anyone entered credentials; those accounts go to runbook 1 straight away.
Steps
Search by sender and subject, then by the URL or hash, which catch variants.
let sender = "invoice@lookalike-domain.example";
EmailEvents
| where Timestamp > ago(14d)
| where SenderFromAddress =~ sender or Subject has "Payment overdue"
| summarize Recipients = dcount(RecipientEmailAddress),
Delivered = countif(DeliveryAction == "Delivered"),
Locations = make_set(DeliveryLocation) by NetworkMessageId, SubjectExpect: the campaign's size and how many copies reached inboxes.
Decide: more than a handful delivered: plan a purge.
Safe Links records each click; IsClickedThrough shows a user who reached the original URL.
let ids = EmailEvents
| where Timestamp > ago(14d)
| where SenderFromAddress =~ "invoice@lookalike-domain.example"
| distinct NetworkMessageId;
UrlClickEvents
| where Timestamp > ago(14d)
| where NetworkMessageId in (ids)
| project Timestamp, AccountUpn, Url, ActionType, IsClickedThroughExpect: a list of users, a few of whom clicked through.
Decide: everyone who clicked through: check for a sign-in from a new address in the next hour (runbook 1).
If the lure carried a file, find every device where it was written or run.
let badHash = "replace-with-the-sha256-of-the-sample";
DeviceFileEvents
| where Timestamp > ago(14d)
| where SHA256 == badHash
| summarize First = min(Timestamp), Paths = make_set(FolderPath) by DeviceNameExpect: devices where the file landed.
Decide: any device where it also ran: runbook 6.
Search and purge in Security & Compliance PowerShell needs the Search And Purge role. Compare the search count with the hunting count before purging; purged items cannot be restored.
Connect-IPPSSession -EnableSearchOnlySession
$q = '(From:invoice@lookalike-domain.example) AND (Subject:"Payment overdue")'
New-ComplianceSearch -Name 'phish-0412' -ExchangeLocation All -ContentMatchQuery $q
Start-ComplianceSearch -Identity 'phish-0412'
Get-ComplianceSearch -Identity 'phish-0412' | Select-Object Status, Items
New-ComplianceSearchAction -SearchName 'phish-0412' -Purge -PurgeType SoftDeleteExpect: the action completes; each run removes at most 10 items per mailbox.
Decide: Defender for Office 365 Plan 2: Microsoft points to email remediation in Threat Explorer instead.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| The message as a file | The reporter's mailbox | One .eml with headers, hashed |
| Recipient and click lists | Defender XDR | Query exports |
| URLs and attachment hashes | The message and EmailUrlInfo, EmailAttachmentInfo | In the case notes |
Contain
Block the sender, domain and URLs. Purge the message. Contain anyone who entered credentials or ran the attachment.
Verify
Re-run the recipient query: DeliveryLocation for the purged copies no longer shows the inbox, and no new copies arrived after the block.
Common mistakes
- Purging before keeping a copy.
- A purge search broader than the campaign.
- Forgetting the people who forwarded the message on.
Three users report the same "payment overdue" message. Step 1 finds 212 recipients, 198 delivered to the inbox. Step 2 finds 14 clicks, two through the warning. Both get session revocation and runbook 1; the message is purged after one copy is kept, and the sender and URL domains are blocked.
Before you close
- Is every copy purged, and every click accounted for?
- Are the senders and URLs blocked?
Hand off
- Indicators, recipient count, clicks, credential entries and devices.
- Blocks and purges done, with counts.
06Malware on an endpointHigh
Starts with: a Defender for Endpoint alert, an antivirus detection that was not fully remediated, or a user reporting strange behavior.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Collect the Defender investigation package from the device page, then isolate. Isolation ends the running state the package captures.
- Note the account logged on and whether it is privileged; a privileged account turns one host into a domain problem.
- Do not reboot, wipe or run a full scan that deletes files before collection.
Steps
The alert names one process. What launched it is usually the initial access; what it launched is the next stage.
let host = "ws-fin-042";
let t = datetime(2026-03-14T22:41:00Z); // alert time
DeviceProcessEvents
| where Timestamp between ((t - 10m) .. (t + 10m))
| where DeviceName =~ host
| project Timestamp, InitiatingProcessParentFileName,
InitiatingProcessFileName, FileName, ProcessCommandLine, AccountName,
SHA256
| sort by Timestamp ascExpect: a chain such as outlook.exe, then winword.exe, then powershell.exe with an encoded command.
Decide: note every binary hash and command line for the sweep in step 3.
Run keys, services and scheduled tasks written in the window.
let host = "ws-fin-042";
DeviceRegistryEvents
| where Timestamp > ago(7d)
| where DeviceName =~ host
| where RegistryKey has_any (@"CurrentVersion\Run", @"\Services\")
| where ActionType == "RegistryValueSet"
| project Timestamp, RegistryKey, RegistryValueName, RegistryValueData,
InitiatingProcessFileNameExpect: a value pointing at a binary in a user-writable folder.
Decide: any persistence found: it goes on the eradication list for every host the sweep finds.
A hash or address from one host is a question about every host.
let badIPs = dynamic(["203.0.113.42"]);
DeviceNetworkEvents
| where Timestamp > ago(30d)
| where RemoteIP in (badIPs)
| summarize First = min(Timestamp), Connections = count(),
Procs = make_set(InitiatingProcessFileName) by DeviceNameExpect: the same infrastructure contacted from other devices.
Decide: every device found enters this runbook.
If the account logged on to other hosts after the infection, the scope has moved.
let acct = "j.smith";
let since = datetime(2026-03-14T22:41:00Z);
DeviceLogonEvents
| where Timestamp > since
| where AccountName =~ acct and ActionType == "LogonSuccess"
| summarize First = min(Timestamp), Types = make_set(LogonType) by DeviceNameExpect: only the user's own workstation.
Decide: network or RDP logons elsewhere: runbook 7.
Native commands, run from a trusted path, written to removable media or a share.
:: Processes with services, then connections with owning process IDs
tasklist /svc
netstat -anob
:: Scheduled tasks in full, and who is logged on
schtasks /query /fo LIST /v
quserExpect: a process with an outbound connection that you cannot account for.
Decide: keep the output with the case and hash it.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Investigation package | Defender for Endpoint device page | Collect investigation package, before isolation |
| Memory image | The host | Live response or a memory acquisition tool, if the case may need it |
| The sample | Defender quarantine or the file path | Download through Defender, or copy and hash |
| Process, file and network timeline | Defender XDR | Query exports for the window |
Contain
Isolate in Defender for Endpoint (full isolation keeps the device talking to the Defender service). Contain the accounts that were logged on. Block the hash and the network indicators.
Rebuild when the attacker had administrative or SYSTEM control, or you cannot account for everything that ran; the rebuild or clean criteria are in the Incident Response reference.
Verify
// No further execution of the sample anywhere after containment
let badHash = "replace-with-the-sha256-of-the-sample";
let containedAt = datetime(2026-03-15T09:30:00Z);
DeviceProcessEvents
| where Timestamp > containedAt
| where SHA256 == badHash
| project Timestamp, DeviceName, AccountNameCommon mistakes
- Isolating before collecting.
- Closing it because antivirus quarantined the file while the dropper and the persistence remain.
- Not checking where the account went next.
Defender alerts on an encoded PowerShell command on a sales laptop. Step 1 shows outlook.exe, then winword.exe, then powershell.exe downloading a DLL; step 2 finds a Run key pointing at it in AppData. Step 3 finds the same download address contacted by two more laptops. The investigation packages are collected, all three are isolated, and step 4 shows the user's account went nowhere else.
Before you close
- Is every host with the file or the infrastructure in scope?
- Is there a rebuild or clean decision for each?
Hand off
- Hosts affected, the sample hash, the parent chain, persistence found.
- Accounts that were logged on.
- Rebuild or clean decision for each host, with the reason.
07Lateral movementHigh
Starts with: an alert for PsExec-style execution, remote WMI or WinRM, unusual RDP, or an account logging on to many hosts.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Identify the source host and the account. Both are compromised until shown otherwise.
- Map before you contain: containing one hop of a chain tells the attacker which hop you found.
- Check whether the account is privileged; if it is a domain admin, open runbook 8 as well.
Steps
Network logons cover file shares, remote services and remote management; RemoteInteractive is RDP.
let srcIP = "10.0.4.17";
DeviceLogonEvents
| where Timestamp > ago(14d)
| where RemoteIP == srcIP and ActionType == "LogonSuccess"
| where LogonType in ("Network", "RemoteInteractive")
| summarize First = min(Timestamp), Accounts = make_set(AccountName),
Types = make_set(LogonType) by DeviceName
| sort by First ascExpect: the hosts reached from the source, in order.
Decide: repeat from each host reached until no new hosts appear.
Remote services start under services.exe; WMI under WmiPrvSE.exe; PowerShell remoting under wsmprovhost.exe.
let targets = dynamic(["srv-file-01", "srv-app-02"]);
DeviceProcessEvents
| where Timestamp > ago(14d)
| where DeviceName in~ (targets)
| where InitiatingProcessFileName in~ ("services.exe", "wmiprvse.exe",
"wsmprovhost.exe", "mmc.exe")
| where FileName in~ ("cmd.exe", "powershell.exe", "rundll32.exe")
or FolderPath has @"\Windows\Temp\"
| project Timestamp, DeviceName, InitiatingProcessFileName, FileName,
ProcessCommandLine, AccountNameExpect: a shell or a binary from Windows\Temp under one of those parents.
Decide: the method tells you what to remove (service, task, WMI subscription).
Lateral movement usually follows or feeds credential theft.
DeviceProcessEvents
| where Timestamp > ago(14d)
| where (FileName =~ "rundll32.exe" and ProcessCommandLine has "comsvcs"
and ProcessCommandLine has "MiniDump")
or FileName in~ ("procdump.exe", "procdump64.exe")
or (FileName =~ "reg.exe" and ProcessCommandLine has "save")
| project Timestamp, DeviceName, AccountName, ProcessCommandLineExpect: nothing, or a dump on one of the hosts in the chain.
Decide: a dump: every account logged on to that host is compromised.
NewCredentials logons over NTLM from a process other than Windows itself are how pass-the-hash tools present a hash.
DeviceLogonEvents
| where Timestamp > ago(14d)
| where LogonType == "NewCredentials" and Protocol == "NTLM"
| where InitiatingProcessFileName !in ("services.exe", "lsass.exe")
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileNameExpect: none.
Decide: any: the account whose hash was used is compromised wherever it is used.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Logon events for every host in the chain | Defender XDR, Security logs | Query exports; wevtutil epl on hosts without Defender |
| The services, tasks and binaries used | Each target host | Investigation package per host |
| Memory from the host with credential theft | That host | Before isolation |
Contain
Contain in one window: isolate every host in the chain, disable the accounts used, and revoke their sessions. Reset the credentials of every account that was logged on to a host with credential theft.
Verify
let accounts = dynamic(["j.smith", "svc-backup"]);
let containedAt = datetime(2026-03-15T09:30:00Z);
DeviceLogonEvents
| where Timestamp > containedAt
| where AccountName in~ (accounts) and ActionType == "LogonSuccess"Common mistakes
- Containing the first host found and letting the attacker use the rest.
- Resetting only the account that alerted, not the ones dumped from memory.
An alert flags PsExec on a file server. Step 1, from the source workstation, shows network logons to four servers in 20 minutes; step 2 finds a service under services.exe running from Windows\Temp on each; step 3 finds a comsvcs MiniDump of LSASS on one of them, where a backup service account was logged on. All five hosts are isolated in one window, and the backup account is reset with the domain admin who used the workstation.
Before you close
- Is the chain mapped to its end?
- Is every exposed credential reset?
Hand off
- The chain, host by host, with times and methods.
- Accounts used and their privilege.
- Hosts with credential theft, and the accounts exposed on each.
08Active Directory privilege escalation: Kerberoasting, DCSync, privileged groupsCritical
Starts with: a Defender for Identity alert (Kerberoasting, DCSync, suspicious group change), a 4769 RC4 spike, or a privileged group change nobody requested.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Assume the worst case until shown otherwise: if DCSync is confirmed, every domain credential, including krbtgt, is in the attacker's hands.
- Move to out-of-band communication; mail and chat may be readable.
- Do not reset krbtgt or mass-reset passwords yet. Eviction is planned and run in one window.
Steps
A replication right used by an account that is not a domain controller.
let repl = dynamic(["1131f6aa-9c07-11d1-f79f-00c04fc2dcd2",
"1131f6ad-9c07-11d1-f79f-00c04fc2dcd2",
"89e95b76-444d-4c62-991a-0facbeda640c"]);
SecurityEvent
| where TimeGenerated > ago(30d)
| where EventID == 4662 and Properties has_any (repl)
| where not(SubjectUserName endswith "$")
| project TimeGenerated, Computer, SubjectUserName, SubjectDomainNameExpect: nothing. Any row is an account pulling password hashes from a domain controller.
Decide: confirmed DCSync: plan full domain eviction, including krbtgt.
RC4 service tickets for many user-account services, and TGTs issued without pre-authentication.
SecurityEvent
| where TimeGenerated > ago(7d)
| where EventID == 4769
| parse EventData with * 'TicketEncryptionType">' Enc '<' *
| parse EventData with * 'ServiceName">' Svc '<' *
| where Enc == "0x17" and not(Svc endswith "$")
| summarize Services = dcount(Svc), Names = make_set(Svc, 20)
by TargetUserName, IpAddress
| where Services >= 5Expect: the requesting account and source address, and the service accounts targeted.
Decide: every targeted service account is a password reset; long, random passwords make the stolen tickets useless.
Additions to Domain Admins, Enterprise Admins, Schema Admins and Administrators.
SecurityEvent
| where TimeGenerated > ago(30d)
| where EventID in (4728, 4732, 4756)
| where TargetUserName in ("Domain Admins", "Enterprise Admins",
"Schema Admins", "Administrators")
| project TimeGenerated, Computer, Group = TargetUserName, MemberName,
AddedBy = SubjectUserNameExpect: only changes that match change records.
Decide: any other: the account that made it is compromised.
This is the baseline you compare against after eviction.
'Domain Admins', 'Enterprise Admins', 'Schema Admins' | ForEach-Object {
Get-ADGroupMember -Identity $_ -Recursive |
Select-Object @{ n = 'Group'; e = { $_ } }, SamAccountName, ObjectClass
}
Get-ADUser -Identity krbtgt -Properties PasswordLastSet, msDS-KeyVersionNumber |
Select-Object PasswordLastSet, msDS-KeyVersionNumberExpect: the membership list and the date krbtgt was last reset.
Decide: krbtgt never reset since the domain was built: expect the cipher issue CISA warns of.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Domain controller Security logs | Every DC | wevtutil epl Security, hashed, before any change |
| Privileged group membership | Active Directory | The PowerShell output above, to file |
| Images of the admin workstations used | Those hosts | Investigation package and disk image |
Contain
Disable the compromised admin accounts. Remove unauthorized group members. Reset targeted service accounts.
Reset krbtgt twice: Microsoft's forest recovery guide says to wait at least 10 hours between the resets (the default maximum ticket lifetime, longer if yours is longer); CISA adds that replication should be healthy before the first reset and replicated before the second.
:: Before and after each reset, read krbtgt's Password last set
net user krbtgt /domainVerify
let containedAt = datetime(2026-03-15T09:30:00Z);
SecurityEvent
| where TimeGenerated > containedAt
| where EventID in (4728, 4732, 4756, 4662)
| project TimeGenerated, Computer, EventID, SubjectUserName, TargetUserNameCommon mistakes
- Resetting krbtgt once, or twice in quick succession.
- Resetting passwords while the attacker can still read them.
- Rebuilding without finding how they got privileged access.
Defender for Identity reports replication from a workstation. Step 1 confirms 4662 with DS-Replication-Get-Changes-All by a helpdesk account at 02:10. Every domain credential is now assumed stolen. The team moves to a phone bridge, rebuilds the admin workstations, and runs the eviction in one window: privileged accounts and service accounts reset, the helpdesk account disabled, and krbtgt reset twice with the wait between.
Before you close
- Was krbtgt reset twice with the wait?
- Is the initial access found and closed?
Hand off
- Accounts with replication rights used, tickets requested, group changes.
- krbtgt reset times.
- The eviction plan, step by step, with owners.
09Ransomware, before and after encryptionCritical
Starts with: files being renamed or encrypted, a ransom note, shadow copy deletion, or an alert for ransomware behavior.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Isolate affected hosts now; whole subnets at the switch if several are hit. Power off only a host you cannot disconnect, because that loses memory (CISA's checklist).
- Protect the backups first: take them offline or confirm they are immutable.
- Move to out-of-band communication.
- Tell legal and the executive sponsor; the ransom and notification questions start now.
Steps
Mass renames by one process are the signal.
DeviceFileEvents
| where Timestamp > ago(1d)
| where ActionType == "FileRenamed"
| summarize Renamed = count(), Last = max(Timestamp)
by DeviceName, InitiatingProcessFileName, bin(Timestamp, 5m)
| where Renamed >= 200
| order by Last descExpect: the devices and the process doing the renaming, with the latest time.
Decide: renames still increasing: isolate those devices before reading further.
Operators delete shadow copies and disable recovery shortly before encrypting.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where (FileName =~ "vssadmin.exe" and ProcessCommandLine has "delete")
or (FileName =~ "wmic.exe" and ProcessCommandLine has "shadowcopy")
or (FileName =~ "wbadmin.exe" and ProcessCommandLine has "delete")
or (FileName =~ "bcdedit.exe"
and ProcessCommandLine has "recoveryenabled")
| project Timestamp, DeviceName, AccountName, ProcessCommandLineExpect: the account and host used to run them, often a domain admin from one host.
Decide: that account and host are the operator's: they lead to the initial access.
Most operators take data first. Look for sync tools and large transfers in the days before.
DeviceProcessEvents
| where Timestamp > ago(14d)
| where FileName in~ ("rclone.exe", "megacmd.exe", "winscp.exe")
or ProcessCommandLine has_any ("rclone copy", "rclone sync")
| project Timestamp, DeviceName, AccountName, ProcessCommandLineExpect: a sync tool on a file server in the days before encryption.
Decide: data taken: this is also a breach for legal.
On a host that is isolated but not yet rebuilt, list what is left.
vssadmin list shadowsExpect: none, usually.
Decide: any left: protect them, they may restore data without the attacker.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| A system image and memory from a sample of affected hosts | Those hosts | Before rebuild (CISA lists these first) |
| The ransom note and samples of encrypted files | Affected hosts | Copies, hashed |
| The payload binary | Defender, or the path from step 1 | Collected through Defender |
| Security logs from domain controllers | Every DC | Before eviction |
Contain
Isolate, disable the accounts used, and disable VPN, remote access and single sign-on paths the operator could use. CISA advises resetting passwords only once the environment is cleaned and rebuilt, so an operator still holding the domain does not collect the new ones. Report to CISA, the FBI or IC3, and ask law enforcement about decryptors.
Recover from offline or immutable backups in the business order agreed beforehand, checking each restore for persistence before it reconnects. If the domain was compromised, follow runbook 8 for the eviction.
Verify
Re-run step 1 hourly until the rename counts stay at zero across the estate.
Common mistakes
- Restoring onto infrastructure the operator still controls.
- Wiping hosts before collecting evidence.
- Missing the data theft because the encryption is louder.
At 03:40 the monitoring shows hundreds of renames on two file servers. Step 1 shows one process renaming files on both; they are isolated within minutes. Step 2 shows vssadmin delete shadows run from a jump host at 03:31 by a domain admin account; step 3 finds rclone on one file server two days earlier. The backups are confirmed immutable, legal and the executive sponsor are told, the domain admin goes to runbook 8, and CISA and the FBI are informed.
Before you close
- Is encryption stopped everywhere?
- Is data theft ruled in or out, with evidence?
- Are restores checked for persistence before reconnection?
Hand off
- Hosts affected and encryption timeline.
- Initial access and the operator's accounts.
- Data taken, if any.
- Backup status and restore plan.
- Reports made to law enforcement.
10Data exfiltration and insider casesHigh
Starts with: a DLP alert, a large or unusual download, a departing employee report, or a sharing link created to outside parties.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- For an insider case: confirm HR and legal authorized the investigation, and work within that scope.
- Do not contact the person or change their access until legal agrees; tip-off destroys evidence.
- Set a legal hold on the person's mailbox and OneDrive if counsel asks.
Steps
Count distinct files per hour, not events.
let upn = "departing.user@yourdomain.com";
OfficeActivity
| where TimeGenerated > ago(30d)
| where UserId =~ upn
| where Operation in ("FileDownloaded", "FileSyncDownloadedFull",
"FileCopied")
| summarize Files = dcount(SourceFileName), Sites = make_set(Site_Url, 10)
by bin(TimeGenerated, 1h)
| where Files > 50Expect: a spike well above the person's normal week.
Decide: name the sites and libraries for the data owner.
Anonymous links and invitations to external addresses.
let upn = "departing.user@yourdomain.com";
OfficeActivity
| where TimeGenerated > ago(30d)
| where UserId =~ upn
| where Operation in ("AnonymousLinkCreated", "SharingInvitationCreated",
"AddedToSecureLink")
| project TimeGenerated, Operation, SourceFileName, TargetUserOrGroupNameExpect: links to personal addresses or anonymous links on sensitive files.
Decide: remove the links once evidence is kept.
USB writes and personal cloud clients.
let host = "ws-sales-017";
DeviceEvents
| where Timestamp > ago(30d)
| where DeviceName =~ host
| where ActionType in ("UsbDriveMounted", "PnpDeviceConnected")
| project Timestamp, ActionType, AdditionalFieldsExpect: drives mounted around the time of the downloads.
Decide: pair with file events on the drive letter.
Mail to the person's own personal address is a common route.
let upn = "departing.user@yourdomain.com";
EmailEvents
| where Timestamp > ago(30d)
| where SenderFromAddress =~ upn and EmailDirection == "Outbound"
| where RecipientDomain in~ ("gmail.com", "outlook.com", "yahoo.com",
"proton.me", "icloud.com")
| project Timestamp, RecipientEmailAddress, Subject, AttachmentCountExpect: messages with attachments to personal domains.
Decide: list the attachments for the data owner.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Audit records of access, download and sharing | Unified audit log | Search-UnifiedAuditLog export |
| Mailbox and OneDrive content | Microsoft 365 | Legal hold, set before any change |
| Endpoint file and device events | Defender XDR | Query exports |
| DLP alerts | Microsoft Purview | Alert export |
Contain
Remove sharing links and external access, and block the destination, at the moment legal and HR agree. For a departure, remove access at the time of leaving, and recover company devices.
Verify
Re-run steps 1 and 2 after the access change: no further downloads or new links.
Common mistakes
- Confronting the person before evidence is preserved.
- Estimating the volume instead of measuring it.
- Leaving legal out until the end.
HR reports a resignation from a sales lead going to a competitor. With legal's authorization, step 1 shows 1,800 files downloaded from the CRM export library in the last week, against fewer than 50 in a normal week; step 4 shows four messages with attachments to a personal address. Legal decides the timing; access is removed at the exit meeting and the findings go to counsel.
Before you close
- Is the volume measured, not estimated?
- Has counsel the list of data affected?
Hand off
- Data affected, how much, through which channel, and whether any is personal or regulated.
- Who authorized the investigation and its scope.
- Actions taken and when.
11Azure subscription compromiseCritical
Starts with: a Defender for Cloud alert, an unexpected role assignment, a resource you did not create (often compute for mining), or a deleted diagnostic setting.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Find out which identity is acting: a user, a service principal or a managed identity. Contain that identity in Entra ID first; Azure access follows it.
- Export the Azure activity log for the subscription before changing anything.
- Check that diagnostic settings still send logs to your workspace; if they were deleted, that is part of the incident.
Steps
Every create, update, delete and action on resources is in AzureActivity.
let caller = "attacker@yourdomain.com"; // or a service principal ID
AzureActivity
| where TimeGenerated > ago(30d)
| where Caller =~ caller
| where OperationNameValue endswith "/WRITE"
or OperationNameValue endswith "/DELETE"
or OperationNameValue endswith "/ACTION"
| summarize Count = count(), First = min(TimeGenerated)
by OperationNameValue, ResourceGroup
| order by First ascExpect: the sequence of what was changed, starting with the first write.
Decide: role assignments, run commands or diagnostic setting deletes: follow steps 2 to 4.
Owner or User Access Administrator on a subscription is control of everything in it.
AzureActivity
| where TimeGenerated > ago(30d)
| where OperationNameValue =~
"MICROSOFT.AUTHORIZATION/ROLEASSIGNMENTS/WRITE"
| where ActivityStatusValue in ("Success", "Succeeded")
| project TimeGenerated, Caller, CallerIpAddress, _ResourceId, PropertiesExpect: assignments that match change records only.
Decide: any other: remove it after recording it.
Run Command executes a script on the VM through the control plane.
AzureActivity
| where TimeGenerated > ago(30d)
| where OperationNameValue has "RUNCOMMAND"
| project TimeGenerated, Caller, CallerIpAddress, _ResourceId,
ActivityStatusValueExpect: none, or ones you can explain.
Decide: any VM a command ran on: treat it as compromised (runbook 6 or 13).
Deleted diagnostic settings blind every rule that reads resource logs.
AzureActivity
| where TimeGenerated > ago(30d)
| where OperationNameValue has "DIAGNOSTICSETTINGS"
| project TimeGenerated, Caller, OperationNameValue, _ResourceIdExpect: only your own deployments.
Decide: a delete: restore the setting and note the gap in coverage.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Azure activity log for the subscription | Azure Monitor | Export, or the AzureActivity query results |
| Resource logs (Key Vault, storage) | Log Analytics, if diagnostic settings were on | Query exports |
| VM disks for any VM a command ran on | Azure | Snapshot the disk before rebuild |
Contain
Disable the user or service principal in Entra ID and revoke its sessions (runbook 1 or 3). Remove the role assignments the attacker made. Stop and snapshot, then delete, resources they created. Restore diagnostic settings.
Verify
let caller = "attacker@yourdomain.com";
let containedAt = datetime(2026-03-15T09:30:00Z);
AzureActivity
| where TimeGenerated > containedAt
| where Caller =~ callerCommon mistakes
- Removing the resources and leaving the role assignment that created them.
- Containing the user but not the service principal they added a secret to.
- Not checking for a gap in logging during the attack.
Defender for Cloud alerts on a cryptocurrency miner. Step 1 shows a developer's account created 60 virtual machines across three Regions in an hour; step 2 shows it granted itself Owner on the subscription the day before; step 4 shows a diagnostic setting deleted first. The account is contained in Entra ID, the role assignment removed, the machines snapshotted and deleted, and the diagnostic setting restored.
Before you close
- Is every identity the attacker used contained?
- Is logging restored, and the gap recorded?
Hand off
- The acting identities, role assignments, resources created and VMs touched.
- Logging gaps, with times.
- Cost impact, for the business.
12AWS access key compromiseCritical
Starts with: a GuardDuty finding, an AWS abuse notice about an exposed key, CloudTrail activity from an unfamiliar address, or an unexpected bill.
The decisions behind this runbook are in the Incident Response reference playbook.
First 15 minutes
- Identify the key ID and the IAM user or role it belongs to.
- Check how the key was used before deactivating it: the investigation needs its last-used information, which deleting removes.
- Check every Region: attackers launch resources where you do not normally look.
Steps
Group by source address and user agent to separate the owner's use from the attacker's.
let keyId = "AKIAIOSFODNN7EXAMPLE";
AWSCloudTrail
| where TimeGenerated > ago(30d)
| where UserIdentityAccessKeyId == keyId
| summarize First = min(TimeGenerated), Calls = count(),
Events = make_set(EventName, 50) by SourceIpAddress, UserAgent
| sort by First ascExpect: the owner's normal pattern and a second address with enumeration and identity calls.
Decide: identity changes (step 2) or launches (step 3) decide the eradication scope.
New users, keys, login profiles, policies and roles.
AWSCloudTrail
| where TimeGenerated > ago(30d)
| where EventName in ("CreateUser", "CreateAccessKey",
"CreateLoginProfile", "UpdateLoginProfile", "AttachUserPolicy",
"PutUserPolicy", "CreateRole", "UpdateAssumeRolePolicy")
| project TimeGenerated, EventName, UserIdentityArn, SourceIpAddress,
RequestParametersExpect: none outside your provisioning.
Decide: each one is an eradication item.
Compute launched in bulk, often in unused Regions, is the mining pattern.
let keyId = "AKIAIOSFODNN7EXAMPLE";
AWSCloudTrail
| where TimeGenerated > ago(30d)
| where UserIdentityAccessKeyId == keyId
| where EventName in ("RunInstances", "CreateFunction20150331",
"CreateBucket", "ModifySnapshotAttribute")
| project TimeGenerated, EventName, AWSRegion, RequestParametersExpect: the Regions and resources to remove.
Decide: snapshot sharing: data has left; tell legal.
From a trusted session, list the user's keys and when each was last used.
aws iam list-access-keys --user-name the-key-owner
aws iam get-access-key-last-used --access-key-id AKIAIOSFODNN7EXAMPLE
aws cloudtrail lookup-events --lookup-attributes \
AttributeKey=AccessKeyId,AttributeValue=AKIAIOSFODNN7EXAMPLEExpect: the key's last service and Region.
Decide: proceed to containment.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| CloudTrail events for the key | CloudTrail (and your trail in S3) | Query export; lookup-events output |
| IAM state: users, keys, policies | IAM | CLI output to file |
| Snapshots of any compromised instance | EC2 | Snapshot before terminating |
Contain
AWS's guidance: create a replacement key, deactivate the original, confirm the applications work, then delete it. Deactivation is reversible.
aws iam update-access-key --access-key-id AKIAIOSFODNN7EXAMPLE \
--status Inactive --user-name the-key-owner
# Stop the user acting at all while you investigate
aws iam attach-user-policy --user-name the-key-owner \
--policy-arn arn:aws:iam::aws:policy/AWSDenyAllDelete the users, keys, roles and policies the attacker created, and the resources in every Region, after keeping what the investigation needs. Enable MFA on the root user.
Verify
let keyId = "AKIAIOSFODNN7EXAMPLE";
let containedAt = datetime(2026-03-15T09:30:00Z);
AWSCloudTrail
| where TimeGenerated > containedAt
| where UserIdentityAccessKeyId == keyId and isempty(ErrorCode)Common mistakes
- Deleting the key before reading its activity.
- Checking only your usual Region.
- Missing a second key or login profile the attacker created.
AWS sends an abuse notice: a key was found in a public repository. Step 1 shows the key used from an unfamiliar address for ListBuckets and DescribeInstances; step 2 shows CreateUser and CreateAccessKey for a new user; step 3 shows RunInstances in a Region the company does not use. The key is deactivated, the new user and its key deleted, the instances snapshotted and terminated, and the repository history cleaned.
Before you close
- Is the key deactivated and every attacker-created identity removed?
- Have all Regions been checked?
Hand off
- Key ID, owner, first and last malicious use.
- Identity changes and resources created, by Region.
- Data shared out, if any.
13Linux server compromise: SSH and web serverHigh
Starts with: an EDR or Defender for Endpoint Linux alert, unexpected outbound connections, a web shell alert, or an SSH login from an unknown address.
First 15 minutes
- Collect volatile state before anything else: processes, connections, logged-in users.
- Do not reboot; a running process may exist only in memory, its binary deleted from disk.
- Work from a trusted shell, and write output to another host or to removable media.
Steps
The process tree, listening and established sockets with their processes, and who is logged in.
ps -eo pid,ppid,user,lstart,cmd --forest
ss -tanp
ss -uanp
last -F -xExpect: a shell or interpreter under the web server user, or a connection out to an address you do not recognize.
Decide: note each suspicious PID for step 2.
A process's executable stays readable through /proc while it runs, even if deleted from disk.
ls -l /proc/4242/exe
sha256sum /proc/4242/exe
cp /proc/4242/exe /mnt/evidence/pid4242.binExpect: a path, or a path marked (deleted).
Decide: a deleted binary that is still running is a strong indicator.
OpenSSH logs accepted logins at the default log level with the method and key fingerprint.
journalctl -u ssh --since "2026-03-13" --no-pager | grep -E "Accepted"
grep -E "Accepted|Invalid user" /var/log/auth.logExpect: the attacker's address with "Accepted publickey" or "Accepted password".
Decide: publickey from an unknown address: check authorized_keys in step 4.
Keys, cron, systemd units and timers, and recently changed executables.
cat /root/.ssh/authorized_keys
crontab -l -u www-data
systemctl list-timers --all
find / -xdev -type f -newermt "2026-03-13" -perm -u+xExpect: a key or cron entry you did not add, a new unit, or executables written in the window.
Decide: each item goes on the eradication list.
Files written by the web server user in the window are the web shells.
find /var/www -type f -newermt "2026-03-13" -name "*.php"Expect: a file the deployment process did not write.
Decide: keep it, then find the request that wrote it in the access log.
Evidence to secure
| Evidence | Where it is | How to collect it |
|---|---|---|
| Volatile output from step 1 | The host | Saved to another host, hashed |
| Running binaries | /proc/<pid>/exe | Copied and hashed as in step 2 |
| Authentication logs | journald and /var/log/auth.log (or /var/log/secure) | Copied with the journal files |
| Web server access logs | /var/log/nginx or /var/log/apache2 | Copied for the window |
| Memory, if the case needs it | The host | AVML or LiME (see the Linux forensic artifacts reference) |
Contain
Block the attacker's address at the host firewall or the cloud security group, lock the accounts used, and remove unauthorized keys, after keeping copies.
iptables -I INPUT -s 203.0.113.42 -j DROP
usermod -L compromised
passwd -l compromisedRebuild a server where the attacker had root; cleaning a root compromise relies on finding everything.
Verify
Re-run step 3 and step 1 after containment: no new logins from the address, no connection to it.
Common mistakes
- Rebooting before capturing volatile state.
- Trusting binaries on a host where the attacker had root; use static tools from removable media.
- Removing the web shell without finding the vulnerability that let it be written.
Outbound connections from a web server to an unknown address on port 4444 trigger an alert. Step 1 shows /bin/sh under the web server user with a connection to that address; step 2 shows its binary marked deleted; step 5 finds a PHP file written to an upload folder an hour earlier. The process binary and logs are kept, the address is blocked, and the server is rebuilt from its image with the upload vulnerability fixed.
Before you close
- Is the access method found and fixed?
- Was the server rebuilt, or is cleaning justified?
Hand off
- Access method, accounts, addresses, persistence found.
- Binaries kept, with hashes.
- Rebuild decision and the vulnerability to fix.
From running a runbook to leading the investigation
Microsoft Cloud Incident Response takes these incidents through a full investigation across Microsoft 365, Entra ID and Sentinel: scoping, forensic analysis, containment, notification and the post-incident review.
Read the first module free →Weekly security engineering insights
Detection techniques, architecture patterns, and operational judgment, every Tuesday.
No spam. Unsubscribe anytime.