Security groups must not expose unknown TCP ports to the entire internet because unknown or unapproved ports can host undocumented services and increase the attack surface for scanning and exploitation.
For AWS::EC2::SecurityGroup resources, this rule inspects each SecurityGroupIngress entry and flags entries that use CidrIp: 0.0.0.0/0 or CidrIpv6: ::/0 together with FromPort/ToPort values that are not present in the known TCP ports map. The check treats a missing or unrecognized FromPort or ToPort as a violation and also flags ranges where any port in FromPort..ToPort is unknown.
To remediate, restrict the CIDR to trusted IP ranges, use explicit approved ports, or reference other security groups instead.
Secure example (allow only a known public port (HTTPS) from the internet, and restrict SSH to a trusted IP range):
Resources:InstanceSecurityGroup:Type:AWS::EC2::SecurityGroupProperties:GroupDescription:Expose known ports to client hostVpcId:Ref:myVPCSecurityGroupIngress:- IpProtocol:tcpFromPort:20ToPort:23CidrIp:0.0.0.0/0
Non-Compliant Code Examples
Resources:InstanceSecurityGroup:Type:AWS::EC2::SecurityGroupProperties:GroupDescription:Expose unknown port to client hostVpcId:Ref:myVPCSecurityGroupIngress:- IpProtocol:tcpFromPort:23ToPort:25CidrIp:0.0.0.0/0
1
2
rulesets:- CloudFormation / AWS # Rules to enforce / AWS.
パーソナライズされたデモをリクエスト
Datadog を始める
Ask AI
AI-generated responses may be inaccurate. Verify important info.