A critical security concern has emerged following the discovery of a vulnerability in the AWS Systems Manager (SSM) Agent, a key component of Amazon Web Services (AWS) used to manage EC2 instances and on-premises servers. This security flaw, identified as a Path Traversal vulnerability, enables attackers to execute malicious code with root privileges, potentially leading to privilege escalation and unauthorized access to sensitive systems.
The issue originates from insufficient input validation in the ValidatePluginId function located in the pluginutil.go file of the SSM Agent. This function is responsible for checking and validating plugin IDs specified in SSM Documents, which are JSON or YAML-based templates defining tasks to configure or manage systems. Attackers can exploit the flaw by including malicious path traversal sequences (such as ../) to manipulate the file system.
When an SSM Document is executed, the SSM Agent dynamically creates directories named after the plugin ID and executes scripts within them using root privileges. Due to the flawed validation, attackers can craft a malicious plugin ID to create unintended directories and execute commands outside secure locations, potentially compromising sensitive areas such as /tmp/.
The vulnerability in the AWS SSM Agent, specifically in the ValidatePluginId function, affects all currently released versions of the SSM Agent. Attackers can utilize a crafted plugin ID to create directories and files in unintended locations. For example, if the plugin ID contains ../../../../../malicious_directory, the agent interprets this as a directive to create directories outside its intended scope, allowing the execution of scripts in arbitrary locations with elevated privileges.
The exploitation of this vulnerability could enable attackers to create directories in restricted or sensitive locations, execute arbitrary commands or scripts with root-level access, and potentially escalate privileges to gain full control over the compromised instance.
To reproduce the exploit, attackers can create a malicious SSM Document with a plugin ID containing path traversal sequences, upload the document to AWS, execute the document via the SSM Agent, and verify the results by checking for unintended directory creation and script execution in these locations.
To address this vulnerability, AWS should enhance input validation in the ValidatePluginId function to reject special characters like ../, release an updated version of the SSM Agent with security patches, and notify customers to update their SSM Agents and audit their systems for signs of exploitation. Organizations using AWS Systems Manager should remain vigilant, apply security updates promptly, and monitor their systems closely to mitigate potential risks.
While AWS has yet to release a patch at the time of writing, swift action is anticipated to safeguard users and infrastructure. This incident highlights the importance of input validation in preventing exploitation and underscores the need for proactive security measures to protect against such vulnerabilities.