More Info:
Database instances should not be publicly accessible. Public database endpoints are continuously scanned by attackers and are a primary vector for data breaches.Risk Level
CriticalAddress
Compliance, SecurityCompliance Standards
- APRA CPS 234 (Australia)
- AWS Startup Security Baseline
- AWS Well Architected Framework
- 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)
- FedRAMP
- GDPR
- HIPAA
- HITRUST CSF
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST
- NIST CSF
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- PCI
- 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
Remediation
Using Console
Using Console
To make sure databases used with OCI Database Management/Monitoring are not publicly accessible, you need to (a) stop public endpoints and (b) use private endpoints / private subnets. Below are step‑by‑step console instructions.
1. Autonomous Databases (ADB) – move to private access
You cannot flip an existing public ADB to private; you must create (or clone) one with private endpoint access and then migrate.1.1 Check if your ADB is public
- In the OCI Console, go to: Menu → Oracle Database → Autonomous Database.
- Select your compartment.
- Open your Autonomous Database.
- On the Details page, look at:
- Access Type / Network Access or
- Access Control
If it shows things like “Allow secure access from everywhere”, “Allow public endpoint access”, or similar, it is public.
1.2 Create a new ADB with private endpoint
- In the Autonomous Databases page, click Create Autonomous Database.
- Fill in basic details (name, workload type, license, etc.).
- Under Network access / Access type:
- Select Private endpoint access only (or “Secure access from private endpoints only”).
- Choose your VCN and private subnet (subnet should:
- Have no route to an Internet Gateway.
- Be associated with a security list/NSG that does not allow
0.0.0.0/0on DB ports).
- Optionally specify Network Security Groups (NSG) that limit access to only your app / monitoring subnets.
- Click Create Autonomous Database.
1.3 Migrate data and cut over
- Use your preferred method (Data Pump, GoldenGate, DB links, etc.) to move data from the old (public) ADB to the new (private) ADB.
- Update application and Database Management monitoring connections to point to the new private ADB (via private IP / private endpoint).
- When fully validated, terminate the old public ADB:
- Open the old ADB → More Actions → Terminate.
2. DB Systems / Bare Metal / VM Databases – remove public exposure
For DB Systems, you must ensure the underlying compute has no public IP and sits in a private subnet with restricted security rules.2.1 Identify DB Systems with public IP
- Go to Menu → Oracle Database → DB Systems (or VM/BM DB Systems).
- Open each DB System and note the subnet.
- Go to Menu → Core Infrastructure → Networking → Virtual Cloud Networks.
- Open the relevant VCN → click Subnets, select the subnet:
- Check if its route table has a route to an Internet Gateway.
- Check Security Lists and/or NSGs for rules allowing
0.0.0.0/0on DB ports (e.g., 1521).
2.2 Remove public IPs from the database host
- Go to Menu → Compute → Instances.
- Find the compute instance(s) associated with your DB System (usually named similarly).
- Click the instance → go to Attached VNICs.
- Click the primary VNIC.
- Under Resources → IP Addresses:
- If a Public IP is attached:
- Click the public IP.
- Click Actions → Unassign.
- If you cannot remove it (or the subnet is inherently public), you must:
- Create a new private subnet (no IGW route, see next step), and
- Recreate the DB System in that subnet, then migrate databases.
- If a Public IP is attached:
2.3 Ensure the subnet is private
- In Networking → Virtual Cloud Networks, open your VCN.
- Click Route Tables → open the route table used by the DB’s subnet.
- Confirm:
- There is no route to an Internet Gateway.
- If outbound internet is needed, use a NAT Gateway, not IGW:
- Add route:
0.0.0.0/0→ NAT Gateway.
- Add route:
- Click Subnets, open the DB subnet, confirm it uses this route table.
2.4 Restrict security lists / NSGs
- In the VCN, go to Security Lists and/or Network Security Groups used by the DB subnet/DB host.
- Edit Ingress Rules:
- Remove any rule like:
Source CIDR: 0.0.0.0/0withDestination Port: 1521(or other DB ports).
- Add rules that:
- Restrict
Sourceto only:- Your app subnets, and/or
- Subnets/hosts that run Database Management/Monitoring agents.
- Restrict
- Remove any rule like:
- If you use NSGs:
- Go to Network Security Groups → [Your NSG] → Ingress Rules.
- Apply the same restrictions.
3. Configure Database Management (Monitoring) over private network
Database Management does not require the database to be public; it can connect via private IP within the VCN.3.1 Ensure a private path between DB and monitoring
- If using Database Management with agents:
- Deploy the agent in:
- The same subnet as the DB, or
- A peered VCN with route and security rules allowing connectivity.
- Verify security lists/NSGs allow traffic between:
- Agent subnet → DB subnet on DB listener port (e.g., 1521).
- Deploy the agent in:
- If using Direct Connectivity from OCI services:
- Ensure the service subnet and DB subnet can communicate privately (VCN routing, no IGW needed).
3.2 Enable Database Management for the database
- Go to Menu → Observability & Management → Database Management.
- Click Managed Databases.
- Click Register / Enable:
- Select your database (ADB or DB System).
- Configure credentials, connection details (private host/SCAN, service name).
- Ensure hostname/IP used is the private address, not a public IP.
4. Verification
- From Networking → Public IPs, confirm:
- No public IP is assigned to DB hosts or DB endpoints.
- From your on-prem or external network:
- Confirm DB listener ports (e.g., 1521) are not reachable from the public internet.
- In Database Management → Managed Databases:
- Confirm the databases show as Active and metrics are being collected via the private network.
Using CLI
Using CLI
Below are minimal, CLI‑only steps to make OCI database instances non‑public while keeping them usable for Database Monitoring.Assumptions:
Get the compute instance(s) backing the DB system:(If you already know the instance OCID(s), skip to next step.)List VNIC attachments for each instance:Get VNIC details:
Remove the public IP from that private IP:Verify:
List security lists:Look for ingress rules that allow If you use NSGs instead of security lists, do the equivalent:
If metrics and DB Management targets are healthy, the DB is non‑public and still fully monitored.
If you share whether your databases are DB Systems, Exadata VM Clusters, or autonomous DBs, I can give the exact CLI variants for that type.
- You have
ociCLI configured. - Databases are running on DB Systems (VM/BM) or on Compute with agents.
- Goal: remove public IPs and block internet ingress on DB ports.
1. Identify DB systems and their VNICs
- If
"public-ip"is non‑null → this DB node is publicly reachable.
2. Remove any public IP from DB VNICs
Get private IP OCID associated with the VNIC:public-ip should now be null.Repeat for all DB nodes.3. Ensure subnet is not effectively public (security lists / NSGs)
3.1. Find subnet and security lists
0.0.0.0/0 to DB ports (e.g., 1521, 3306, 5432).3.2. Replace ingress rules with restricted ones
- Create a file
ingress-rules.jsonwith only trusted sources (for example, app subnets or on‑prem CIDRs). Example pattern:
- Export existing egress rules to reuse:
- Update the security list:
4. Verify Database Monitoring still works
Database Monitoring (via Management Agent / Database Management) needs only private network reachability, not public internet.- Confirm DB is reachable from the Management Agent subnet or OCI service VCN.
- Verify DB Management status (if used) via CLI:
- Run a test metric fetch:
If you share whether your databases are DB Systems, Exadata VM Clusters, or autonomous DBs, I can give the exact CLI variants for that type.
Using Python
Using Python
To make OCI database targets non‑public using Python, you remediate at the network/VNIC and DB config layers via the OCI Python SDK.Below is a concise, step‑by‑step approach with example code.
You’ll need the compartment OCID:
Option B – If the service supports a “private endpoint only” settingSome ADB flavors use a private endpoint (no public endpoint). Where supported, set the relevant field (for example,
In practice, you usually go from If the API rejects this on primary VNICs, you must instead use the “recreate in private subnet” path.
You would replace
If you share exactly which OCI DB types you’re monitoring (ADB Shared/DED, VM DB Systems, Exadata, etc.), I can adjust the Python examples to those specific APIs and flags.
1. Prerequisites
- Install SDK:
- Have an OCI config file (
~/.oci/config) with a profile (e.g.DEFAULT) that has rights to:- Read/update DB resources
- Read/update VNICs / security lists / NSGs
2. Autonomous Databases – Disable Public Access / Restrict Access
For Autonomous DBs, you can:- Disable public access entirely (where supported)
- Or enable access control and restrict IPs/network resources
2.1. List Autonomous Databases
2.2. Identify Publicly Accessible ADBs
Check flags such asis_access_control_enabled, and (if present) any is_public‑style attribute (varies by service type/region).2.3. Remediate: Enable Access Control / Remove Public Access
Option A – Enable access control and restrict by IP whitelist:private_endpoint_label / private endpoint configuration; actual field names vary by ADB type and region). That often requires creating the ADB with private endpoint; you cannot always flip from public → private in-place. In those cases:- Create a new ADB with
private_endpoint_label/ private endpoint config in a private subnet. - Migrate data.
- Decommission the public ADB.
3. DB Systems (VM/BM DBs) – Remove Public IPs and Lock Down Network
“Public” usually means:- VNIC has a public IP
- Subnet routes to Internet Gateway
- Security lists/NSGs allow 0.0.0.0/0 on DB ports
- Remove public IP from the DB node VNIC.
- Tighten security rules.
3.1. List DB Systems and Nodes
3.2. For Each DB System, Get VNICs and Public IPs
db_node.vnic_id if present, or from instance OCID. Example using db_node.vnic_id (commonly available):3.3. Remediate: Remove Public IP From VNIC
You cannot “unassign” a public IP on some primary VNICs in-place; the usual safe remediation patterns:- If it’s an ephemeral public IP:
- Delete the public IP object (where applicable) or update the VNIC to
assign_public_ip="NO"on secondary VNIC.
- Delete the public IP object (where applicable) or update the VNIC to
- If primary VNIC:
- Place DB System in a private subnet at creation time.
- So remediation can mean: create new DB system in private subnet, migrate DB, and then terminate the old system.
4. Tighten Security Lists / NSGs
Even without a public IP, avoid 0.0.0.0/0 on DB ports.Example for security lists:0.0.0.0/0 with your internal CIDRs.5. Integrating With “Database Monitoring”
If you’re using OCI Database Management / Monitoring:- Use the above logic in a reporting script that:
- Lists DB targets you monitor
- Flags those with public exposure
- Optionally:
- Trigger remediation functions (like the above) automatically.
- Or create a “dry run” mode that just prints what would be changed.
Using Terraform
Using Terraform
oci_database_db_system to use a different subnet_id (from a public to a private subnet) forces full replacement of the DB System, which means recreation of the database and associated downtime; plan and migration/backups must be handled carefully.To verify, terraform plan should show:- Creation of the new
oci_core_subnet.db_private_subnet(and NSG resources if added). - An update to
oci_database_db_system.db_systemchangingsubnet_id(andnsg_idsif used), with a-/+replacement indicator on the DB System resource.

