AWS security group allows RDP from all addresses

Limit RDP management access to approved administrators and network paths.

Description

Replace 0.0.0.0/0 in cidr_blocks with the source addresses on the approved RDP management path. Check IPv6 rules for the equivalent all-address range, ::/0.

Potential impact

An external client can attempt to sign in if the instance has a reachable address, a route and an RDP listener. Operating system authentication still applies.

Remediation

Verify administration over the VPN, bastion or management network. Check other groups, SSH and WinRM permissions, RDP authentication and patches, then test that an unapproved source cannot connect.

Examples

Check the target VPC and resource associations. To narrow only the rules on the existing allow-rdp group, keep its group-level description. Changing that field makes Terraform replace the group.

Before

hcl
resource "aws_security_group" "windows_admin" {
  name        = "allow-rdp"
  description = "RDP open to the internet"

  ingress {
    description = "RDP from anywhere"
    from_port   = 3389
    to_port     = 3389
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

The first rule allows TCP 3389 from all IPv4 sources.

After

hcl
resource "aws_security_group" "windows_admin" {
  name        = "allow-rdp"
  description = "RDP restricted to admin network"

  ingress {
    description = "RDP from admin network only"
    from_port   = 3389
    to_port     = 3389
    protocol    = "tcp"
    cidr_blocks = ["10.20.0.0/24"]
  }
}

Replace the example 10.20.0.0/24 with the actual administrator range and configure its route to the instance separately.

References