Security group egress allows all destination addresses

Restrict outbound destinations to the required scope and review permissions in other attached security groups.

Description

An outbound rule with 0.0.0.0/0 covers every IPv4 destination. With ::/0, it covers every IPv6 destination. The rule still limits traffic to its configured protocol and ports.

Potential impact

Where a route exists, a workload can connect to unapproved destinations. Omitting a required destination can also break updates or service calls.

Remediation

Specify the required ports and destination CIDRs, supported group references or prefix lists. Check all attached groups for broader IPv4 and IPv6 permissions and test the workload’s external dependencies. Creating a group without egress rules can add a default allow-all rule.

Examples

Both examples omit VpcId and require a default VPC in the Region. Security group state tracking allows replies to permitted inbound requests.

Before

yaml
Resources:
  InstanceSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Allow http to client host
      SecurityGroupEgress:
        - IpProtocol: tcp
          FromPort: 80
          ToPort: 80
          CidrIp: 0.0.0.0/0

The first allows only TCP 80 to every IPv4 destination.

After

yaml
Resources:
  InstanceSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Allow http to client host
      SecurityGroupEgress:
        - IpProtocol: tcp
          FromPort: 80
          ToPort: 80
          CidrIp: 192.0.2.0/24

The second keeps TCP 80. Replace the documentation destination 192.0.2.0/24 with the actual service range.

References