All checks
Medium ECS · regional

ECS task definitions should not use host network mode

Checks that the task definition family's latest active revision does not set networkMode to host; older revisions a service may still run are not read. Host mode ties a container to the instance's own network, so it can reach private loopback services on the host and impersonate the host.

service
ECS
severity
Medium
scope
evaluated in every region

How to fix it

  • Can break clients: Containers lose the instance's ports and loopback services, and under awsvpc the service also needs a network configuration and target groups of type ip.

In the console

ECS → Task definitions → the family → the latest revision → Create new revision with JSON

networkMode
awsvpc (each task gets its own network interface) or bridge; none turns networking off, and only host fails
portMappings
Under awsvpc, containerPort only, as hostPort is ignored; under bridge, hostPort left out or 0 for a dynamic port
Task definition
The new revision, on each service's Update page and in each scheduled task; running tasks keep the old one

With Terraform

resource "aws_ecs_task_definition" "this" {
  family       = "example"
  network_mode = "awsvpc"

  container_definitions = jsonencode([{
    name  = "app"
    image = var.container_image
  }])
}

See which of your accounts this check is failing on.

Book a live scan