Overview
Create an Activity Log Alert for the Create or Update Network Security Group event.
Rationale
Monitoring for Create or Update Network Security Group events gives insight into network access changes and may reduce the time it takes to detect suspicious activity.
Default Value
By default, no monitoring alerts are created.
Remediation guidance
Remediate from Azure Portal
- Navigate to the
Monitorblade. - Select
Alerts. - Select
Create. - Select
Alert rule. - Choose a subscription.
- Select
Apply. - Select the
Conditiontab. - Click
See all signals. - Select
Create or Update Network Security Group (Network Security Group). - Click
Apply. - Select the
Actionstab. - Click
Select action groupsto select an existing action group orCreate action groupto create a new one. - Follow the prompts to choose or create an action group.
- Select the
Detailstab. - Select a
Resource group, and provide anAlert rule nameand an optionalAlert rule description. - Click
Review + create. - Click
Create.
Remediate from Azure CLI
az monitor activity-log alert create --resource-group "<resource_group_name>" --condition category=Administrative and operationName=Microsoft.Network/networkSecurityGroups/write and level=verbose --scope "/subscriptions/<subscription ID>" --name "<activity_log_rule_name>" --subscription <subscription_id> --action-group <action_group_ID>
Remediate from PowerShell
Create the Conditions object.
$conditions = @()
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Administrative -Field category
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Microsoft.Network/networkSecurityGroups/write -Field operationName
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Verbose -Field level
Retrieve the Action Group information, store it in a variable, and then create the Actions object.
$actionGroup = Get-AzActionGroup -ResourceGroupName <resource_group_name> -Name <action_group_name>
$actionObject = New-AzActivityLogAlertActionGroupObject -Id $actionGroup.Id
Create the Scope object
$scope = "/subscriptions/<subscription id>"
Create the Activity Log Alert Rule for Microsoft.Network/networkSecurityGroups/write
New-AzActivityLogAlert -Name "<activity_log_alert_rule_name>" -ResourceGroupName "<resource_group_name>" -Condition $conditions -Scope $scope -Location global -Action $actionObject -Subscription <subscription_ID> -Enabled $true
Service-wide remediation
Recommended when many resources are affected: fix the platform baseline first so new resources inherit the secure setting, then remediate the existing flagged resources in batches.
Azure
Use management group or subscription Azure Policy assignments, remediation tasks where supported, landing-zone standards, and IaC modules so drift is prevented at scale.
Operational rollout
- Fix the baseline first at the account, subscription, project, cluster, or tenant scope that owns this control.
- Remediate the currently affected resources in batches, starting with internet-exposed and production assets.
- Re-scan and track approved exceptions with an owner and expiry date.
Query logic
These are the stored checks tied to this control.
Activity Log Alert exists for Create or Update Network Security Group
Connectors
Covered asset types
Expected check: eq []
query ($subscriptionResourceId: String!) {
AzureActivityLogAlertsForAction(
subscriptionResourceId: $subscriptionResourceId
equals:"microsoft.network/networksecuritygroups/write"){...AssetFragment}}
Microsoft Azure