Overview
Amazon Elastic Container Service (ECS) task definitions are JSON files that describe how a Docker container should be launched within an ECS cluster.
This control only evaluates the in-use (RUNNING Task) revision of an Amazon ECS task definition, configured with the host network mode, exhibits unexpected privilege escalation on the host container.
If the privileged parameter is set to true or the user parameter is set to root or any other highly privileged user, it can lead to security concerns. These containers have elevated privileges, enabling them to access resources and perform operations that are typically restricted.
Remediation guidance
To remediate this issue, identify the task definitions with the host network mode and elevated privileges, and update their parameters accordingly. You can achieve this by creating a new task definition revision using the following steps:
- Open the Amazon ECS classic console.
- Choose the region that contains your task definition.
- In the navigation pane, select "task definitions."
- On the task definitions page, select the checkbox next to the task definition that needs revision, and choose Create new revision.
- Update the
privilegedparameter tofalseand/or change theuserparameter to a low-privileged user. - If your task definition is used in a service, update your service with the updated task definition. For more information, refer to the AWS documentation.
Service-wide remediation
Recommended when many resources are affected: fix the platform baseline first so new resources inherit the secure setting, then remediate the existing flagged resources in batches.
AWS
Use AWS Organizations guardrails, AWS Config rules or conformance packs where they fit, approved account baselines, and IaC modules so new resources inherit the secure setting.
Operational rollout
- Fix the baseline first at the account, subscription, project, cluster, or tenant scope that owns this control.
- Remediate the currently affected resources in batches, starting with internet-exposed and production assets.
- Re-scan and track approved exceptions with an owner and expiry date.
Query logic
These are the stored checks tied to this control.
Check if Amazon ECS task definitions should have secure networking modes and user definitions
Connectors
Covered asset types
Expected check: eq []
{
ecsTaskDefinitions(
where: {
networkMode: "host", task_NOT: null,
OR:[
{containerSpecs_SOME: { privileged: true }},
{containerSpecs_SOME: { user_CONTAINS: "root" }}
] }
) {...AssetFragment}
}
AWS