T1021.008 Microsoft Sentinel · KQL

Detect Direct Cloud VM Connections in Microsoft Sentinel

Adversaries may leverage Valid Accounts to log directly into cloud-hosted virtual infrastructure using cloud-native connection methods. Cloud providers offer interactive console access to VMs that bypasses traditional network controls: Azure Serial Console, AWS EC2 Instance Connect, AWS Systems Manager Session Manager (SSM), and GCP OS Login. These methods authenticate via the cloud IAM layer rather than network credentials, can bypass firewall rules and security groups, and often provide SYSTEM or root-level access by default. Adversaries who compromise cloud IAM credentials can pivot to VM instances using these native APIs, even when SSH/RDP is blocked at the network level.

MITRE ATT&CK

Tactic
Lateral Movement
Technique
T1021 Remote Services
Sub-technique
T1021.008 Direct Cloud VM Connections
Canonical reference
https://attack.mitre.org/techniques/T1021/008/

KQL Detection Query

Microsoft Sentinel (KQL)
kusto
// Detect direct cloud VM connections via cloud-native methods
// Azure Serial Console and Run Command detections
AzureActivity
| where TimeGenerated > ago(24h)
| where OperationNameValue in~ (
    "MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION",
    "MICROSOFT.COMPUTE/VIRTUALMACHINES/EXTENSIONS/WRITE",
    "MICROSOFT.SERIALCONSOLE/CONSOLESERVICES/ACCESS"
  )
| extend Caller = tostring(Caller)
| extend ResourceGroup = tostring(ResourceGroup)
| extend VMName = tostring(Resource)
| project TimeGenerated, Caller, OperationNameValue, ResourceGroup, VMName,
         HTTPRequest, Properties, Level
| union (
    // Detect SSM Session Manager connections (via CloudTrail if AWS logs ingested)
    // Using CommonSecurityLog for forwarded AWS/GCP events
    CommonSecurityLog
    | where TimeGenerated > ago(24h)
    | where DeviceVendor == "Amazon" and DeviceProduct == "CloudTrail"
    | where Activity in~ ("StartSession", "ResumeSession", "SendCommand", "StartAutomationExecution")
    | project TimeGenerated, SourceUserName, Activity, DestinationHostName, SourceIP
)
| sort by TimeGenerated desc
high severity medium confidence

Detects direct cloud VM connections via Azure Serial Console, Azure Run Command extension (VM agent-based remote execution), AWS SSM Session Manager, and EC2 Instance Connect. Uses AzureActivity for Azure operations and CommonSecurityLog for forwarded AWS CloudTrail events. These cloud-native access methods bypass traditional network-level security controls.

Data Sources

Cloud Service: Cloud Service AuthenticationAzure Activity LogsAWS CloudTrailInstance Metadata: Cloud API

Required Tables

AzureActivityCommonSecurityLogAuditLogs

False Positives & Tuning

  • DevOps and cloud operations teams using Azure Serial Console or Run Command for legitimate VM troubleshooting and patch management
  • Automated configuration management pipelines using AWS SSM Run Command to apply configurations at scale
  • IT operations using EC2 Instance Connect as a replacement for SSH bastion hosts in approved workflows
  • Cloud platform teams testing instance connectivity and emergency recovery procedures via serial console
  • Managed service providers performing authorized maintenance via cloud-native access tools
Download portable Sigma rule (.yml)

Other platforms for T1021.008


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.

  1. Test 1AWS SSM Send Command to EC2 Instance

    Expected signal: AWS CloudTrail event: eventName=SendCommand, eventSource=ssm.amazonaws.com, with instanceId, documentName, and parameters. CloudWatch Log stream for the command output (if session logging enabled). Source IP address recorded in CloudTrail.

  2. Test 2AWS EC2 Instance Connect (Temporary SSH Key Injection)

    Expected signal: AWS CloudTrail: SendSSHPublicKey event from ec2-instance-connect.amazonaws.com with instanceId, osUser, and publicKey fingerprint. Subsequent SSH connection attempt to the instance.

  3. Test 3Azure Run Command on VM

    Expected signal: Azure Activity Log: MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION operation by the executing identity. The script content is visible in the Properties field. Source IP recorded in httpRequest.clientIpAddress.

  4. Test 4Start AWS SSM Session Manager Interactive Session

    Expected signal: AWS CloudTrail: StartSession event from ssm.amazonaws.com with target instanceId, sessionId, and caller identity. Session logs in CloudWatch if session logging enabled. Note: interactive session content is only captured if session logging is configured.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections