Skip to main content
Back
DemonstrationAWS
6 min read

ECScape: a low-privileged ECS task takes the IAM credentials of other tasks on its instance

Environment
A research environment staged by Sweet Security: an Amazon ECS cluster on EC2 with demo tasks of different privilege on one container instance; no company was named
When
Run dates not stated; talk scheduled June 30, 2025 – Aug 6, 2025Disclosed Aug 6, 2025
Entry
A compromised, low-privileged container on an ECS container instance of the EC2 launch type that could reach the instance metadata service from its own network namespace; no container breakout and no host root were needed.

Sweet Security's ECScape research started from a compromised, low-privileged container on an Amazon ECS container instance of the EC2 launch type, with no breakout and no host root. The container took the instance role credentials from the instance metadata service, used them to discover the Agent Communication Service endpoint, read the cluster and container instance identifiers from local endpoints and opened a forged agent session, over which the ECS control plane pushed the task role and task execution role credentials of every task with a role on the instance; with them, the researcher deleted a demo S3 bucket and read a demo secret. Direct assumption of the task roles fails and Fargate tasks are not affected; AWS classified the behavior as a design consideration of ECS on EC2, issued no CVE or bulletin and updated its documentation.

What the demonstration did

Internet
Amazon ECS control planeAgent Communication Service
Amazon ECS
Low-Privileged Task
Amazon EC2
Shared ECS Container Instance
+ demo S3 bucket
+ secret db-secret
+ full S3 access role
Other Tasks' Resources
Researcher's Code
Deny-All Task Role
Stolen Task Credentials
Instance Metadata Service
ECS Container Agent
Task Metadata Endpoint
Agent Introspection API
S3 Control Task
Database Task

Replaying the ECScape demonstration / published August 2025; the run dates are not stated

  1. 1

    Instance credentials from a low-privileged container

    Not dated · published Aug 6, 2025

    The low-privileged container asks the instance metadata service for the instance profile credentials and receives the instance role.

  2. 2

    Impersonating the ECS agent

    Not dated · published Aug 6, 2025

    The instance role finds the agent's control channel, local endpoints give the identifiers, and a forged agent session receives every task's role credentials.

  3. 3

    Using the stolen task roles

    Not dated · published Aug 6, 2025

    A stolen task role with full S3 access deletes a demo bucket, and a stolen task execution role reads the demo secret db-secret.

  4. 4

    Disclosure and AWS's response

    July 2025 · day not stated

    Sweet Security reports the issue to AWS, which calls it a design consideration of ECS on EC2 and updates its documentation.

Impact

From a low-privileged container on a shared ECS container instance, the researcher took the instance role credentials, impersonated the ECS agent and received the task role and task execution role credentials of the other tasks on the instance; with them, a demo S3 bucket was deleted and a demo secret was read. Direct assumption of the task roles failed, and Fargate tasks are not affected. AWS classified the behavior as a design consideration and updated its documentation.

Outcome

What the demonstration shows about your ECS on EC2 instances

The chain needed one low-privileged container that could reach the instance metadata service. Once it held the instance role, no AWS control told its agent session from the real agent's, and the control plane sent it the credentials of every task with a role on the instance. The controls that cap it sit before and after that point: keep your tasks off the instance metadata service with the ECS agent setting for awsvpc tasks and IMDSv2 with a hop limit of 1 for bridge tasks, and bound what a stolen task role can do with service control policies and S3 Object Lock. Fargate tasks are not affected. AWS treats the behavior as a design consideration of ECS on EC2, so separating tasks of different privilege is yours to do.

Would the controls have stopped it?

In hindsight, no control would have stopped it. 6 controls would have limited how far it went. 5 steps have no cloud-provider control. The counts below are control assessments, not attack stages: several can address the same step. The same replay with the controls in place before the incident shows where each phase would have been refused or bounded.

0
Prevented
6
Contained
5
Not covered

How it could have been prevented

