Azure Automation and Logic Apps are the two most common "serverless" execution surfaces in an Azure tenant, and both run under a workload identity that usually holds far more privilege than the human who triggers them. An attacker who gains write access to an Automation account can import an arbitrary PowerShell or Python runbook, publish it, and start a job that executes under the account's managed identity — no interactive sign-in, no user MFA, no Conditional Access. The same account can be turned into durable persistence by attaching a webhook (an unauthenticated HTTPS trigger reachable from anywhere on the internet) or a recurring schedule that re-creates a backdoor on a cron cadence long after the attacker's original credentials are revoked.
This SOP treats a runbook or Logic App write outside a change window as a SEV1 candidate: the same primitives that automate patching also automate credential theft and role escalation. Key data sources: AzureActivity (management-plane runbook/webhook/schedule/workflow writes and role assignments), AzureDiagnostics (JobLogs / JobStreams runbook output, Logic App WorkflowRuntime), and AuditLogs (Entra role grants to the managed identity or service principal). MITRE ATT&CK: T1648 Serverless Execution, T1546 Event Triggered Execution, T1098.003 Additional Cloud Roles.
☰ Table of Contents
01 — BACKGROUND
TECHNIQUE OVERVIEWAn Azure Automation account is a hosted job engine: it stores runbooks (PowerShell, PowerShell Workflow, or Python scripts), executes them on Microsoft-managed sandboxes or a Hybrid Runbook Worker, and authenticates to Azure and Microsoft Graph using either a legacy Run As service principal or, on modern accounts, a system- or user-assigned managed identity. Because operators grant these identities broad rights so automation "just works" — frequently Contributor at subscription scope, sometimes Owner or User Access Administrator — the identity behind a runbook is often more privileged than any single human. Logic Apps follow the same pattern: a low-code workflow with an HTTP-request trigger and a managed identity that can reach Key Vault, Storage, or Exchange Online through built-in connectors.
Three properties make these services attractive to an intruder. First, execution is non-interactive — a runbook job or a workflow run produces no user sign-in, bypassing MFA and most Conditional Access. Second, they are natively persistent — a webhook or schedule keeps firing after the human credential is burned. Third, the output surface (JobStreams) is often not monitored, so credential dumps and role grants performed inside a runbook go unseen unless diagnostic logging is enabled and shipped to the SIEM.
| Field | Value |
|---|---|
| MITRE Technique | T1648 — Serverless Execution T1546 — Event Triggered Execution (webhook / schedule trigger) T1098.003 — Account Manipulation: Additional Cloud Roles (managed-identity grant) T1078.004 — Valid Accounts: Cloud Accounts (identity re-use) |
| Kill-chain Phase | Execution · Persistence · Privilege Escalation |
| Primary Log Source | AzureActivity (management plane), AzureDiagnostics (JobLogs / JobStreams, WorkflowRuntime) |
| Secondary Log Sources | AuditLogs (Entra role grants to SP/MI), AADServicePrincipalSignInLogs (MI token use), MicrosoftGraphActivityLogs |
| Resource Providers | Microsoft.Automation, Microsoft.Logic, Microsoft.Authorization |
| Default Severity | SEV1 candidate — runbook/workflow write outside a change window; webhook creation = confirmed persistence |
| Detection Window | 24 hours for execution; extend webhook/schedule/role-grant hunts to 7–30 days |
Common attack paths
| # | Path | What the analyst sees |
|---|---|---|
| A1 | Malicious runbook execution — attacker imports/edits a runbook, publishes, starts a job; code runs under the MI to enumerate, dump Key Vault, or add a role | runbooks/write + runbooks/publish/action + jobs/write in quick succession; JobStreams containing Get-AzKeyVaultSecret / New-AzRoleAssignment |
| A2 | Webhook persistence — attacker creates a webhook on a runbook; the URL triggers execution over unauthenticated HTTPS from anywhere | webhooks/write; later jobs with no corresponding interactive caller |
| A3 | Schedule persistence — a recurring schedule re-runs a backdoor runbook (re-adds an admin, re-grants a role) on a cron cadence | schedules/write + jobSchedules/write linking schedule → runbook |
| A4 | Managed-identity privilege grant — attacker grants the Automation MI Owner/Contributor/UAA so the runbook can do anything | roleAssignments/write to the MI object ID; AuditLogs "Add app role assignment to service principal" |
| A5 | Logic App workflow abuse — HTTP-triggered Logic App with a Key Vault / Office 365 connector exfiltrates secrets or mail under the workflow MI | Microsoft.Logic/workflows/write; WorkflowRuntime trigger from an unexpected client IP |
A managed identity is a machine account with no MFA and, by default, no Conditional Access. A runbook that adds a role assignment to itself or to a new principal is silent privilege escalation — treat any roleAssignments/write initiated from an Automation context as CRITICAL until proven part of a documented deployment.
02 — IDENTIFICATION
6 INDICATORS + IOCAnswer these five questions before running deep queries. Any single YES in rows 1–4 pushes this to active investigation; row 5 sets your urgency ceiling.
- 1Was a runbook, webhook, schedule, or Logic App workflow written outside a known deployment window? Cross-check your change calendar / CI pipeline for a matching release.
- 2Did the same principal that wrote the runbook also start a job and/or grant a role? Write → publish → run → role-grant in one short burst is the classic abuse chain.
- 3Is the caller a human user rather than a deployment service principal? A named user hand-editing production automation at 02:00 is an outlier; a pipeline SP is expected.
- 4Is the CallerIpAddress a new / non-corporate / cloud-hosting IP or a Tor/anonymiser ASN? Pivot to SOP-36 for anonymiser confirmation.
- 5What is the blast radius of the identity? Determine the Automation account MI / Run As role scope now — Owner or Contributor at subscription scope makes this CRITICAL regardless of the observed action.
Before anything else, call the Automation account owner listed on the resource tags. Ninety percent of "runbook changed" alerts are a scheduled deployment; the fast confirmation is a human who says "yes, that was my release at 14:00." No owner answer within the SLA = treat as unauthorised and proceed.
The abuse chain begins with getting attacker code into the account. An attacker imports a new runbook or edits the draft of an existing one, then publishes it so it becomes runnable. A write-then-publish pair on a production runbook by a human user, with no matching change ticket, is the first high-signal event.
- 1Open Microsoft Sentinel → Logs (or Log Analytics → Logs) and confirm the AzureActivity table is receiving data for the affected subscription.
- 2Run the KQL below over the last 24 hours. For each hit note Caller, CallerIpAddress, and the target runbook in
_ResourceId. - 3In parallel open Automation Accounts → [account] → Runbooks, click the runbook, and review the Source control / Modified timestamp and the runbook body for suspicious cmdlets.
- 4Correlate the write time against your change / release calendar. A publish with no ticket and a human caller is a confirmed anomaly — move to I2.
| Operation (OperationNameValue) | Meaning | Severity |
|---|---|---|
| .../RUNBOOKS/DRAFT/WRITE | Runbook draft content written / replaced — code staged | HIGH |
| .../RUNBOOKS/WRITE | Runbook object created or updated | HIGH |
| .../RUNBOOKS/PUBLISH/ACTION | Draft promoted to published — now executable | CRITICAL |
| .../RUNBOOKS/DRAFT/CONTENT/WRITE | Raw script content of the draft modified | CRITICAL |
The runbook body is only visible in AzureActivity as an operation name, not as content — the actual script is not in the log. You must open the runbook in the portal (or export it via Export-AzAutomationRunbook) to read what it does. Never verdict on the operation name alone.
Writing a runbook is harmless until it runs. A jobs/write event starts execution under the account's managed identity. The job's output — captured in AzureDiagnostics JobStreams when diagnostic logging is enabled — is where you actually see what the code did: secret reads, role grants, outbound web calls, or credential material.
- 1Open Automation Accounts → [account] → Jobs. Sort by Start time and locate jobs correlating to the I1 write. Click a job → All Logs / Output / Error / Streams.
- 2If the account has diagnostic settings shipping to Log Analytics, run the JobStreams KQL below to pull output centrally without per-job clicking.
- 3Read the output for high-risk cmdlets —
Get-AzKeyVaultSecret,New-AzRoleAssignment,Add-AzADGroupMember,Invoke-WebRequest,Invoke-RestMethod,DownloadString, base64 blobs. - 4Note the RunOn target — a job forced onto a Hybrid Runbook Worker can pivot into on-prem or a VNet the sandbox cannot reach.
| Output Signal (in JobStreams) | Meaning | Severity |
|---|---|---|
| Get-AzKeyVaultSecret / listKeys | Runbook is dumping Key Vault secrets or storage keys | CRITICAL |
| New-AzRoleAssignment | Runbook is granting RBAC roles — self-escalation | CRITICAL |
| Add-AzADGroupMember / New-AzADUser | Directory manipulation — backdoor account/group | CRITICAL |
| Invoke-WebRequest / DownloadString | Outbound fetch of a second-stage payload or exfil | HIGH |
| [Convert]::FromBase64String | Encoded payload being decoded in-runbook | HIGH |
If AzureDiagnostics returns nothing, the account almost certainly has no diagnostic setting shipping JobStreams — the output is invisible to the SIEM. Do not read "0 hits" as "clean." Read the job output directly in the portal and enable diagnostic logging as a permanent fix (see Eradication).
A webhook is an HTTPS URL containing a token that starts a runbook when called — with no Azure authentication. Anyone holding the URL can trigger the runbook from anywhere on the internet, and the URL secret is only shown once at creation. A webhook on a sensitive runbook is durable persistence that survives revocation of the attacker's Azure credentials.
- 1Run the KQL below over the last 7 days — webhook creation is rare, so any hit warrants review.
- 2Open Automation Accounts → [account] → Webhooks and review each webhook's linked runbook, expiry date, and creation time.
- 3A webhook pointing at a newly-written runbook (I1), or with a far-future expiry, or created by a human off-hours, is a confirmed persistence artifact — disable it in Containment.
- 4Correlate webhook-triggered jobs: jobs in the Jobs list with no interactive caller and a source of "Webhook" indicate the trigger has already fired.
Webhook URLs are secrets that Azure never shows again after creation. You cannot "read" an existing webhook's URL to confirm it is compromised — assume any unauthorised webhook is leaked and delete it. Deleting the webhook invalidates the URL immediately.
A schedule linked to a runbook re-runs it automatically — hourly, daily, or on a custom cadence. An attacker uses this to make a backdoor self-healing: even if you remove a rogue admin or role, the scheduled runbook re-creates it on the next tick. Detecting the schedule link (jobSchedules/write) is what stops the whack-a-mole.
- 1Run the KQL below over the last 7 days for schedule and job-schedule writes.
- 2Open Automation Accounts → [account] → Schedules; for each schedule check Linked runbooks and the recurrence.
- 3A new schedule linked to a suspect runbook (I1), a high-frequency recurrence (every hour), or an odd start time is a persistence signal.
- 4Cross-reference with I3 — attackers frequently attach both a webhook and a schedule for redundancy.
The power of runbook abuse scales with the identity behind it. An attacker either grants the Automation account's managed identity a high RBAC role (so its runbooks can do anything) or grants an Entra directory role / app-role to the underlying service principal. A roleAssignments/write naming the Automation MI object ID, or an AuditLogs role-add to a service principal, is the privilege-escalation event.
- 1Run both KQL queries below: the AzureActivity query catches Azure RBAC grants; the AuditLogs query catches Entra directory / app-role grants to a service principal.
- 2Get the Automation account's MI object ID: Automation Accounts → [account] → Identity. Match it against the principal in any roleAssignments/write.
- 3In Subscriptions → Access control (IAM) → Role assignments, filter by the MI and confirm the granted role and scope. Owner / Contributor / User Access Administrator at subscription scope = CRITICAL.
- 4Note the initiating principal — if a runbook job (I2) performed the grant, the automation is escalating itself; if a user did it, that user account may be compromised (pivot SOP-04).
| Operation | Meaning | Severity |
|---|---|---|
| MICROSOFT.AUTHORIZATION/ROLEASSIGNMENTS/WRITE | Azure RBAC role granted (target = MI object ID) | CRITICAL |
| Add app role assignment to service principal | Entra app-role (e.g. Graph permission) granted to SP | CRITICAL |
| Add member to role | Entra directory role (e.g. Global Admin) granted | CRITICAL |
A role grant that is itself performed by an Automation runbook job is the highest-confidence signal in this SOP — the automation is escalating its own identity with no human in the loop. Treat as active compromise and proceed straight to Containment C2/C4.
Logic Apps are the low-code cousin of runbooks: a workflow with a trigger (often an HTTP-request trigger reachable via a SAS-signed callback URL) and actions that can run inline code or call connectors to Key Vault, Storage, or Exchange Online — all under the workflow's managed identity. An attacker creates or edits a workflow to exfiltrate secrets or mail, using the HTTP trigger as an unauthenticated-style persistence channel.
- 1Run the AzureActivity KQL for workflow writes and the AzureDiagnostics WorkflowRuntime KQL for trigger/action runs.
- 2Open Logic apps → [workflow] → Logic app designer and inspect the trigger type and the actions — flag HTTP-request triggers, Key Vault / Office 365 / Storage connectors, and inline "Execute code" actions.
- 3Check Run history for triggers fired from unexpected client IPs, and the workflow's Identity blade for the MI and its role assignments (pivot to I5).
- 4A newly created or modified workflow with an HTTP trigger plus a sensitive connector, called from an external IP, is a confirmed abuse artifact.
Pull the following before you make the call — they drive both containment and any downstream hunt:
- 1Identities: the Caller UPN/appId that wrote the runbook/workflow; the Automation account MI object ID; any principal that received a role grant.
- 2Resources: Automation account & runbook names, webhook/schedule names, Logic App workflow name, target subscription/resource group.
- 3Network: CallerIpAddress / clientIP of the writes and trigger runs; resolve ASN and geo (pivot SOP-36 for anonymiser).
- 4Payload: the runbook body and any URLs, IPs, or base64 blobs it contains; job IDs and their JobStreams output.
- 5Timeline: first write → publish → job start → role grant → trigger creation, as an ordered sequence.
| True-Positive Signals | False-Positive Signals |
|---|---|
| Write/publish + job start + role grant in one short burst by a human caller | Change ticket / release pipeline run naming this account and window |
| JobStreams output reading Key Vault secrets or calling New-AzRoleAssignment | Known deployment SP as Caller from a corporate/CI egress IP |
| Webhook created on a sensitive runbook / far-future expiry | Webhook/schedule matching a documented integration owned by a named team |
| CallerIpAddress on a hosting/VPN/Tor ASN or new geography | Runbook body unchanged; only a benign parameter/tag edit |
| Role grant elevating the Automation MI to Owner/Contributor/UAA | Role grant matches least-privilege design approved in the account's runbook README |
Decision rule: any single true-positive signal with no corroborating change record = confirmed, proceed to Containment. Close as false positive only when a change ticket or pipeline run names this account, this operation, and this time window, and the runbook body is confirmed benign. "An engineer probably did it" is a hypothesis, not a verdict.
03 — CONTAINMENT
STOP ITDo not delete the runbook before exporting its content and the job output — that is your primary evidence of what executed. Disable/suspend first, export, then remediate.
- 1Stop any running job: Jobs → select the job → Stop. This halts in-flight execution before you touch anything else.
- 2Delete rogue webhooks: Webhooks → select → Delete. This invalidates the URL instantly (I3).
- 3Remove rogue schedules / links: Schedules → disable or delete the schedule; unlink it from the runbook (I4).
- 4Suspend the runbook: Runbooks → the suspect runbook → Edit and revert to a known-good published version, or set the runbook to draft so it cannot be started. Export the malicious version first (
Export-AzAutomationRunbook). - 5If Logic App abuse (I6): Logic apps → [workflow] → Disable, and regenerate the HTTP-trigger callback URL / access-key so the old signed URL stops working.
- 1If the identity is compromised and non-critical, disable the service principal: Enterprise applications → the Automation/Logic App SP → Properties → Enabled for users to sign in = No.
- 2Revoke active tokens for the SP so already-issued access tokens stop working:
Revoke-MgServicePrincipalSignInSession(Graph PowerShell) against the SP object ID. - 3If a legacy Run As account is in use, its certificate may be exposed — regenerate/remove the Run As certificate in the Automation account and migrate to a managed identity.
- 4Rotate every secret the runbook could read: any Key Vault secret, storage key, or connection string the JobStreams output touched must be treated as compromised — rotate now (pivot SOP-44 for Key Vault).
Disabling the runbook and rotating credentials does NOT revoke already-minted managed-identity access tokens — they remain valid until expiry (typically up to ~24 hours, commonly ~60–90 minutes for the token itself). You must revoke the SP sessions AND block at the resource side (Key Vault access policy / RBAC, Storage key) and confirm activity has stopped before declaring containment.
- 1Remove any attacker-added role assignment identified in I5 — match the exact principal, role, and scope; do not strip legitimate assignments.
- 2Remove attacker-added Entra directory roles / app-role assignments from the service principal.
- 3If the write caller was a human user, contain that account: revoke sessions and reset credentials (pivot SOP-04) — the runbook change was likely made with stolen creds.
- 4Block the malicious CallerIpAddress at your egress / Conditional Access named locations, and add any C2 domain/IP from the runbook body to Defender/firewall indicators (pivot SOP-34).
- 5Sweep all other Automation accounts and Logic Apps in the tenant for writes from the same caller or IP in the same window — assume the actor touched more than one.
04 — ERADICATION
CLEAN UP- 1Remove all attacker artifacts: delete the malicious runbook (after evidence export), all rogue webhooks and schedules, and any attacker-created Logic App workflow. Enumerate every runbook, webhook, and schedule in the account — attackers plant more than one.
- 2Enumerate all credentials on the identity: check the Automation/Logic App SP for attacker-added secrets, certificates, and federated identity credentials (an FIC lets an external token authenticate with no stored secret — a stealthy persistence trick). Remove any you did not create.
- 3Reconstruct data-at-risk: from JobStreams and resource-side logs (Key Vault, Storage, Exchange) determine which secrets and data the runbook/workflow actually accessed, and rotate everything in reach.
- 4Close the entry point: right-size the Automation account MI to least privilege (remove standing Owner/Contributor at subscription scope); restrict who holds Automation Contributor / Logic App Contributor; require change-controlled deployment for runbook publishes.
- 5Turn on the missing telemetry: enable diagnostic settings on the Automation account (JobLogs + JobStreams) and Logic Apps (WorkflowRuntime) to Log Analytics so this is never invisible again.
- 6Verify clean: re-run I1, I3, I4, and I5 expecting 0 hits; confirm no webhook/schedule remains and the identity holds only approved roles.
- Malicious runbook, webhooks, schedules, and rogue Logic App workflows are deleted (evidence exported first)
- All attacker-added SP secrets, certificates, and federated identity credentials removed
- Attacker-added RBAC and Entra role assignments reversed; MI at least privilege
- Every Key Vault secret / storage key / connection string in reach of the runbook rotated
- Compromised caller account(s) reset and sessions revoked; malicious IP blocked
- Diagnostic logging (JobLogs/JobStreams, WorkflowRuntime) enabled to the SIEM
- Re-run of I1/I3/I4/I5 returns 0 hits; tenant-wide sweep for the same caller/IP is clean
05 — ESCALATION
TIERS| Tier | Trigger Condition | Who to Notify | Action |
|---|---|---|---|
| L1 → L2 | Runbook/workflow write cannot be confirmed as a change within 30 min, or the identity holds a privileged role, or >1 Automation account touched | SOC L2 | Hand off with the I7 IOC pack and timeline |
| L2 → IR | Confirmed malicious execution, MI privilege escalation, webhook/schedule persistence, or Key Vault secret access in JobStreams | Incident Response Team | Open incident, execute C2–C4, begin tenant-wide hunt |
| IR → CISO | Subscription-wide compromise, Owner/UAA obtained via MI, or confirmed exfiltration of secrets/data | CISO + Cloud Platform lead | Invoke major-incident process; consider credential rollover at scale |
| CISO → Exec/Legal | Regulated data exfiltrated (GDPR/PCI/HIPAA), production customer-facing workload affected, or multi-tenant/CSP identity involved | Exec, Legal, DPO | Start breach-notification clock (e.g. GDPR 72h); engage comms |
| External | Nation-state TTPs, need for cloud forensics, or Microsoft-side investigation required | MSSP / Microsoft DART / law enforcement | Preserve evidence; engage per contract |
Bring to every escalation:
- 1Incident / alert ID, subscription and Automation account / Logic App names
- 2Caller identity (UPN/appId) + CallerIpAddress/ASN, and the Automation MI object ID
- 3Timeline: write → publish → job start → role grant → trigger creation
- 4Runbook/workflow body, JobStreams excerpts, and extracted IOCs
- 5Containment already taken and current confidence (TP confirmed / suspected / unverified)
| MITRE ATT&CK | Technique | Where seen |
|---|---|---|
| T1648 | Serverless Execution | Runbook job (I1/I2), Logic App workflow run (I6) |
| T1546 | Event Triggered Execution | Webhook (I3) & schedule (I4) persistence |
| T1098.003 | Account Manipulation: Additional Cloud Roles | MI / SP role grant (I5) |
| T1078.004 | Valid Accounts: Cloud Accounts | Managed-identity re-use for non-interactive execution |
| T1552.006 | Unsecured Credentials: Cloud Instance Metadata / secrets | Key Vault / storage-key reads in JobStreams (I2) |
If the compromised identity belongs to a multi-tenant or CSP/partner automation, the blast radius may extend beyond your tenant — escalate straight to CISO and treat as a potential supply-chain event regardless of the observed action count.
- 1MITRE ATT&CK — T1648 Serverless Execution; T1546 Event Triggered Execution; T1098.003 Additional Cloud Roles
- 2Microsoft Learn — Azure Automation: runbooks, webhooks, schedules, managed identities, and diagnostic settings (JobLogs / JobStreams)
- 3Microsoft Learn — Azure Logic Apps: HTTP-request triggers, managed identity, and workflow diagnostic logs (WorkflowRuntime)
- 4Microsoft Sentinel — AzureActivity, AzureDiagnostics, and AuditLogs table schemas (Advanced Hunting / Log Analytics)
- 5Related CyberHawk SOPs — SOP-44 (Key Vault Secret Access), SOP-48 (Azure Subscription Management-Plane Abuse), SOP-110 (Service Principal / Workload Identity Abuse), SOP-04 (Account Compromise)
Stay Threat-Ready
Follow CyberHawk Threat Intel for daily SOC analyst playbooks, detection engineering guides, and threat intelligence.