Description
Limit inbound TCP 3389 in the Azure NSG to approved administrator addresses or the RDP path you use, such as a VPN or Azure Bastion.
Potential impact
Allowing every source can invite unwanted sign-in attempts where a route to the VM exists. Review the host firewall, authentication and security updates as well.
Remediation
Prepare an alternative management connection. Check the effective IPv4 and IPv6 rules on the NIC and subnet. Give any required, narrowly scoped allow a lower priority number than the broad deny. Test new connections from the approved and blocked paths and check the VM logs.
Examples
The excerpts change a rule on the same NSG. Verify its NIC or subnet association, the VM address and routing separately.
Before
resource security_group 'Microsoft.Network/networkSecurityGroups@2020-11-01' = {
name: 'rdp-security-group'
location: resourceGroup().location
tags: {}
properties: {
securityRules: [
{
properties: {
description: 'access to RDP'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '3389'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 301
direction: 'Inbound'
}
name: 'rdp-rule'
}
]
}
}
At priority 301, Allow admits RDP from every source unless an earlier rule matches.
After
resource security_group 'Microsoft.Network/networkSecurityGroups@2020-11-01' = {
name: 'rdp-security-group'
location: resourceGroup().location
tags: {}
properties: {
securityRules: [
{
properties: {
description: 'access to RDP'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '3389'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Deny'
priority: 301
direction: 'Inbound'
}
name: 'rdp-rule'
}
]
}
}
Changing the same rule to Deny blocks new RDP connections that have no higher-priority allow.