T1648

Serverless Execution

This detection identifies adversary abuse of serverless computing platforms — including AWS Lambda, Azure Functions, and Microsoft Power Automate — to execute arbitrary code or automate malicious workflows within cloud environments. Adversaries create or modify serverless functions to run cryptomining payloads, establish persistent backdoors triggered by cloud events, escalate privileges by attaching overprivileged IAM roles (via IAM:PassRole or iam.serviceAccounts.actAs), and exfiltrate data through automated workflows. Key indicators include unexpected serverless function creation by identities with no prior deployment history, attachment of administrative IAM roles to functions, event source mappings that enable persistent trigger-based execution, and Power Automate flows containing email forwarding or external HTTP connector actions. Real-world examples include the Denonia cryptominer (first Lambda-specific malware), Pacu framework Lambda deployment, and adversary-created Power Automate flows forwarding executive email to external addresses.

Microsoft Sentinel / Defender
kusto
let lookback = 1d;
// AWS Lambda abuse via CloudTrail
let LambdaAbuse = AWSCloudTrail
| where TimeGenerated > ago(lookback)
| where EventSource == "lambda.amazonaws.com"
| where EventName in~ (
    "CreateFunction20150331",
    "UpdateFunctionCode20150331v2",
    "AddPermission20150331v2",
    "CreateEventSourceMapping",
    "UpdateFunctionConfiguration20150331v2"
)
| extend Actor = coalesce(UserIdentityArn, UserIdentityUserName)
| extend SourceIP = SourceIpAddress
| extend FunctionName = tostring(RequestParameters.functionName)
| extend FunctionRole = tostring(RequestParameters.role)
| extend Runtime = tostring(RequestParameters.runtime)
| extend RiskScore = case(
    EventName == "AddPermission20150331v2", 80,
    EventName == "CreateEventSourceMapping", 75,
    EventName == "UpdateFunctionCode20150331v2", 70,
    FunctionRole has_any ("Admin", "PowerUser", "FullAccess"), 90,
    65
)
| project TimeGenerated, Platform="AWS Lambda", Actor, SourceIP,
    Action=EventName, ResourceName=FunctionName,
    ExtraDetail=strcat("Role: ", FunctionRole, " | Runtime: ", Runtime),
    RiskScore, TenantOrAccount=RecipientAccountId, Region=AWSRegion;
// Azure Functions creation/modification
let AzureFuncAbuse = AzureActivity
| where TimeGenerated > ago(lookback)
| where OperationNameValue has_any (
    "microsoft.web/sites/write",
    "microsoft.web/sites/functions/write",
    "microsoft.web/sites/config/write"
)
| where ActivityStatusValue == "Success"
| where ResourceProvider == "MICROSOFT.WEB"
| extend Actor = Caller
| extend SourceIP = CallerIpAddress
| extend RiskScore = 70
| project TimeGenerated, Platform="Azure Functions", Actor, SourceIP,
    Action=OperationNameValue, ResourceName=ResourceId,
    ExtraDetail=tostring(Properties), RiskScore,
    TenantOrAccount=SubscriptionId, Region=ResourceGroup;
// Power Automate suspicious flow activity (M365 / CloudAppEvents)
let PowerAutomate = CloudAppEvents
| where TimeGenerated > ago(lookback)
| where Application == "Microsoft Power Automate"
| where ActionType in ("CreateFlow", "UpdateFlow", "EnableFlow", "ShareFlow")
| extend Actor = AccountUpn
| extend SourceIP = IPAddress
| extend FlowName = tostring(RawEventData.flowName)
| extend TriggerType = tostring(RawEventData.triggerType)
| extend RiskScore = case(
    ActionType == "ShareFlow", 75,
    ActionType == "EnableFlow", 70,
    ActionType == "CreateFlow", 65,
    60
)
| project TimeGenerated, Platform="Power Automate", Actor, SourceIP,
    Action=ActionType, ResourceName=FlowName,
    ExtraDetail=strcat("Trigger: ", TriggerType),
    RiskScore, TenantOrAccount=tostring(AccountObjectId), Region="M365";
// Union all platforms and surface highest risk events
union LambdaAbuse, AzureFuncAbuse, PowerAutomate
| order by RiskScore desc, TimeGenerated desc
| project TimeGenerated, Platform, Actor, SourceIP, Action, ResourceName, ExtraDetail, RiskScore, TenantOrAccount, Region
high severity medium confidence

Data Sources

AWS CloudTrail (Sentinel Connector) Azure Activity Logs Microsoft Defender for Cloud Apps / CloudAppEvents

Required Tables

AWSCloudTrail AzureActivity CloudAppEvents

False Positives

  • Legitimate DevOps CI/CD pipelines (GitHub Actions, Jenkins, AWS CodePipeline) using service accounts to regularly deploy Lambda or Azure Function updates as part of normal SDLC workflows
  • Infrastructure-as-code tooling (Terraform, AWS CDK, Pulumi, Bicep) creating or updating serverless resources during planned deployments — these typically originate from known CI/CD source IPs with consistent timing patterns
  • IT or business teams creating Power Automate flows for approved process automation such as SharePoint approval workflows, Teams notifications, or internal HR onboarding processes

Unlock Pro Content

Get the full detection package for T1648 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections