π‘οΈ AWS ECS Service automatically assigns public IP addressesπ’
- Contextual name: π‘οΈ Service automatically assigns public IP addressesπ’
- ID:
/ce/ca/aws/ecs/service-public-ip-auto-assignment - Tags:
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
- Policy Type:
COMPLIANCE_POLICY - Policy Categories:
SECURITY
Logicβ
- π§ prod.logic.yamlπ’
- π AWS ECS Service
- π AWS ECS Service - object.extracts.yaml
- π§ͺ test-data.json
Similar Policiesβ
- AWS Security Hub: [ECS.2] ECS services should not have public IP addresses assigned to them automatically
Descriptionβ
Descriptionβ
This policy identifies AWS ECS Services that are configured to automatically assign public IP addresses to launched tasks. This option is available only when using the
awsvpcnetwork mode, which is required for the Fargate launch type.Rationaleβ
Assigning public IP addresses to ECS tasks allows them to be directly reachable from the public internet. This exposure increases the risk of unauthorized access, including network scanning, brute-force attempts, and exploitation of application vulnerabilities.
Backend services and internal applications should be deployed within private subnets that do not have direct inbound or outbound internet routes. External access should be managed through Load Balancers, while outbound access should be routed through NAT Gateways.
Auditβ
This policy marks an AWS ECS Service as
INCOMPLIANTif theAssign Public IPconfiguration is set to Enabled.Inactive ECS Services are marked as
INAPPLICABLE.
Remediationβ
Remediationβ
Update the ECS Service Network Configurationβ
Using the AWS CLIβ
Changing the network configuration triggers a new service deployment.
Prepare a
network-config.jsonfile. Ensure you include the correct subnets and security groups, but setassignPublicIpto DISABLED.{
"awsvpcConfiguration": {
"subnets": ["subnet-xxxx", "subnet-yyyy"],
"securityGroups": ["sg-xxxx"],
"assignPublicIp": "DISABLED"
}
}Run the update command:
aws ecs update-service \
--cluster {{cluster-name}} \
--service {{service-name}} \
--network-configuration file://network-config.json