Description
To allow one client, use an IPv4 /32 or IPv6 /128. Both are valid source CIDRs for a single address.
Potential impact
Access can fail if a client’s address changes. Widening the CIDR grants access to other addresses in that network.
Remediation
Allow only the approved sources. If their addresses change frequently, update the rules or use a supported security group reference or managed access path. Verify a new connection from the intended client.
Examples
The second example expands TCP 80 access from individual hosts to an IPv4 /24 and an IPv6 /48. Use those ranges only if all of their addresses need access. Replace the documentation addresses and myVPC with actual values.
Before
yaml
Resources:
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
# Allow HTTP from the specified client addresses
GroupDescription: Allow http to client host
VpcId:
Ref: myVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 192.0.2.10/32
InboundRule:
Type: AWS::EC2::SecurityGroupIngress
Properties:
IpProtocol: tcp
FromPort: 80
ToPort: 80
GroupId: !GetAtt InstanceSecurityGroup.GroupId
CidrIpv6: 2001:db8:1234::10/128
After
yaml
Resources:
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
# Allow HTTP from the specified client networks
GroupDescription: Allow http to client host
VpcId:
Ref: myVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 192.0.2.0/24
InboundRule:
Type: AWS::EC2::SecurityGroupIngress
Properties:
IpProtocol: tcp
FromPort: 80
ToPort: 80
GroupId: !GetAtt InstanceSecurityGroup.GroupId
CidrIpv6: 2001:0DB8:1234::/48