Skip to main content

More Info:

Internet Gateways that are enabled and attached to a VCN provide direct internet connectivity. Unnecessary internet gateways expand the network attack surface.

Risk Level

Medium

Address

Compliance, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • HIPAA
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • Reserve Bank of India (RBI) Cyber Security Framework
  • Reserve Bank of India (RBI) Master Direction – Information Technology Framework
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

Below are step‑by‑step remediation options in the OCI Console for the issue
“OCI Network Internet Gateways Should Not Be Exposed” in the context of OCI Networking / Monitoring (e.g., flagged by Cloud Guard, Network Monitoring, or security posture tools).

1. Identify the Exposed Internet Gateway

  1. Sign in to the OCI Console.
  2. In the top-left, open the Navigation menuNetworkingVirtual Cloud Networks.
  3. Select the compartment where the issue was reported.
  4. Click the VCN in which the Internet Gateway (IGW) exists.
  5. In the left panel of the VCN details page, click Internet Gateways.
  6. Find the Internet Gateway flagged as exposed (or review each IGW):
    • Check State (should be “Available”).
    • Check if it is attached to route tables with 0.0.0.0/0 pointing to it.
If a security tool (Cloud Guard, etc.) gave you a specific IGW OCID or name, use that to find it.

2. If the Internet Gateway Is Not Needed → Disable or Delete It

A. Disable the Internet Gateway
  1. From the VCN → Internet Gateways list, click the IGW name.
  2. Click Edit.
  3. Uncheck Enable internet gateway.
  4. Click Save changes.
B. Delete the Internet Gateway (only if you are sure it’s not needed)
  1. Ensure no route table has this IGW as a target:
    • From VCN page, click Route Tables.
    • Open each Route Table and remove any rule with Target Type = Internet Gateway pointing to this IGW (see Section 3 below).
  2. Once no routes use it, go back to Internet Gateways.
  3. Click the Actions (⋮) menu next to the IGW → Terminate (or Delete).
  4. Confirm deletion.

3. If the Internet Gateway Must Exist → Remove or Restrict Public Routes

The exposure usually comes from default route 0.0.0.0/0 → Internet Gateway.

A. Remove the 0.0.0.0/0 Route to IGW (Preferred)

  1. From the VCN page, click Route Tables.
  2. For each Route Table associated with public subnets:
    • Click the route table name.
    • Click Edit.
    • For any route rule with:
      • Destination CIDR Block = 0.0.0.0/0 and
      • Target Type = Internet Gateway (your IGW),
    • Click the trash icon to remove that rule.
    • Optionally, add a more restrictive rule (e.g., specific CIDRs if you must allow certain IP ranges).
    • Click Save changes.
If the subnet no longer needs internet access at all, it’s now effectively private.

B. Use NAT Gateway or Service Gateway Instead of IGW (For Private Egress)

If workloads only need outbound access (no inbound from Internet):
  1. From Navigation menuNetworkingVirtual Cloud Networks → open your VCN.
  2. In left panel, click NAT GatewaysCreate NAT Gateway (if not already present).
  3. Still in the VCN, go to Route Tables, edit the relevant route table:
    • Remove 0.0.0.0/0 → Internet Gateway.
    • Add 0.0.0.0/0 → NAT Gateway.
  4. Associate that route table with the subnets that should be private but require outbound Internet.
For OCI services (Object Storage, etc.) without public Internet:
  1. In VCN, click Service GatewaysCreate Service Gateway.
  2. Edit route tables:
    • Add route with Destination Type = Service CIDR (All OCI Services or specific service).
    • Target Type = Service Gateway.
  3. Remove any corresponding 0.0.0.0/0 → Internet Gateway if not required.

4. Tighten Security for Subnets Using IGW (If You Must Keep Public Access)

If you absolutely must keep an IGW and public subnet, limit exposure:

A. Restrict Security Lists or Network Security Groups (NSGs)

  1. From NetworkingVirtual Cloud Networks → open your VCN.
  2. For Security Lists:
    • Click Security Lists, open the list associated with the public subnet.
    • Edit Ingress Rules:
      • Remove or narrow any 0.0.0.0/0 rules, especially with wide ports (e.g., 0–65535).
      • Add only the minimal required IP ranges and ports (e.g., SSH from your office IP only).
    • Edit Egress Rules similarly, restricting if possible.
  3. For NSGs (recommended over security lists):
    • Click Network Security Groups.
    • Open the NSG associated with your instances.
    • Reduce rules from 0.0.0.0/0 to specific source CIDRs and ports.

5. Validate via Networking / Monitoring / Cloud Guard

  1. If using Cloud Guard:
    • Go to Navigation menuIdentity & SecurityCloud Guard.
    • Check Detections.
    • Confirm that the “Network Internet Gateways Should Not Be Exposed” problem is Resolved after your changes (may take a few minutes).
  2. If using Network Monitoring / VCN Flow Logs:
    • Verify that no unexpected inbound traffic from unknown internet IPs is reaching formerly exposed subnets.
  3. Optionally run an updated Security Assessment / Vulnerability scan to confirm no open/public endpoints remain unintentionally exposed.

