Back to Checks
alibabacloud

A log monitoring and alert is set up for security group changes

sls_security_group_changes_alert_enabled
Service: slsSeverity: medium
OfficialBuilt-inVerified
Categories:logging
Resource Type:ALIYUN::SLS::Alert

Alibaba Cloud SLS should have an alarm configured for Security Group changes. By directing ActionTrail logs to SLS with alert rules, real-time monitoring is achieved. Security Groups are stateful packet filters controlling VPC ingress and egress traffic; monitoring their changes ensures network access modifications are promptly detected.

Risk

Without monitoring for security group changes, unauthorized modifications to network access controls may go undetected, leading to resources being exposed to untrusted networks. This increases risk of network exposure, unauthorized access, and lateral movement, potentially compromising confidentiality and availability of critical services.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler alibabacloud --checks sls_security_group_changes_alert_enabled

Recommendation

  1. Log on to the SLS Console
  2. Ensure ActionTrail is enabled
  3. Select Alerts
  4. Ensure alert rule has been enabled for security group changes

Remediation

CLI

aliyun sls create-alert --project <project-name> --alert-name security-group-changes --alert-displayname 'Security Group Changes Alert' --condition 'event.serviceName: Ecs and (event.eventName: AuthorizeSecurityGroup or event.eventName: RevokeSecurityGroup or event.eventName: CreateSecurityGroup or event.eventName: DeleteSecurityGroup)' --dashboard <dashboard-name> --schedule '{"type":"FixedRate","interval":"1m"}'

Other

1Log on to the **SLS Console**.
2Ensure **ActionTrail** is enabled and delivering logs to a **Log Service** project.
3Navigate to the project receiving ActionTrail logs.
4Select **Alerts** and click **Create Alert Rule**.
5Configure the query to filter for security group changes: `event.serviceName: Ecs and (event.eventName: AuthorizeSecurityGroup or event.eventName: RevokeSecurityGroup or event.eventName: CreateSecurityGroup or event.eventName: DeleteSecurityGroup)`.
6Set the alert **schedule**, **notification method**, and **severity**.
7Save and enable the alert rule.

Check Code

from prowler.lib.check.models import Check, CheckReportAlibabaCloud
from prowler.providers.alibabacloud.services.sls.sls_client import sls_client


class sls_security_group_changes_alert_enabled(Check):
    def execute(self) -> list[CheckReportAlibabaCloud]:
        findings = []
        found = False

        for alert in sls_client.alerts:
            query_list = alert.configuration.get("queryList", [])
            if not query_list:
                continue

            for query_obj in query_list:
                query = query_obj.get("query", "")
                if (
                    "CreateSecurityGroup" in query
                    or "AuthorizeSecurityGroup" in query
                    or "AuthorizeSecurityGroupEgress" in query
                    or "RevokeSecurityGroup" in query
                    or "RevokeSecurityGroupEgress" in query
                    or "JoinSecurityGroup" in query
                    or "LeaveSecurityGroup" in query
                    or "DeleteSecurityGroup" in query
                    or "ModifySecurityGroupPolicy" in query
                ):
                    found = True
                    report = CheckReportAlibabaCloud(
                        metadata=self.metadata(), resource=alert
                    )
                    report.status = "PASS"
                    report.status_extended = f"SLS Alert {alert.name} is configured for security group changes."
                    report.resource_id = alert.name
                    report.resource_arn = alert.arn
                    report.region = alert.region
                    findings.append(report)
                    break

            if found:
                break

        if not found:
            report = CheckReportAlibabaCloud(
                metadata=self.metadata(), resource=sls_client.provider.identity
            )
            report.status = "FAIL"
            report.status_extended = (
                "No SLS Alert configured for security group changes."
            )
            report.resource_id = sls_client.audited_account
            report.resource_arn = sls_client.provider.identity.identity_arn
            report.region = sls_client.region
            findings.append(report)

        return findings