| name | cis-azure-foundations-7.2 |
| description | Ensure SSH access from the Internet is evaluated and restricted |
| category | cis-azure-foundations |
| version | 5.0.0 |
| author | cyberstrike-official |
| tags | ["cis","azure","networking","nsg"] |
| cis_id | 7.2 |
| cis_benchmark | CIS Microsoft Azure Foundations Benchmark v5.0.0 |
| tech_stack | ["azure"] |
| cwe_ids | [] |
| chains_with | ["cis-azure-foundations-7.1","cis-azure-foundations-7.3","cis-azure-foundations-7.4","cis-azure-foundations-7.11"] |
| prerequisites | [] |
| severity_boost | {} |
Ensure SSH access from the Internet is evaluated and restricted
Description
Network security groups should be periodically evaluated for port misconfigurations. Where SSH is not explicitly required and narrowly configured for resources attached to a network security group, Internet-level access to Azure resources should be restricted or eliminated.
Rationale
The potential security problem with using SSH over the Internet is that attackers can use various brute force techniques to gain access to Azure Virtual Machines. Once the attackers gain access, they can use a virtual machine as a launch point for compromising other machines on the Azure Virtual Network or even attack networked devices outside of Azure.
Impact
None documented. Restricting SSH access from the Internet is a security best practice with no negative functional impact when properly configured with alternative access methods such as VPN, ExpressRoute, or Azure Bastion.
Audit Procedure
Using Azure Portal
- Go to
Network security groups.
- Click the name of a network security group.
- Under
Settings, click Inbound security rules.
- Ensure that no inbound security rule exists that matches the following:
- Port:
22 or range including 22
- Protocol:
TCP or Any
- Source:
0.0.0.0/0, Internet, or Any
- Action:
Allow
- Repeat steps 1-4 for each network security group.
Using Azure Resource Graph
- Go to
Resource Graph Explorer.
- Click
New query.
- Paste the following into the query window:
resources | where type =~ "microsoft.network/networksecuritygroups" | project id, name, securityRule = properties.securityRules | mv-expand securityRule | extend access = securityRule.properties.access, direction = securityRule.properties.direction, protocol = securityRule.properties.protocol, destinationPort = case(isempty(securityRule.properties.destinationPortRange), securityRule.properties.destinationPortRanges, securityRule.properties.destinationPortRange), sourceAddress = case(isempty(securityRule.properties.sourceAddressPrefix), securityRule.properties.sourceAddressPrefixes, securityRule.properties.sourceAddressPrefix) | where access =~ "Allow" and direction =~ "Inbound" and protocol in~ ("tcp", "*") | mv-expand destinationPort | mv-expand sourceAddress | extend destinationPortMin = toint(split(destinationPort, "-")[0]), destinationPortMax = toint(split(destinationPort, "-")[-1]) | where (destinationPortMin <= 22 and destinationPortMax >= 22) or destinationPort == "" | where sourceAddress in~ ("*", "0.0.0.0", "internet", "any") or sourceAddress endswith "/0"