Summary remediation pattern (OCI Console):
  • If IGW unnecessary → Disable or Delete it.
  • If IGW required → remove 0.0.0.0/0 routes or move subnets to NAT/Service Gateway.
  • Where IGW and public subnets must exist → strict Security Lists/NSGs and narrow routes.
To “remediate” exposed Internet Gateways (IGs) in OCI via CLI, you typically:
  1. Identify all Internet Gateways and which are “exposed”
  2. Stop exposure by:
    • Disabling or deleting the IG, and/or
    • Removing 0.0.0.0/0 routes that point to the IG
Below are step‑by‑step OCI CLI commands you can run.

0. Set up common variables


1. List Internet Gateways in a compartment

Look for:
  • "is-enabled": true
  • Attached "vcn-id": "..."
If you want to filter by VCN:
Note each internet-gateway-id that should not be exposed.

2. Find route tables that expose these IGs

For each IG:
Inspect the JSON for any route-rules with:
  • "destination": "0.0.0.0/0"
  • "network-entity-id": "<IG_OCID>"
To narrow with jq:
Any returned route tables are exposing the IG to the internet.

3. Remove 0.0.0.0/0 routes to the Internet Gateway

For each exposed route table, fetch its full config:
Edit rt.json and remove or change any rule like:
or (for newer APIs):
Keep only the desired rules.Then update the route table:
Repeat for all route tables exposing the IG.

4. Disable or delete unused Internet Gateways

If the IG should no longer be used at all:

Option A – Disable the Internet Gateway (safer)

This leaves the object but stops traffic.

Option B – Delete the Internet Gateway

Make sure no route table still references it.

5. (Optional) Verify that no IG is exposing 0.0.0.0/0

Quick cross-check:
If this returns nothing, there are no 0.0.0.0/0 routes via Internet Gateways in the compartment.
If you share a sample Cloud Guard / Monitoring finding (OCID or JSON), I can translate it to exact CLI commands for that specific IG and route table.
To “not expose” OCI Internet Gateways (IGWs), you generally need to:
  1. Detect IGWs in a tenancy/compartment.
  2. Find route tables that send 0.0.0.0/0 (and ::/0 for IPv6) to those IGWs.
  3. Either:
    • Remove or modify those route rules, or
    • Disable/delete the IGW if not needed.
Below is a concise, step‑by‑step approach and a Python example using the OCI SDK.

1. Prerequisites

  • Install SDK:
  • Configure ~/.oci/config with at least:
    • tenancy
    • user
    • fingerprint
    • key_file
    • region
Example profile [DEFAULT] is assumed.

2. Decide What “Not Exposed” Means for Your Policy

Pick your policy, for example:
  • Strict: No route rule anywhere with 0.0.0.0/0 or ::/0 using an Internet Gateway.
  • Conditional: Only allow from specific VCNs/compartments; everything else is remediated.
In the example below, we:
  • Flag any route rule with:
    • cidr_block == "0.0.0.0/0" or destination == "0.0.0.0/0"
    • destination_type == "CIDR_BLOCK"
    • network_entity_id == an IGW OCID
  • And delete those route rules.
You can adapt to instead:
  • Replace the IGW with a NAT Gateway, or
  • Narrow the CIDR to a specific external subnet, etc.

3. Python Script – Monitor and Remediate IGW Exposure


4. Using This for “Monitoring”

To turn this into ongoing monitoring:
  1. Keep DRY_RUN = True and:
    • Run it periodically from:
      • OCI Functions (wrapped in a function)
      • OCI DevOps/Code pipelines or an external CI
      • A cron job on a bastion host
    • Send output to:
      • OCI Logging / Logging Analytics
      • Email / Slack via extra code.
  2. For auto-remediation:
    • Set DRY_RUN = False in a controlled environment.
    • Optionally restrict to specific compartments.

5. Optional: Hardening IGWs Further

If you want stricter remediation, after cleaning routes you can:
  • Disable an IGW (is_enabled=False via update_internet_gateway).
  • Or delete unused IGWs (delete_internet_gateway) if no more routes reference them.
If you specify your exact policy (e.g., “no IGW at all in compartment X”), I can adjust the code to enforce that explicitly.
Disabling enabled is an in‑place update on oci_core_internet_gateway and does not force replacement of the gateway (no outage from the resource being recreated, but any existing routes to it will stop providing internet connectivity).To verify, terraform plan should show only an in-place update on oci_core_internet_gateway.this with enabled changing from true to false and no resources marked -/+ (replace) or - (destroy) unless you intentionally removed other configuration.