The same replay with the controls in place. Green marks where a step is refused, blue where it is bounded, and red where no control reaches it. Open a row to read the control, why it acts, and its caveat.

Internet
Amazon ECS control planeAgent Communication Service
Amazon ECS
Low-Privileged Task
Amazon EC2
Shared ECS Container Instance
+ demo S3 bucket
+ secret db-secret
+ full S3 access role
Other Tasks' Resources
Researcher's Code
Deny-All Task Role
Stolen Task Credentials
Instance Metadata Service
ECS Container Agent
Task Metadata Endpoint
Agent Introspection API
S3 Control Task
Database Task

Replaying the ECScape demonstration / published August 2025; the run dates are not stated

1 · Instance credentials from a low-privileged container

2 Contained3 on other clouds

2 · Impersonating the ECS agent

4 Not covered

3 · Using the stolen task roles

4 Contained3 on other clouds

4 · Disclosure and AWS's response

1 Not covered

Key facts

  • The researcher started from a compromised, low-privileged task container on an ECS container instance of the EC2 launch type; its own task role denied everything
  • The container requested the instance role credentials from the instance metadata service, a request that Sweet Security says CloudTrail does not log
  • With the instance role, the researcher called ecs:DiscoverPollEndpoint and opened a WebSocket to the Agent Communication Service with the real agent's parameters; AWS accepted it alongside the real agent's session
  • The ECS control plane pushed the task role and task execution role credentials of every task with a role on the instance over the forged session
  • With a stolen task role that had full S3 access, the researcher deleted a demo S3 bucket; with a stolen task execution role, the researcher read the demo secret db-secret
  • Sweet Security reported the issue to AWS in July 2025; AWS called it a design consideration of ECS on EC2, issued no CVE or bulletin and updated its documentation, and a CVE ID had been requested as of August 8, 2025

Sources

Every fact in this breakdown comes from the public reporting below. The replay is a model of that reporting, not a reconstruction of the environment it describes.

  1. 1.
    ECScape: Understanding IAM Privilege Boundaries in Amazon ECSSweet Security · Aug 6, 2025 · Researchthreat model, instance role credentials from the instance metadata service, poll endpoint discovery, identifier gathering, the forged agent session, task role and task execution role credentials, demo outcomes (S3 bucket deletion, secret read), Fargate not affected, CloudTrail visibility, mitigations, AWS's response
  2. 2.
    Under the Hood of Amazon ECS on EC2: Agents, IAM Roles, and Task IsolationSweet Security · Aug 6, 2025 · ResearchECS agent internals, the two instance role permissions, the Agent Communication Service, how task credentials reach tasks, the July 2025 report to AWS, AWS's classification, AWS's documentation changes
  3. 3.
    Security considerations for running containers on Amazon ECSAmazon Web Services (AWS Security Blog) · Aug 1, 2025 · AdvisoryAWS's position on container and instance boundaries, the July 9 and August 1, 2025 updates, Fargate isolation, workload separation advice
  4. 4.
    ECS-cape – Hijacking IAM Privileges in Amazon ECSfwd:cloudsec North America 2025 (pretalx schedule) · Jun 30, 2025 · Researchthe earlier public talk, the abstract's claims
  5. 5.
    ECS on EC2: Covering Gaps in IMDS HardeningLatacora · Oct 2, 2025 · ResearchIMDS blocking by network mode, the hop limit gap for awsvpc and host tasks, the host mode impasse, AWS's documentation update as reported
  6. 6.
    ECScape: New AWS ECS flaw lets containers hijack IAM roles without breaking outCSO Online · Aug 8, 2025 · NewsAWS not responding to the outlet, CVE requested, researcher quotes on default settings and Fargate, Black Hat USA 2025 presentation

The estate in the replay follows the researchers' description of their own test environment. Verdicts describe what a control does when it is in place before the run. They are not an assessment of any company's security program.

More cloud attack breakdowns

All breakdowns