More Info:
Ensure that no network security groups allow unrestricted inbound access on TCP ports 27017, 27018 and 27019.Risk Level
HighAddress
SecurityCompliance Standards
HITRUST, GDPR, SOC2, NISTCSF, PCIDSS, FedRAMPTriage and Remediation
- Remediation
Remediation
Using Console
Using Console
Sure, here are the step-by-step instructions to remediate unrestricted MongoDB access in Azure:
- Log in to the Azure portal (https://portal.azure.com/).
- Navigate to the “Azure Cosmos DB” service from the dashboard.
- Select the database account that has the unrestricted MongoDB access.
- Click on the “Firewalls and virtual networks” option from the left-hand side menu.
- Under the “Firewalls and virtual networks” tab, select “Selected networks” and then click on the “Add my IP” button.
- This will add your current IP address to the allowed list of IP addresses that can access the database.
- If you want to allow access from other IP addresses, you can add them by clicking on the “Add IP range” button.
- Once you have added the required IP addresses, click on the “Save” button to save the changes.
- After saving the changes, you can verify that the unrestricted MongoDB access has been remediated by attempting to access the database from an IP address that is not on the allowed list. You should receive an error message indicating that access is denied.
Using CLI
Using CLI
To remediate Unrestricted MongoDB Access in Azure using Azure CLI, you can follow the below steps:
- Open the Azure CLI on your local machine or use the Azure Cloud Shell.
-
Run the following command to list all the MongoDB accounts in your Azure subscription:
- Identify the MongoDB account that has unrestricted access.
-
Run the following command to update the MongoDB account to restrict access:
Replace
<resource-group-name>with the name of the resource group in which the MongoDB account is located and<mongodb-account-name>with the name of the MongoDB account that you want to update. - After running the above command, the MongoDB account will be updated to restrict access and will only be accessible from within the virtual network or via a private endpoint.
Using Python
Using Python
To remediate the Unrestricted MongoDB Access misconfiguration in Azure using Python, you can follow the below steps:Step 1: Install the Azure SDK for Python using pip command:Step 2: Use the below Python code to remediate the misconfiguration:In the above code, replace the placeholders
your-subscription-id, your-client-id, your-secret, your-tenant-id, your-resource-group-name, your-nsg-name and your-ip-address with your actual values.This code will remove the existing rule that allows unrestricted MongoDB access and create a new rule that allows access only from specific IP addresses.
