SEC595: Applied Data Science and AI/Machine Learning for Cybersecurity Professionals


Experience SANS training through course previews.
Learn MoreLet us help.
Contact usBecome a member for instant access to our free resources.
Sign UpWe're here to help.
Contact UsRemote Command Execution via AWS SSM and Azure Run Command

AWS Systems Manager and Azure Run Command are legitimate remote execution frameworks built into AWS and Azure infrastructure-as-a-service (IaaS) offerings. For attackers, they're also a reliable lateral movement and persistence path that bypasses traditional network controls entirely. Named threat groups including APT29 and Scattered Spider have used these mechanisms in confirmed intrusions. Both platforms create a detection challenge by redacting the actual command content from their primary audit logs, leaving responders to reconstruct attacker activity from secondary sources and host-based artifacts.
AWS Systems Manager (SSM) runs a pre-installed agent on AWS-provided Amazon Linux and Windows Server AMIs that communicates outbound-only to the SSM service’s domain. No inbound firewall rules are required. An attacker with ssm:SendCommand permissions can issue aws ssm send-command targeting any EC2 instance reachable by the SSM service, without touching SSH or RDP. Commands execute as root on Linux and as SYSTEM on Windows. Session Manager (ssm:StartSession) provides a full interactive shell under the same privilege model.
Azure Run Command operates through the Azure VM Agent — WindowsAzureGuestAgent.exe on Windows and WALinuxAgent on Linux — invoked via portal, CLI, PowerShell, or REST API. The minimum RBAC permission required is Microsoft.Compute/virtualMachines/runCommand/action, attainable at the Virtual Machine Contributor role. Like SSM, execution is SYSTEM on Windows and root on Linux.
Both mechanisms are designed for legitimate remote administration, but threat actors are attracted by the ability to execute commands with the highest privileges on a host without needing host credentials.
APT29, tracked by Microsoft as NOBELIUM during the SolarWinds campaign and subsequently renamed Midnight Blizzard, used Azure Run Command as part of post-compromise activity following the SolarWinds supply chain intrusion. In October 2021, MSTIC documented the group exploiting Azure Admin-on-Behalf-of (AOBO, a Microsoft partner delegation mechanism) to pivot from compromised managed service provider accounts into downstream customer environments. Once positioned in a customer tenant, APT29 used Run Command to conduct reconnaissance, steal credentials, and deploy Cobalt Strike BEACON via PowerShell.
Scattered Spider (UNC3944/Octo Tempest) used SSM aggressively across multiple phases of their operations, as documented by CISA in November 2023. Specific actions included running AWS-GatherSoftwareInventory across all EC2 instances for software reconnaissance, using SSM Send Command for lateral movement into EC2 instances, and deploying ETL tooling via SSM to centralize data before exfiltration. The group also enabled EC2 Serial Console Access (EnableSerialConsoleAccess) and used SendSerialConsoleSSHPublicKey via EC2 Instance Connect, extending persistence options beyond SSM alone. Scattered Spider conducts data exfiltration and extortion operations, with ransomware deployed in some intrusions through the ALPHV/BlackCat affiliate program.
Both platforms share the same fundamental gap: the actual command content is not logged in the primary audit trail.
In AWS CloudTrail, SendCommand events (source: ssm.amazonaws.com) capture the IAM principal, timestamp, target instanceIds, and documentName, but the parameters field, which contains the actual command text, is always redacted with HIDDEN_DUE_TO_SECURITY_REASONS. This is intentional AWS behavior, not a configuration failure. An analyst reviewing CloudTrail for AWS-RunShellScript invocations will see who ran a command and against which instances, but not what the command contained.
In Azure, the Activity Log records Microsoft.Compute/virtualMachines/runCommand/action for Action Run Commands, including useful fields: caller, CallerIpAddress, resourceId (identifying the specific VM), operationName, status, and authorization.scope. The actual script content is absent. Managed Run Commands introduce a second gap: creation events log as Microsoft.Compute/virtualMachines/runCommand/write which does not always also generate the /action event, meaning detections built solely on the action event will miss Managed Run Command activity. Azure Activity Log default retention is 90 days, and without export to Log Analytics or a Storage Account, older events are unrecoverable.
Understanding these gaps is prerequisite to building effective detection coverage. The log events establish context — who, when, and which target — but command content recovery requires separate data sources.
When investigating SSM activity or writing detections, look for the following on the following CloudTrail events from source ssm.amazonaws.com:
From Azure Activity Log and Log Analytics (if configured):
When command content is needed for attribution, scope determination, or chain-of-custody, host-based artifacts are the primary recovery path.
AWS SSM — Linux:
AWS SSM — Windows:
Azure Run Command — Windows:
Azure Run Command — Linux:
Cloud audit logs and host artifacts should be supplemented with endpoint telemetry, particularly where EDR or Sysmon is deployed on cloud-hosted VMs.
On Windows, Event ID 4688 (process creation) and Event ID 4104 (PowerShell Script Block Logging) capture child process execution and PowerShell content regardless of obfuscation. Sysmon Event ID 1 flags powershell.exe or cmd.exe spawned under WindowsAzureGuestAgent.exe or amazon-ssm-agent.exe — both parent processes with limited legitimate child process scope. Sysmon Event ID 11 captures PS1 file creation in plugin download directories. EDR process lineage from RunCommandExtension.exe or amazon-ssm-agent.exe provides the most direct signal, and multiple simultaneous SSM agent processes on a single host indicate the Mitiga-documented parallel agent technique.
On Linux, auditd or eBPF-based telemetry with execve syscall logging will surface commands executed with waagent or run-command-extension as the parent process.
The detection surface here is recoverable, but it requires deliberate configuration before an incident. The logs that don't exist at collection time cannot be retrieved during response.
If you’re looking to learn more about investigating cloud security threats, SANS FOR509: Enterprise Cloud Forensics and Incident Response is designed to prepare responders in cloud environments. Students learn what log sources are available, what threat actors do, and how those activities appear in the logs so that you can identify suspicious activity, reconstruct attacker actions despite logging gaps, and build effective detections and response strategies in real-world cloud environments.


Megan is a Senior Security Engineer at Datadog, SANS DFIR faculty, and co-author of FOR509. She holds two master’s degrees, serves as CFO of Mental Health Hackers, and is a strong advocate for hands-on cloud forensics training and mental wellness.
Read more about Megan Roddie-Fonseca