Back to Checks
oraclecloud

Event rule monitoring network gateway changes has notification actions configured

events_rule_network_gateway_changes
Service: eventsSeverity: high
OfficialBuilt-inVerified
Categories:logging
Resource Type:EventRule

OCI Events rules monitor network gateway lifecycle and attachment changes (DRG, Internet, NAT, Service, and Local Peering gateways) and include notification actions so changes generate alerts.

The evaluation looks for rules filtered to these events and confirms they trigger notifications.

Risk

Unalerted gateway changes can reroute traffic, expose services, or sever connectivity.

Attackers or misconfigurations may modify routes or attachments to enable data exfiltration, man-in-the-middle, or denial of service, degrading confidentiality, integrity, and availability.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler oraclecloud --checks events_rule_network_gateway_changes

Recommendation

Define event rules that match create, update, delete, attach, and detach actions for all gateway types and send notifications to monitored channels.

Apply least privilege on topics, cover all compartments/regions, integrate with SIEM, and use defense in depth with network change approvals.

Remediation

CLI

oci events rule create --compartment-id <example_resource_id> --display-name <example_resource_name> --condition '{"eventType":["com.oraclecloud.virtualnetwork.createdrg","com.oraclecloud.virtualnetwork.deletedrg","com.oraclecloud.virtualnetwork.updatedrg","com.oraclecloud.virtualnetwork.createdrgattachment","com.oraclecloud.virtualnetwork.deletedrgattachment","com.oraclecloud.virtualnetwork.updatedrgattachment","com.oraclecloud.virtualnetwork.changeinternetgatewaycompartment","com.oraclecloud.virtualnetwork.createinternetgateway","com.oraclecloud.virtualnetwork.deleteinternetgateway","com.oraclecloud.virtualnetwork.updateinternetgateway","com.oraclecloud.virtualnetwork.changelocalpeeringgatewaycompartment","com.oraclecloud.virtualnetwork.createlocalpeeringgateway","com.oraclecloud.virtualnetwork.deletelocalpeeringgateway.end","com.oraclecloud.virtualnetwork.updatelocalpeeringgateway","com.oraclecloud.natgateway.changenatgatewaycompartment","com.oraclecloud.natgateway.createnatgateway","com.oraclecloud.natgateway.deletenatgateway","com.oraclecloud.natgateway.updatenatgateway","com.oraclecloud.servicegateway.attachserviceid","com.oraclecloud.servicegateway.changeservicegatewaycompartment","com.oraclecloud.servicegateway.createservicegateway","com.oraclecloud.servicegateway.deleteservicegateway.end","com.oraclecloud.servicegateway.detachserviceid","com.oraclecloud.servicegateway.updateservicegateway"]}' --actions '{"actions":[{"actionType":"ONS","topicId":"<example_resource_id>"}]}'

Terraform

resource "oci_events_rule" "<example_resource_name>" {
  compartment_id = "<example_resource_id>"
  display_name   = "<example_resource_name>"

  # Critical: Monitor required network gateway event types
  condition = jsonencode({
    eventType = [
      "com.oraclecloud.virtualnetwork.createdrg",
      "com.oraclecloud.virtualnetwork.deletedrg",
      "com.oraclecloud.virtualnetwork.updatedrg",
      "com.oraclecloud.virtualnetwork.createdrgattachment",
      "com.oraclecloud.virtualnetwork.deletedrgattachment",
      "com.oraclecloud.virtualnetwork.updatedrgattachment",
      "com.oraclecloud.virtualnetwork.changeinternetgatewaycompartment",
      "com.oraclecloud.virtualnetwork.createinternetgateway",
      "com.oraclecloud.virtualnetwork.deleteinternetgateway",
      "com.oraclecloud.virtualnetwork.updateinternetgateway",
      "com.oraclecloud.virtualnetwork.changelocalpeeringgatewaycompartment",
      "com.oraclecloud.virtualnetwork.createlocalpeeringgateway",
      "com.oraclecloud.virtualnetwork.deletelocalpeeringgateway.end",
      "com.oraclecloud.virtualnetwork.updatelocalpeeringgateway",
      "com.oraclecloud.natgateway.changenatgatewaycompartment",
      "com.oraclecloud.natgateway.createnatgateway",
      "com.oraclecloud.natgateway.deletenatgateway",
      "com.oraclecloud.natgateway.updatenatgateway",
      "com.oraclecloud.servicegateway.attachserviceid",
      "com.oraclecloud.servicegateway.changeservicegatewaycompartment",
      "com.oraclecloud.servicegateway.createservicegateway",
      "com.oraclecloud.servicegateway.deleteservicegateway.end",
      "com.oraclecloud.servicegateway.detachserviceid",
      "com.oraclecloud.servicegateway.updateservicegateway"
    ]
  })

  actions {
    actions {
      # Critical: Add notification action so the rule passes the check
      action_type = "ONS"   # Sends to Notifications service (ONS)
      topic_id    = "<example_resource_id>"  # ONS topic OCID
    }
  }
}

Other

