More Info:
Ensure that Microsoft Azure network security groups (NSGs) do not allow unrestricted access (i.e. 0.0.0.0/0) on TCP port 135 in order to implement the principle of least privilege and effectively reduce the attack surface. Remote Procedure Call (RPC) TCP port 135 is used for client-server communications by Microsoft Message Queuing (MSMQ) as well as other Microsoft Windows/Windows Server software.Risk Level
HighAddress
SecurityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- DPDPA
- Digital Operational Resilience Act (EU)
- Essential 8
- FedRAMP
- GDPR
- HIPAA
- HITRUST CSF
- ISO 27001
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST CSF
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- PCI
- SOC2
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the “Unrestricted RPC Access” misconfiguration in Azure using the Azure Console, you can follow these steps:
- Log in to the Azure portal (https://portal.azure.com/).
- Navigate to the virtual machine that has the misconfiguration.
- Click on the “Networking” tab in the left-hand menu.
- Under “Inbound port rules”, click on “Add inbound port rule”.
- In the “Add inbound security rule” dialog box, fill in the following information:
- Name: A unique name for the rule (e.g., “RPC Access Restricted”).
- Priority: A number that determines the order in which the rule is applied (e.g., 100).
- Protocol: Select “TCP”.
- Port range: Enter “135-139, 445”.
- Action: Select “Deny”.
- Source: Select “Any”.
- Click “Add” to create the new rule.
- Repeat steps 4-6 for any other virtual machines that have the same misconfiguration.
Using CLI
Using CLI
To remediate unrestricted RPC access in Azure using Azure CLI, follow these steps:
- Open the Azure CLI command prompt.
-
Run the following command to get a list of all virtual machines in your Azure subscription:
az vm list --query "[].{Name:name, ResourceGroup:resourceGroup}"This will give you a list of all the virtual machines in your subscription along with their resource group names. - Identify the virtual machine that has unrestricted RPC access.
-
Run the following command to get the public IP address of the virtual machine:
az vm show -d -g <resource-group-name> -n <vm-name> --query publicIps -o tsvReplace<resource-group-name>with the name of the resource group where the virtual machine is located and<vm-name>with the name of the virtual machine. - Note down the public IP address of the virtual machine.
-
Run the following command to create a network security group:
az network nsg create -g <resource-group-name> -n <nsg-name>Replace<resource-group-name>with the name of the resource group where the virtual machine is located and<nsg-name>with a name for the network security group. -
Run the following command to create a rule in the network security group to block all incoming traffic on port 135:
az network nsg rule create -g <resource-group-name> --nsg-name <nsg-name> -n block-rpc --priority 100 --source-address-prefixes '*' --destination-port-ranges 135 --access Deny --protocol Tcp --description "Block all incoming traffic on port 135"Replace<resource-group-name>with the name of the resource group where the virtual machine is located and<nsg-name>with the name of the network security group that you created in step 6. -
Run the following command to associate the network security group with the virtual machine’s network interface:
az network nic update -g <resource-group-name> -n <nic-name> --network-security-group <nsg-name>Replace<resource-group-name>with the name of the resource group where the virtual machine is located,<nic-name>with the name of the virtual machine’s network interface, and<nsg-name>with the name of the network security group that you created in step 6. -
Verify that the network security group is associated with the virtual machine’s network interface by running the following command:
az network nic show -g <resource-group-name> -n <nic-name> --query networkSecurityGroupReplace<resource-group-name>with the name of the resource group where the virtual machine is located and<nic-name>with the name of the virtual machine’s network interface. -
Verify that the rule to block incoming traffic on port 135 is applied by running the following command:
az network nsg rule show -g <resource-group-name> --nsg-name <nsg-name> -n block-rpcReplace<resource-group-name>with the name of the resource group where the virtual machine is located and<nsg-name>with the name of the network security group that you created in step 6.
Using Python
Using Python
To remediate the Unrestricted RPC Access misconfiguration in AZURE using Python, you can follow the below steps:
-
Import the required Python libraries:
-
Authenticate with the Azure cloud using the
DefaultAzureCredentialclass: -
Instantiate a
NetworkManagementClientobject using thecredentialobject: -
Get the
SecurityGroupobject that contains the rule you want to remediate: -
Get the
SecurityRuleobject that contains the unrestricted RPC access: -
Update the
SecurityRuleobject to restrict the RPC access: -
Update the
SecurityGroupobject in Azure with the newSecurityRuleobject:
Using Terraform
Using Terraform
destination_port_range = "135" and source_address_prefix = "0.0.0.0/0", remove or modify that rule so that no rule on this NSG allows TCP 135 from 0.0.0.0/0.This change updates the NSG rule in-place (no NSG replacement), but it will immediately impact traffic to port 135 once applied.For verification, terraform plan should show that the old rule allowing 0.0.0.0/0 to TCP 135 is being removed or updated, and that the new/updated rule only allows TCP 135 from the specified restricted CIDR ranges.
