Summary
A path traversal vulnerability in the AWS Systems Manager Agent aws:downloadContent plugin may allow an authenticated user with restricted ssm:SendCommand access to write files outside the intended download directory. Because the plugin performs these writes with root privileges, overwriting sensitive files could potentially enable arbitrary code execution.
Affected context
The issue affects deployments using the AWS Systems Manager Agent aws:downloadContent plugin to retrieve objects from Amazon S3. Risk arises when an authenticated principal can invoke the permitted AWS-DownloadContent document and the plugin does not sufficiently constrain object-derived filenames to the intended download directory.
Exploit preconditions
- Attack surface: The AWS Systems Manager Agent
aws:downloadContentplugin - Required access: An authenticated remote user with permission to invoke
ssm:SendCommand for the AWS-DownloadContent document
- Trigger point: Processing S3 object keys while downloading content
- Why exploitation is possible: Insufficient pathname restrictions may allow
object-derived paths to resolve outside the designated download directory,
with the agent performing the write using root privileges
Why this happens
The vulnerability is caused by improper limitation of a pathname to a restricted directory. The plugin derives a local destination from attacker- influenceable S3 object metadata without reliably enforcing that the resolved path remains within the authorized download directory. This behavior maps to CWE-23, Path Traversal, where path components can escape an intended directory boundary and reach unintended filesystem locations.
Potential impact
- An attacker may write arbitrary files outside the intended download directory
- Sensitive system or application files could be overwritten
- The SSM-managed host could experience integrity or availability impacts
- Arbitrary code could execute with root privileges if a suitable sensitive file is overwritten
- The host could be used for further unauthorized activity
General mitigation guidance
Mitigation generally focuses on enforcing filesystem boundaries independently
of user-controlled object names.
Common defensive patterns include:
- Canonicalizing and validating destination paths before every write
- Rejecting traversal components, absolute paths, and paths that resolve outside
an explicitly authorized directory
- Constructing destinations from trusted identifiers rather than raw object keys
- Applying filesystem permissions and service-account privileges that limit the
consequences of an unexpected write
- Separating downloaded content from executable or security-sensitive paths
- Using patched, vendor-supported agent releases through established update
processes
- Restricting
ssm:SendCommandpermissions and applying least-privilege IAM
policies
How teams detect issues like this
Detection approaches may include:
- Static analysis for path joins or file writes that use S3 object keys or other
external names without canonicalization and containment checks
- Code review checks for absolute paths, traversal segments, and missing
post-resolution directory-boundary validation
- Runtime monitoring of the SSM Agent for writes outside approved download
locations
- File-integrity monitoring for unexpected changes to system, service, or startup
configuration files
- IAM policy reviews and enforcement rules limiting command-document access to
required principals
- Automated security scanning and code-review tools that identify path
traversal patterns

