HIGH
Source
Trivy
Frameworks

CIS AWS 1.2

ID
AVD-AWS-0107

Security groups should not allow ingress from 0.0.0.0/0 or ::/0 to port 22 or port 3389.

Security groups provide stateful filtering of ingress and egress network traffic to AWS resources. It is recommended that no security group allows unrestricted ingress access to remote server administration ports, such as SSH to port 22 and RDP to port 3389.

Impact

Follow the appropriate remediation steps below to resolve the issue.

Set a more restrictive CIDR range

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Resources:
  GoodSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Limits security group egress traffic
      SecurityGroupIngress:
        - CidrIp: 127.0.0.1/32
          IpProtocol: "6"
          FromPort: 22
          ToPort: 22

Set a more restrictive CIDR range

1
2
3
4
resource "aws_security_group_rule" "good_example" {
  type        = "ingress"
  cidr_blocks = ["10.0.0.0/16"]
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
resource "aws_security_group_rule" "example" {
  type              = "ingress"
  security_group_id = "sg-123456"
  from_port         = 22
  to_port           = 22
  protocol          = "tcp"
  cidr_blocks = [
    "1.2.3.4/32",
    "4.5.6.7/32",
  ]
}