Detect Cloud Services in Splunk
Adversaries may log into accessible cloud services within a compromised environment using Valid Accounts that are synchronized with or federated to on-premises user identities. Many enterprises federate user identities to cloud services (Azure AD/Entra ID, AWS, GCP, M365), allowing adversaries with compromised on-premises credentials to move laterally into cloud control planes. APT29 leveraged synced high-privileged accounts to move into Office 365/Azure. Storm-0501 abused Entra Connect Sync Server for hybrid lateral movement. Scattered Spider used existing AWS EC2 instances for lateral movement. Methods include cloud CLI tools (Connect-AZAccount, gcloud auth, aws configure), web console access, and Application Access Tokens.
MITRE ATT&CK
- Tactic
- Lateral Movement
- Technique
- T1021 Remote Services
- Sub-technique
- T1021.007 Cloud Services
- Canonical reference
- https://attack.mitre.org/techniques/T1021/007/
SPL Detection Query
index=o365 OR index=azure OR index=aws (sourcetype="o365:management:activity" OR sourcetype="azure:monitor:aad:signin" OR sourcetype="aws:cloudtrail")
(
sourcetype="azure:monitor:aad:signin"
properties.status.errorCode=0
| eval UserUPN='properties.userPrincipalName'
| eval AppName='properties.appDisplayName'
| eval SourceIP='properties.ipAddress'
| eval RiskLevel='properties.riskLevelDuringSignIn'
| eval IsAnon=if(match('properties.networkLocationDetails', "anonymizedIP"), 1, 0)
| where RiskLevel IN ("medium", "high") OR IsAnon=1
| eval AlertType="AzureRiskySignin"
| table _time, UserUPN, AppName, SourceIP, RiskLevel, IsAnon, AlertType
)
OR
(
sourcetype="o365:management:activity" Operation="UserLoggedIn"
ResultStatus="Success"
| eval UserUPN=UserId
| eval ClientIP='ClientIP'
| eval AppName='ApplicationName'
| eval Country=mvindex(split('ClientInfoString', ";"), 0)
| stats dc(ClientIP) as UniqueIPs, values(ClientIP) as IPs by UserUPN, AppName
| where UniqueIPs >= 3
| eval AlertType="O365MultiIPLogin"
| table UserUPN, AppName, UniqueIPs, IPs, AlertType
)
OR
(
sourcetype="aws:cloudtrail" eventName="ConsoleLogin" responseElements.ConsoleLogin="Success"
| eval UserArn='userIdentity.arn'
| eval SourceIP='sourceIPAddress'
| eval MFA='additionalEventData.MFAUsed'
| where MFA="No"
| eval AlertType="AWSConsoleLoginNoMFA"
| table _time, UserArn, SourceIP, MFA, AlertType
) Detects cloud service lateral movement using three log sources: Azure AD sign-in logs for risky or anonymized-IP sign-ins, Office 365 audit logs for users logging in from 3+ unique IPs (potential credential sharing/token theft), and AWS CloudTrail for console logins without MFA (higher risk indicator of unauthorized access). The AlertType field identifies the detection source.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Developers using cloud CLI tools from their workstations
- CI/CD pipeline agents authenticating to cloud services for deployment
- Cloud administrators performing routine management via cloud CLI
- Multi-cloud monitoring tools authenticating to multiple platforms
- Legitimate travel causing geographic sign-in anomalies
Other platforms for T1021.007
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Authenticate to Azure via Azure CLI from Compromised Endpoint
Expected signal: Sysmon Event ID 1: az.cmd (or az) process creation with 'login' in command line. Sysmon Event ID 3: outbound HTTPS connections to login.microsoftonline.com. Azure AD SigninLogs entry for the authenticated user from the endpoint's IP address.
- Test 2Authenticate to Azure PowerShell (Connect-AzAccount)
Expected signal: Sysmon Event ID 1: powershell.exe with Connect-AzAccount in command line. Sysmon Event ID 3: HTTPS connections to login.microsoftonline.com, management.azure.com. Azure AD SigninLogs showing PowerShell client sign-in.
- Test 3Configure AWS CLI with Stolen Credentials
Expected signal: Linux auditd EXECVE for aws CLI binary. File creation/modification of ~/.aws/credentials. HTTPS connection to sts.amazonaws.com. AWS CloudTrail event for GetCallerIdentity API call from the source IP.
- Test 4List and Access Cloud Resources After Authentication
Expected signal: Sysmon Event ID 1 for each az command execution. HTTPS connections to management.azure.com API. Azure Activity Log: List operations for subscriptions, resources, and key vaults. Entra ID audit log for authenticated session activities.
References (8)
- https://attack.mitre.org/techniques/T1021/007/
- https://learn.microsoft.com/en-us/cli/azure/
- https://learn.microsoft.com/en-us/powershell/azure/
- https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1021.007/T1021.007.md
- https://www.mandiant.com/resources/blog/remediation-hardening-strategies-microsoft-365
- https://www.microsoft.com/security/blog/2024/09/26/storm-0501-ransomware-attacks-expanding-to-hybrid-cloud-environments/
- https://specterops.io/blog/credential-storage/
Unlock Pro Content
Get the full detection package for T1021.007 including response playbook, investigation guide, and atomic red team tests.