Azure No Security Contact Set - Security Rule
More Info:
Set at least one security contact.
Risk Level
Low
Address
Security
Compliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Using Console
To remediate the "No Security Contact Set" misconfiguration in Azure, you can follow these steps:
- Log in to the Azure portal (https://portal.azure.com).
- Navigate to the Security Center by clicking on the "Security Center" icon in the left-hand menu.
- In the Security Center, click on the "Secure score" tab in the left-hand menu.
- Scroll down to the "No security contact set" item in the list and click on it.
- Click on the "Remediate" button to the right of the item.
- In the "Remediation tasks" pane that appears, select the subscription(s) and resource group(s) that you want to apply the remediation to.
- Click on the "Remediate" button at the bottom of the pane to apply the remediation.
After completing these steps, Azure will set a security contact for the selected subscription(s) and resource group(s), which will ensure that security alerts and notifications are sent to the appropriate parties.
Using CLI
To remediate the "No Security Contact Set" misconfiguration in Azure using Azure CLI, you can follow these steps:
-
Open the Azure CLI and login to your Azure account.
-
Run the following command to get the list of security contacts set for your subscription:
az security contact list --query '[].{name:name,email:email}' --output tableIf the output is empty, it means that no security contact has been set for your subscription.
-
To set a security contact for your subscription, run the following command:
az security contact create --email <email_address> --name <name> --phone <phone_number>Replace
<email_address>,<name>, and<phone_number>with the appropriate values. -
Once the command is executed successfully, run the following command again to verify that the security contact has been set:
az security contact list --query '[].{name:name,email:email}' --output tableThe output should now show the security contact that you just set.
By following these steps, you have successfully remediated the "No Security Contact Set" misconfiguration in Azure using Azure CLI.
Using Python
To remediate the misconfiguration "No Security Contact Set" in Azure using Python, you can follow these steps:
- Import the necessary modules:
from azure.identity import DefaultAzureCredential
from azure.mgmt.security import SecurityCenter
- Authenticate to Azure using the
DefaultAzureCredential:
credential = DefaultAzureCredential()
- Create a
SecurityCenterclient object:
security_center_client = SecurityCenter(
credential=credential,
subscription_id="<subscription-id>"
)
Note: Replace <subscription-id> with your Azure subscription ID.
- Get the security contact for the subscription:
security_contact = security_center_client.security_contacts.get(
resource_group_name="<resource-group-name>",
security_contact_name="<security-contact-name>"
)
Note: Replace <resource-group-name> and <security-contact-name> with the appropriate values.
- If the
security_contactobject isNone, create a new security contact:
if security_contact is None:
security_center_client.security_contacts.create(
resource_group_name="<resource-group-name>",
security_contact_name="<security-contact-name>",
email="<email-address>",
phone="<phone-number>"
)
Note: Replace <email-address> and <phone-number> with the appropriate values.
- If the
security_contactobject is notNone, update the existing security contact:
else:
security_center_client.security_contacts.create_or_update(
resource_group_name="<resource-group-name>",
security_contact_name="<security-contact-name>",
email="<email-address>",
phone="<phone-number>"
)
Note: Replace <email-address> and <phone-number> with the appropriate values.
- Verify that the security contact has been set:
security_contact = security_center_client.security_contacts.get(
resource_group_name="<resource-group-name>",
security_contact_name="<security-contact-name>"
)
if security_contact is not None:
print("Security contact set successfully.")
else:
print("Failed to set security contact.")
That's it! These steps will remediate the misconfiguration "No Security Contact Set" in Azure using Python.
Using Terraform
resource "azurerm_security_center_contact" "security_contact" {
# ID must be 'default' in current Azure Security Center API
name = "default"
email = "SECURITY_CONTACT_EMAIL@example.com" # replace with your security contact email
phone = "+1-555-555-5555" # replace with your security contact phone (E.164 format)
alert_notifications = true # enable email notifications for alerts
alerts_to_admins = "On" # send alerts to subscription admins as well
}
This adds the required Security Center contact; it does not force replacement of other resources, only creates/updates this contact object. After you add it, terraform plan should show this resource with + create (or ~ update if it already exists but differs).