T1059.009

Cloud API

Adversaries may abuse cloud APIs to execute malicious commands. APIs available in cloud environments provide various functionalities and are a feature-rich method for programmatic access to nearly all aspects of a tenant. These APIs may be utilized through CLIs (aws, az, gcloud), in-browser Cloud Shells, PowerShell modules, or SDKs. With proper permissions, adversaries may abuse cloud APIs to invoke functions across compute, storage, IAM, networking, and security services. APT29 has leveraged the Microsoft Graph API, TeamTNT has used AWS CLI with compromised credentials, and Storm-0501 has used cloud CLI for data exfiltration.

Microsoft Sentinel / Defender
kusto
let SuspiciousAPICalls = dynamic([
  "CreateUser", "AttachUserPolicy", "CreateAccessKey",
  "CreateRole", "AssumeRole", "GetSessionToken",
  "PutBucketPolicy", "DeleteBucketPolicy",
  "CreateFunction", "UpdateFunctionCode",
  "RunInstances", "CreateKeyPair",
  "StopLogging", "DeleteTrail", "PutEventSelectors",
  "DisableGuardDuty", "DeleteDetector",
  "CreateGroup", "AddMemberToGroup",
  "InviteUser", "AddMember",
  "roleDefinitions/write", "roleAssignments/write"
]);
AuditLogs
| where TimeGenerated > ago(24h)
| where OperationName has_any (SuspiciousAPICalls)
| union (
  AzureActivity
  | where TimeGenerated > ago(24h)
  | where OperationNameValue has_any ("roleDefinitions/write", "roleAssignments/write", "Microsoft.Compute/virtualMachines/write")
)
| union (
  AWSCloudTrail
  | where TimeGenerated > ago(24h)
  | where EventName has_any (SuspiciousAPICalls)
  | where UserIdentityType != "AssumedRole" or isnotempty(ErrorCode)
)
| project TimeGenerated, OperationName, Identity, CallerIpAddress, ResultType, ResultDescription
| sort by TimeGenerated desc
high severity medium confidence

Data Sources

Cloud Service: Cloud Service Enumeration User Account: User Account Modification Application Log: Application Log Content

Required Tables

AuditLogs AzureActivity AWSCloudTrail

False Positives

  • Cloud administrators creating IAM users and roles during onboarding or infrastructure provisioning
  • Infrastructure-as-Code tools (Terraform, CloudFormation, Pulumi) creating cloud resources programmatically
  • CI/CD pipelines deploying Lambda functions or updating compute resources

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections