Ensure Amazon ECS task definitions using 'host' network mode do not allow privileged or root user access to the host
Description
Ensure that Amazon ECS task definitions using host network mode do not allow privileged or root user access. This protects the host container instance from unauthorized access and privilege escalation.
Note: This recommendation assumes that only the latest active revision of a task definition is in use. If older revisions are in use, apply the audit and remediation procedures to those revisions as needed.
Rationale
Combining host networking mode with privileged or root user access significantly increases the risk of container breakout, where a compromised container can gain control of the host system.
Impact
There may be some administrative effort required to ensure Amazon ECS applications function as expected without privileged or root user access.
Audit Procedure
Using AWS Console
- Login to the ECS console using https://console.aws.amazon.com/ecs/.
- In the left panel, click
Task definitions. - Click the name of a task definition.
- Click on the latest active revision of the task definition.
- If
Network modeis set tohost, clickJSON. - For each element under
containerDefinitions, ensure thatprivilegedis set tofalseor is absent, and ensure thatuseris not set torootor is absent. - Repeat steps 1-6 for each task definition.
Using AWS CLI
Run the following command to list task definitions:
aws ecs list-task-definitions
For the latest revision of a task definition, run the following command:
aws ecs describe-task-definition --task-definition <task-definition-arn>
If networkMode is set to host, ensure that for each element under containerDefinitions, privileged is set to false or is absent, and ensure that user is not set to root or is absent.
Repeat for each task definition.
Expected Result
For task definitions using host network mode, privileged should be false or absent, and user should not be root or should be absent in all containerDefinitions.
Remediation
Using AWS Console
- Login to the ECS console using https://console.aws.amazon.com/ecs/.
- In the left panel, click
Task definitions. - Click the name of a task definition.
- Click on the latest active revision of the task definition.
- Click
Create new revision. - Click
Create new revision with JSON. - For each element under
containerDefinitions, setprivilegedtofalse, or remove"privileged": true. - For each element under
containerDefinitions, setuserto an appropriate non-root user, or remove"user": "root". - Click
Create. - Repeat steps 1-9 for each task definition requiring remediation.
Note: When a task definition is updated, running tasks launched from the previous task definition remain unchanged. Updating a running task requires redeploying it with the new task definition.
Using AWS CLI
No specific CLI remediation provided. Use the console steps above or register a new task definition revision with corrected settings using aws ecs register-task-definition.
Default Value
When creating a task definition with host network mode, the privileged and user parameters are unset by default.
References
- https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html
- https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
- https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/describe-task-definition.html
Additional Information
- AWS recommends using the
awsvpcnetwork mode unless you have a specific need to use a different network mode. - The
privilegedparameter is not supported for Windows containers or tasks using the Fargate launch type.
CIS Controls
| Controls Version | Control | IG 1 | IG 2 | IG 3 |
|---|---|---|---|---|
| v8 | 5.4 Restrict Administrator Privileges to Dedicated Administrator Accounts | x | x | x |
| v7 | 4.3 Ensure the Use of Dedicated Administrative Accounts | x | x | x |
Profile
Level 1 | Automated