More Info:

Ensure that no network security groups allow unrestricted inbound access via TCP or UDP on selected ports.

Risk Level

High

Address

Security

Compliance Standards

CISAZURE, CBP, HITRUST, GDPR, SOC2, NISTCSF, PCIDSS, FedRAMP

Triage and Remediation

Remediation

Sure, here are the step-by-step instructions to remediate the issue of unrestricted inbound TCP or UDP access on selected ports in Azure:

  1. Log in to the Azure portal using your credentials.
  2. Navigate to the ‘Security Center’ from the left-hand side menu.
  3. Click on ‘Security Alerts’ and then select the alert that says ‘Unrestricted inbound TCP/UDP access to a port in a Network Security Group (NSG)‘.
  4. Review the details of the alert, including the affected NSG and the specific port(s) that have unrestricted access.
  5. Click on the ‘Remediate’ button at the top of the alert details page.
  6. Select the ‘Deploy to Resource Group’ option and then click on ‘Create’.
  7. In the ‘Basics’ tab of the deployment wizard, select the affected subscription, resource group, and location.
  8. In the ‘Template’ tab, select the ‘Edit Template’ option and then make the following changes:
    • Under ‘parameters’, select the appropriate NSG from the dropdown menu.

    • Under ‘variables’, add a new variable for the port(s) that need to be restricted, such as:

      "restrictedPorts": {
          "value": [
            "22",
            "3389"
          ]
        }
      
    • Under ‘resources’, add a new resource for the NSG rule that will restrict access to the specified port(s), such as:

       {
           "type": "Microsoft.Network/networkSecurityGroups/securityRules",
           "apiVersion": "2021-02-01",
           "name": "restrictInboundPorts",
           "location": "[parameters('location')]",
           "dependsOn": [
               "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]"
           ],
           "properties": {
               "description": "Restrict inbound access to specified ports",
               "protocol": "Tcp",
               "sourcePortRange": "*",
               "destinationPortRange": "[variables('restrictedPorts')]",
               "sourceAddressPrefix": "*",
               "destinationAddressPrefix": "*",
               "access": "Deny",
               "priority": 200,
               "direction": "Inbound"
           }
       }
      
  9. Save the template and then click on Review + create.
  10. Review the deployment settings and then click on ‘Create’ to initiate the deployment.

Once the deployment is complete, the NSG rule will be in effect and inbound access to the specified port(s) will be restricted. You can verify the changes by reviewing the NSG rules in the Azure portal.