Review ELB outbound access rules

Verify that the ELB can initiate required backend and health-check connections.

Description

Omitting egress rules on a new CloudFormation security group allows all outbound traffic by default. Check the effective rules in every group attached to the ELB, including standalone rules.

Potential impact

Blocking a required backend port can interrupt requests or health checks. Allowing every destination can let the ELB connect beyond its backends.

Remediation

Allow outbound connections to the backend and health-check destinations and ports. Configure the targets to accept connections from the ELB’s group. Security groups automatically permit replies to allowed connections. Test requests and health checks.

Examples

Supply the ELB’s VPC for VpcId, along with the listener and subnets omitted here.

Before

yaml
Resources:
  LoadBalancerSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: ELB security group
      VpcId: !Ref VpcId

  MyLoadBalancer:
    Type: AWS::ElasticLoadBalancing::LoadBalancer
    Properties:
      SecurityGroups:
        - !GetAtt LoadBalancerSecurityGroup.GroupId

After

yaml
Resources:
  LoadBalancerSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: ELB security group
      VpcId: !Ref VpcId
      SecurityGroupEgress:
        - IpProtocol: tcp
          FromPort: 80
          ToPort: 80
          CidrIp: 0.0.0.0/0

  MyLoadBalancer:
    Type: AWS::ElasticLoadBalancing::LoadBalancer
    Properties:
      SecurityGroups:
        - !GetAtt LoadBalancerSecurityGroup.GroupId

The second excerpt allows TCP 80 to every IPv4 destination. Narrow it to backend CIDRs or security groups. If the backend connection needs encryption, configure TLS for that connection.

References