More Info:
Network Security Groups should not allow RDP (port 3389) access from 0.0.0.0/0. Public RDP is one of the most exploited attack vectors for ransomware and unauthorized access.Risk Level
CriticalAddress
Compliance, SecurityCompliance 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)
- 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
- 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 stop public RDP access in OCI Network Security Groups (NSGs) using the OCI Console, you need to:
- Find the NSG(s) with an ingress rule allowing TCP/3389 from 0.0.0.0/0 (or ::/0)
- Remove or restrict that rule
- (Optional) Use Monitoring/Alarms to detect if it reappears
1. Identify NSGs with Public RDP Access
- Sign in to the OCI Console.
- At the top, set the correct Region and Compartment (or choose the parent compartment and enable “Include subcompartments” where applicable).
- In the left menu, go to:
Networking → Network Security Groups. - For each NSG (or those linked to your Windows Compute instances):
- Click the NSG name.
- Go to the Ingress Rules tab.
- Look for rules with:
- Stateless/Stateful: Either
- Source Type: CIDR
- Source CIDR:
0.0.0.0/0(and/or::/0for IPv6) - IP Protocol:
TCP - Destination Port Range:
3389(or a range including 3389)
2. Remediate the NSG Rule (Stop Public RDP)
Option A – Delete the rule (recommended if not required)
- In the NSG Ingress Rules list, find the RDP rule (TCP 3389 from 0.0.0.0/0).
- Click the Actions menu (three dots) next to the rule.
- Click Remove (or Delete rule).
- Confirm deletion.
Option B – Restrict the rule to specific IPs (if RDP needed)
- In the same Ingress Rules list, click the Actions menu next to the RDP rule.
- Click Edit.
- Change:
- Source Type:
CIDR(orService/NSGif using internal access). - Source CIDR:
- Replace
0.0.0.0/0with your trusted IP/range, e.g.:- Single admin IP:
203.0.113.10/32 - Corporate egress range: e.g.
198.51.100.0/24
- Single admin IP:
- Replace
- Keep IP Protocol as
TCP. - Destination Port Range:
3389(or as needed).
- Source Type:
- Click Save changes.
Option C – Move security control from NSG to a bastion / VPN
If you prefer no direct RDP from the internet:- Remove public RDP rule from the NSG as in Option A.
- Use one of:
- OCI Bastion:
- Go to Identity & Security → Bastion.
- Create a bastion in the same VCN.
- Use Session types like RDP (via SSH tunnel or native where supported).
- Site-to-Site VPN / FastConnect:
- Ensure NSG ingress for RDP only from your on-prem CIDR, not the internet.
- Jump host in a private subnet and only allow SSH/RDP from trusted IPs.
- OCI Bastion:
3. Confirm Instance-Level Exposure
- Go to Compute → Instances.
- Select the Windows instance.
- In the Attached VNICs, note:
- NSG(s) attached to the VNIC.
- Public IP presence:
- If you remove the public IP, RDP is no longer directly exposed to the internet.
- If the instance does not need direct public RDP:
- Under the VNIC, detach or unassign the Public IP, and access through Bastion/VPN instead.
4. (Optional) Add Monitoring / Alerting for Public RDP in Networking
While OCI Monitoring is used primarily for metrics/alarms, for configuration-level findings (like public RDP) you typically use Cloud Guard:- Go to Identity & Security → Cloud Guard.
- Ensure a Cloud Guard Target is configured for your tenancy/compartments.
- In Detector Recipes, confirm detectors for:
- Public inbound access on sensitive ports (e.g., RDP – TCP/3389).
- Enable Responder Recipes or at least:
- Configure Notifications via Notifications → Topics (e.g., Email/Slack) so any new public RDP rule triggers an alert.
Quick Checklist
- Remove or edit NSG rules allowing TCP 3389 from
0.0.0.0/0or::/0. - Prefer access via OCI Bastion, VPN, or trusted IP/CIDR only.
- Confirm instances do not have unnecessary public IPs.
- Use Cloud Guard to monitor for new public RDP exposures.
Using CLI
Using CLI
Below is a simple, CLI‑only way to:
Optionally filter to a specific VCN:Copy the
Look for ingress rules with:Note the entire rule object; you will need to either remove it or edit it.
Open
Verify:Confirm that no
Use the IDs reported by this script, then fix each NSG as per steps 3–4.
If you want, share a sample
- Find NSG rules that allow public RDP (TCP/3389 from 0.0.0.0/0), and
- Remove or restrict those rules.
- You have
ociconfigured. - You know your
compartment-idandvcn-id(if you want to scope by VCN).
1. List NSGs in the compartment (optionally by VCN)
id of each NSG you want to check (e.g., NSG_OCID).2. Identify NSG rules that allow public RDP
For each NSG:protocol = "6"(TCP),isStateless = falseor true (either is fine),source = "0.0.0.0/0",- and
tcpOptions.destination-port-range.min = 3389andmax = 3389(or a range that includes 3389).
3. Export current rules as JSON (for safe editing)
nsg-rules.json and:-
Option A – Remove public RDP entirely:
Delete the rule objects that allow TCP/3389 from0.0.0.0/0. -
Option B – Restrict to specific source(s):
Change:to a more restrictive CIDR, for example:or your corporate IP range.
4. Update the NSG with the corrected rules
INGRESS rule remains with:source = "0.0.0.0/0",protocol = "6",- and port 3389 (or ranges including 3389).
5. Optional: Scripted detection of public RDP rules
Example usingjq to show NSGs with public RDP:If you want, share a sample
nsg-rules.json (with sensitive data removed) and I can show exactly what to edit.Using Python
Using Python
Below is a concise, step‑by‑step way to detect and remediate public RDP access in OCI Network Security Groups (NSGs) using Python and the OCI SDK.
1. Prerequisites
- Install the OCI Python SDK:
- Configure your OCI CLI/SDK credentials (
~/.oci/config):
2. Logic You Need
You want to:- List all NSGs in a compartment (or tenancy).
- For each NSG, list security rules.
- Identify rules that:
- Are ingress,
- Use TCP,
- Allow destination port 3389 (RDP),
- Have source CIDR
0.0.0.0/0or::/0.
- Remove or restrict those rules.
3. Python Script (Detect & Remediate)
This example:- Scans one compartment.
- Prints the violating rules.
- Optionally removes them (toggle
DRY_RUN).
4. How to Use This for Monitoring
- Keep
DRY_RUN = Trueand run the script on a schedule (e.g., cron / OCI Functions + Events) to only detect and report. - Send findings to:
- Logging (stdout + OCI Logging),
- Email (OCI Notifications),
- Ticketing system (via webhook/HTTP calls).
5. To Auto‑Remediate
- Set
DRY_RUN = Falsein automation context. - Optionally, instead of removing rules, modify them to a restricted CIDR (e.g., corporate IP range) by adjusting the
AddSecurityRuleDetailsfor matching rules rather than removing them.
Using Terraform
Using Terraform
oci_core_network_security_group_security_rule that allowed 0.0.0.0/0 on port 3389, Terraform will show that rule being destroyed and a new, more restrictive rule being created; this is a replacement of the rule resource (not the NSG itself) and will immediately stop public RDP once applied.For verification, terraform plan should show that any rule with source = "0.0.0.0/0" and destination_port_range 3389 is removed or updated so that:- no ingress rule on TCP/3389 has
source = "0.0.0.0/0", and - the new/updated rule uses a restricted CIDR or NSG source as in the snippet above.

