Abuse of AWS Systems Manager Session Manager for Remote Execution
Adversaries abuse AWS Systems Manager (SSM) Session Manager to gain interactive shell access and perform remote command execution on EC2 instances or managed hybrid nodes.
What's new
AWS Systems Manager (SSM) Session Manager is a service designed to provide interactive shell access to EC2 instances and managed hybrid nodes without the need for bastion hosts or open inbound network ports. While this functionality is intended for legitimate administrative access, it presents a significant vector for post-exploitation activity. Adversaries with access to valid AWS credentials or those who have compromised an instance role with ssm:StartSession permissions can leverage the SSM agent to spawn arbitrary processes.
The SSM agent utilizes worker processes, such as ssm-session-worker and ssm-document-worker, to handle incoming requests. When an attacker initiates a session, their commands are executed as child processes of these workers. This technique allows for stealthy remote execution, as the activity originates from a trusted system binary. Detection of this behavior is challenging due to the mix of legitimate administrative traffic and malicious commands, necessitating careful behavioral analysis and environment-specific tuning.
Attack Chain
- Attacker gains access to AWS credentials or compromises an IAM role with
ssm:StartSessionpermissions. - Attacker initiates a session using the AWS CLI or SDK to connect to a target EC2 instance or managed node.
- The SSM Agent on the target host receives the connection request and spawns a
ssm-session-workerprocess. - The attacker sends shell commands or scripts through the established SSM tunnel.
- The
ssm-session-workerspawns a child process (e.g.,/bin/bashorpowershell.exe) to execute the attacker's instructions. - Attacker performs reconnaissance, credential harvesting, or further lateral movement using the elevated privileges of the agent.
- Attacker maintains persistent access or exfiltrates data by executing additional payloads from the shell session.
Impact
Successful abuse of SSM Session Manager allows an attacker to operate within the target environment as an authenticated administrator. This grants them the ability to bypass network-level security controls, execute arbitrary code, steal sensitive credentials stored on the instance, and move laterally across the cloud environment. The potential damage includes full system compromise, data theft, and the deployment of further malware, affecting any sector that relies on AWS EC2 or SSM for infrastructure management.
Recommendation
Prioritize the identification of unauthorized SSM session activity by auditing CloudTrail logs for StartSession events. Enable process-creation logging on all managed nodes to detect anomalous child processes spawned by SSM worker binaries.
- Deploy the Sigma rule below to monitor process lineages originating from SSM session workers.
- Review CloudTrail logs to map
ssm-session-workerprocess timestamps to specific IAM principals or AWS access keys. - Establish an exclusion list for known automation service accounts and standard administrative scripts to reduce false positives in the detection rule.
- Enforce the Principle of Least Privilege for IAM roles assigned to EC2 instances, ensuring only authorized users have access to SSM Session Manager.
Immediate actions
Deploy process-creation detection rule for SSM worker activity
Threat Hunt
Audit CloudTrail logs for StartSession API calls correlated with suspicious parent-child process pairs
Data: CloudTrail Management Events, Endpoint Process Logs
Mitigations
Restrict ssm:StartSession IAM permissions to only authorized administrative principals
Cloud Administration Command (T1651)
Detection coverage 2
Detect Suspicious Child Process Execution from AWS SSM Session Worker
mediumDetects potentially unauthorized process execution spawned by AWS Systems Manager (SSM) worker processes.
Detect AWS SSM Inventory Reconnaissance
mediumDetects unauthorized or anomalous access to AWS Systems Manager inventory APIs, including software inventory gathering and patch status description.
Detection queries are available on the platform. Get full rules →