HTTP port open to all addresses

Review whether internet-wide TCP 80 access is needed, protect HTTP data in transit, and restrict access to internal services.

Description

Check which service listens on TCP 80 and who needs it. A public site may redirect HTTP to HTTPS, but the initial HTTP request travels in plaintext. Limit internal services to their clients.

Potential impact

Public addressing and a route can make the service reachable from outside. Data sent over HTTP can be read or modified even when the source is a private address.

Remediation

Restrict internal access to required CIDRs or source security groups. Review permissions in other attached groups. Send sensitive requests directly over HTTPS and validate the certificate. For public sites, check redirects, HSTS, secure cookies and application authentication and authorization.

Examples

Define myVPC for the target VPC. Configure the routes and listening service separately.

Before

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

The first rule allows TCP 80 from every IPv4 source through 0.0.0.0/0. For IPv6, ::/0 covers every source.

After

yaml
Resources:
  InstanceSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Allow http to client host
      VpcId:
        Ref: myVPC
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 80
          ToPort: 80
          CidrIp: 192.168.0.0/16

The second keeps TCP 80 and narrows only the source to 192.168.0.0/16. Use the actual client range and test both a permitted and a denied connection.

References