Network ACL rule allows SSH from an unrestricted address range

Restrict network ACL SSH access to management paths.

Description

This inbound rule allows TCP port 22 from 0.0.0.0/0 (all IPv4 addresses) or ::/0 (all IPv6 addresses). A matching rule with a lower number takes precedence.

Potential impact

Where routing, security groups and the SSH service permit the connection, unnecessary sources can attempt to sign in.

Remediation

Restrict inbound SSH to approved management networks and allow outbound replies to the management clients’ ports. Verify that a new SSH connection succeeds from an approved network and is blocked from an unapproved network.

Examples

Rule 100 narrows only the source to 10.3.0.0/18. Replace it with your management range and supply aws_vpc.main, the subnet association and outbound rules separately.

Before

hcl
resource "aws_network_acl" "example" {
  vpc_id = aws_vpc.main.id

  ingress {
    protocol   = "tcp"
    rule_no    = 100
    action     = "allow"
    cidr_block = "0.0.0.0/0"
    from_port  = 22
    to_port    = 22
  }
}

After

hcl
resource "aws_network_acl" "example" {
  vpc_id = aws_vpc.main.id

  ingress {
    protocol   = "tcp"
    rule_no    = 100
    action     = "allow"
    cidr_block = "10.3.0.0/18"
    from_port  = 22
    to_port    = 22
  }
}

References