Description
For an HTTP service used only by internal clients, restrict ingress to approved CIDRs or a source security group. A public website can keep the ports its external clients need.
Potential impact
0.0.0.0/0 permits every IPv4 source. An internal service can then receive internet connections if public addressing, routes and other controls permit them.
Remediation
Review IPv4 and IPv6 rules separately. ::/0 includes every IPv6 source. Keep the necessary ports and test approved and unapproved connections to the resource using the group.
Examples
Supply the VPC ID as myVPC and attach the group to the intended resource. Both excerpts use TCP 80. The second narrows the source only if you give AllowedClientCidr an approved IPv4 range.
Before
Parameters:
myVPC:
Type: AWS::EC2::VPC::Id
Resources:
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: HTTP
VpcId: !Ref myVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
After
Parameters:
myVPC:
Type: AWS::EC2::VPC::Id
AllowedClientCidr:
Type: String
Resources:
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: HTTP
VpcId: !Ref myVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: !Ref AllowedClientCidr