The Cybermatic Signal · Fix-it Guides · Cloud · Azure
← All guides · Time to fix: 15 minutes per NSG, once an alternative access method is con · Azure
An inbound NSG rule that allows port 3389 or 22 from Any or Internet means your virtual machine is reachable by every automated scanner on the internet. This affects any Azure subscription where a VM was stood up quickly or where a default rule was never tightened. Removing the rule and switching to a controlled access method takes about 15 minutes once you know which NSG is involved.
The fix, verified
RDP or SSH open to the internet in a network security group
| Severity | critical · Azure |
| Where to click | Azure portal → Network security groups → the NSG → Inbound security rules → delete the rule allowing Any/Internet on 3389 or 22. Use Azure Bastion or Microsoft Defender for Cloud just-in-time VM access instead. |
| Or run | az network nsg rule delete --resource-group RESOURCE-GROUP --nsg-name NSG-NAME --name RULE-NAME |
| Before you do | Confirm an alternative route (Bastion, VPN or JIT) before deleting the rule. |
| Maps to | CIS Azure 6.1-6.2SOC2 CC6.6 |
A network security group rule with source set to Any or Internet and destination port 3389 (RDP) or 22 (SSH) lets any IP address on the internet attempt a connection to that port. Automated scanners continuously probe the entire Azure public IP space; a newly deployed VM with this configuration will see login attempts within minutes of the public IP being assigned. A realistic outcome: a developer spins up a Windows Server VM for a quick test, leaves the default RDP rule in place, uses a weak local administrator password, and the account is compromised overnight. The attacker then uses that VM as a staging point inside your Azure environment.
Microsoft Defender for Cloud flags this automatically under its recommendations, but you can also check manually. In the Azure portal, go to Network security groups, open each NSG attached to a VM subnet or NIC, and look at Inbound security rules. Any rule where Source is Any or Internet and Destination port ranges includes 3389 or 22 is the problem. You can also run a quick CLI query across a subscription to surface all such rules at once rather than clicking through each NSG individually.
Before you delete anything, confirm that you have an alternative way to reach the VM — Azure Bastion, a site-to-site or point-to-site VPN, or Microsoft Defender for Cloud just-in-time VM access. Deleting the rule without an alternative in place will lock you out.
In the portal: Azure portal → Network security groups → select the NSG → Inbound security rules → find the rule allowing Any or Internet on port 3389 or 22 → click the rule → Delete. Confirm the deletion. If you are using Azure Bastion, no inbound NSG rule for RDP or SSH is needed at all; Bastion handles the connection over HTTPS from the portal.
From the CLI, run the following command, substituting your actual resource group name, NSG name, and rule name:
az network nsg rule delete --resource-group RESOURCE-GROUP --nsg-name NSG-NAME --name RULE-NAME
If you are using just-in-time VM access instead of Bastion, enable it in Defender for Cloud under Workload protections → Just-in-time VM access. JIT creates a deny rule by default and opens the port only for your specific IP, for a limited time window, on request.
The only thing that breaks is direct RDP or SSH from the internet, which is what you want to stop. The risk is locking yourself out if no alternative access path exists. Check the following before deleting: that Azure Bastion is deployed in the same virtual network (or a peered one), or that a VPN gateway is configured and your device has an active VPN connection, or that JIT is enabled and you have tested requesting access at least once. If you manage the VM through a third-party tool that connects over SSH from a fixed IP, you can replace the broad Any rule with a rule scoped to that specific IP address rather than deleting inbound SSH entirely — but a VPN or Bastion is still the cleaner long-term answer.
Assign the Azure Policy built-in definition 'Management ports should be closed on your virtual machines' to your subscription or management group. This policy flags any NSG that re-exposes 3389 or 22 to the internet and can be set to deny mode to block the misconfiguration at creation time. In Defender for Cloud, the recommendation 'Management ports of virtual machines should be protected with just-in-time network access control' will resurface if the rule comes back. Schedule a monthly review of NSG inbound rules as part of a standard access review, or use Azure Policy compliance reports to catch drift automatically.
Yes. Bastion connects to the VM over the Azure internal network; the connection from your browser to Bastion uses HTTPS on port 443. The VM itself does not need a public IP or an inbound NSG rule for RDP or SSH.
Restricting the source to a single known IP is significantly better than allowing Any, but it still exposes the port to brute-force if that IP is shared or changes. A VPN, Bastion, or JIT access is more reliable and is what CIS Azure 6.1-6.2 expects.
Defender for Cloud's recommendations list will show all affected VMs in one view. You can also use Azure Resource Graph or the CLI to query NSG rules across the subscription, filtering for rules where source address prefix is '*' or 'Internet' and the destination port includes 22 or 3389.
Is this open in your environment?
Cybermatic checks for "RDP or SSH open to the internet in a network security group" automatically — on every connected account, every day — and shows you the exact fix above next to each one it finds. The free scan takes about ten minutes and needs no credit card.
Run the free scan All guides →Part of The Cybermatic Signal. Written by the Cybermatic editorial agent from the configuration check Cybermatic runs for this setting (ID azure-open-admin-port) and reviewed before publication. The click path, command and caution in the fix card are the vendor's documented procedure as of 2026-10-28. Found an error? Write to info@cybermatic.ai.
BriefingIssuesFlashGuidesInsurance checkDomain checkSubscribe
Cybermatic.ai by Ironhawk Group · 9330 Lyndon B Johnson Fwy, Suite 900 · Dallas, TX 75243 · Privacy · cybermatic.ai