1In OCI Console, go to Observability & Management > Events Service > Rules
2Click Create rule and select the target Compartment
3Set Display name
4Under Matching events, add these Event types:
5- com.oraclecloud.virtualnetwork.createdrg
6- com.oraclecloud.virtualnetwork.deletedrg
7- com.oraclecloud.virtualnetwork.updatedrg
8- com.oraclecloud.virtualnetwork.createdrgattachment
9- com.oraclecloud.virtualnetwork.deletedrgattachment
10- com.oraclecloud.virtualnetwork.updatedrgattachment
11- com.oraclecloud.virtualnetwork.changeinternetgatewaycompartment
12- com.oraclecloud.virtualnetwork.createinternetgateway
13- com.oraclecloud.virtualnetwork.deleteinternetgateway
14- com.oraclecloud.virtualnetwork.updateinternetgateway
15- com.oraclecloud.virtualnetwork.changelocalpeeringgatewaycompartment
16- com.oraclecloud.virtualnetwork.createlocalpeeringgateway
17- com.oraclecloud.virtualnetwork.deletelocalpeeringgateway.end
18- com.oraclecloud.virtualnetwork.updatelocalpeeringgateway
19- com.oraclecloud.natgateway.changenatgatewaycompartment
20- com.oraclecloud.natgateway.createnatgateway
21- com.oraclecloud.natgateway.deletenatgateway
22- com.oraclecloud.natgateway.updatenatgateway
23- com.oraclecloud.servicegateway.attachserviceid
24- com.oraclecloud.servicegateway.changeservicegatewaycompartment
25- com.oraclecloud.servicegateway.createservicegateway
26- com.oraclecloud.servicegateway.deleteservicegateway.end
27- com.oraclecloud.servicegateway.detachserviceid
28- com.oraclecloud.servicegateway.updateservicegateway
29Add action: Notification, select the target Notifications (ONS) topic
30Click Create (ensure the rule is enabled)

Check Code

"""Check Ensure a notification is configured for network gateway changes."""

from prowler.lib.check.models import Check, Check_Report_OCI
from prowler.providers.oraclecloud.services.events.events_client import events_client
from prowler.providers.oraclecloud.services.events.lib.helpers import (
    check_event_rule_has_notification_actions,
    filter_rules_by_event_types,
)


class events_rule_network_gateway_changes(Check):
    """Check Ensure a notification is configured for network gateway changes."""

    def execute(self) -> Check_Report_OCI:
        """Execute the events_rule_network_gateway_changes check."""
        findings = []

        # Required event types for network gateway changes
        required_event_types = [
            "com.oraclecloud.virtualnetwork.createdrg",
            "com.oraclecloud.virtualnetwork.deletedrg",
            "com.oraclecloud.virtualnetwork.updatedrg",
            "com.oraclecloud.virtualnetwork.createdrgattachment",
            "com.oraclecloud.virtualnetwork.deletedrgattachment",
            "com.oraclecloud.virtualnetwork.updatedrgattachment",
            "com.oraclecloud.virtualnetwork.changeinternetgatewaycompartment",
            "com.oraclecloud.virtualnetwork.createinternetgateway",
            "com.oraclecloud.virtualnetwork.deleteinternetgateway",
            "com.oraclecloud.virtualnetwork.updateinternetgateway",
            "com.oraclecloud.virtualnetwork.changelocalpeeringgatewaycompartment",
            "com.oraclecloud.virtualnetwork.createlocalpeeringgateway",
            "com.oraclecloud.virtualnetwork.deletelocalpeeringgateway.end",
            "com.oraclecloud.virtualnetwork.updatelocalpeeringgateway",
            "com.oraclecloud.natgateway.changenatgatewaycompartment",
            "com.oraclecloud.natgateway.createnatgateway",
            "com.oraclecloud.natgateway.deletenatgateway",
            "com.oraclecloud.natgateway.updatenatgateway",
            "com.oraclecloud.servicegateway.attachserviceid",
            "com.oraclecloud.servicegateway.changeservicegatewaycompartment",
            "com.oraclecloud.servicegateway.createservicegateway",
            "com.oraclecloud.servicegateway.deleteservicegateway.end",
            "com.oraclecloud.servicegateway.detachserviceid",
            "com.oraclecloud.servicegateway.updateservicegateway",
        ]

        # Filter rules that monitor network gateway changes
        matching_rules = filter_rules_by_event_types(
            events_client.rules, required_event_types
        )

        # Create findings for each matching rule
        for rule, _ in matching_rules:
            report = Check_Report_OCI(
                metadata=self.metadata(),
                resource=rule,
                region=rule.region,
                resource_name=rule.name,
                resource_id=rule.id,
                compartment_id=rule.compartment_id,
            )

            # Check if the rule has notification actions
            if check_event_rule_has_notification_actions(rule):
                report.status = "PASS"
                report.status_extended = f"Event rule '{rule.name}' is configured to monitor network gateway changes with notifications."
            else:
                report.status = "FAIL"
                report.status_extended = f"Event rule '{rule.name}' monitors network gateway changes but does not have notification actions configured."

            findings.append(report)

        # If no matching rules found, create a single FAIL finding
        if not findings:
            report = Check_Report_OCI(
                metadata=self.metadata(),
                resource={},
                region="global",
                resource_name="Network Gateway Changes Event Rule",
                resource_id=events_client.audited_tenancy,
                compartment_id=events_client.audited_tenancy,
            )
            report.status = "FAIL"
            report.status_extended = (
                "No event rules configured to monitor network gateway changes."
            )
            findings.append(report)

        return findings