Azure RDP rule public-access scope needs review

Restrict RDP connections to approved management paths and addresses.

Description

Limit TCP 3389 in the Azure NSG to the management network that needs RDP. For Azure Bastion or a VPN, use the source range the target VM actually sees.

Potential impact

External clients can attempt to sign in if the VM has a public path and an RDP listener. Account authentication and the host firewall still apply.

Remediation

Check effective rules and priorities at both the subnet and NIC. Apply the same intent in the host firewall, then test a new RDP connection through the approved path and confirm that another source is blocked.

Examples

Both examples use the same priority-100 inbound rule on the same NSG. Configure the management path separately.

Before

hcl
resource "azurerm_network_security_rule" "rdp_open" {
  name                        = "allow-rdp"
  priority                    = 100
  direction                   = "Inbound"
  access                      = "Allow"
  protocol                    = "TCP"
  source_port_range           = "*"
  destination_port_range      = "3389"
  source_address_prefix       = "*"
  destination_address_prefix  = "*"
  resource_group_name         = azurerm_resource_group.example.name
  network_security_group_name = azurerm_network_security_group.example.name
}

The wildcard source (*) permits TCP 3389 from every address.

After

hcl
resource "azurerm_network_security_rule" "rdp_open" {
  name                        = "allow-rdp"
  priority                    = 100
  direction                   = "Inbound"
  access                      = "Allow"
  protocol                    = "TCP"
  source_port_range           = "*"
  destination_port_range      = "3389"
  source_address_prefix       = "10.20.0.0/24"
  destination_address_prefix  = "*"
  resource_group_name         = azurerm_resource_group.example.name
  network_security_group_name = azurerm_network_security_group.example.name
}

The second limits only the source to 10.20.0.0/24. Supply the actual management range and check whether another matching rule allows traffic from the remaining addresses.

References