azure.network.no-ssh-from-internet

No network security group allows SSH from the internet

No inbound rule in any network security group allows TCP port 22 from an internet-wide source.

High Attested Preventive

Assertion

none(rules, r => r.direction == "Inbound" and r.access == "Allow" and source(r) ∩ {"*", "0.0.0.0/0", "/0", "::/0", "Internet"} ≠ ∅ and 22 ∈ ports(r))

Evaluated against az network nsg list --query "[].securityRules", collected daily.

Rationale

SSH exposed to the whole internet is a brute-force target from the minute the address is allocated, and a successful guess or leaked key is a shell on the machine. Administrative access belongs behind a bastion, a VPN, or Azure Bastion, where the set of sources is finite and the session is logged. A rule allowing port 22 from everywhere is almost always a leftover from initial setup, and this control exists so that it does not stay one.

Observation

The collector lists every network security group in each subscription and examines its securityRules. A rule fails the control when it is inbound, allows traffic, has a source that covers the whole internet, and has a destination port range that includes 22. The source check looks at both sourceAddressPrefix and sourceAddressPrefixes; the port check expands destinationPortRange and destinationPortRanges, including * and ranges such as 20-25. Rule priority is not considered: a permissive rule shadowed by a stricter one still fails, because the shadow can be removed.

Remediation

Delete the rule, or narrow its source to the address range of the bastion or VPN that administrators actually connect from. Where no fixed range exists, use Azure Bastion or just-in-time access, both of which open the port only for an approved session.