The Cybermatic Signal · Fix-it Guides · Cloud · AWS
← All guides · Time to fix: 10 minutes per security group · AWS
An AWS security group rule that allows port 22 (SSH) or port 3389 (RDP) from 0.0.0.0/0 means any machine on the internet can attempt to log in to your server. This affects any EC2 instance attached to a permissive security group — a common setup that gets created during a quick launch and then forgotten. Closing the rule takes about ten minutes per security group, and you can do it without any downtime to the server itself.
The fix, verified
RDP or SSH open to the internet in a security group
| Severity | critical · AWS |
| Where to click | EC2 console → Security Groups → the group → Inbound rules → Edit: delete the 0.0.0.0/0 rule for 22/3389 and allow only your office IP, or remove it entirely and use AWS Systems Manager Session Manager (no open ports at all). |
| Or run | aws ec2 revoke-security-group-ingress --group-id sg-XXXXXXXX --protocol tcp --port 3389 --cidr 0.0.0.0/0 |
| Before you do | Run the command for port 22 as well if SSH is open. Confirm you have another way in (Session Manager or a VPN) before revoking. |
| Maps to | CIS AWS 5.2SOC2 CC6.6 |
A security group is AWS's built-in firewall for EC2 instances. An inbound rule for port 22 or 3389 with a source of 0.0.0.0/0 tells AWS to accept connection attempts from every IP address on the internet. Automated scanners find open RDP and SSH ports within minutes of a new instance launching. From there, attackers run credential-stuffing or brute-force tools around the clock. A realistic outcome: a developer spins up a Windows Server for testing, leaves the default RDP rule in place, uses a weak local administrator password, and returns the next morning to find the instance encrypted by ransomware and being used to attack other systems. The instance had no business data on it, but the AWS account itself is now compromised and the cleanup takes days.
In the AWS console, go to EC2 and open the Security Groups list. Sort or filter by inbound rules. Look for any group with a rule where the port is 22 or 3389 and the source is 0.0.0.0/0 or ::/0 (the IPv6 equivalent). You can also run a quick CLI check across your account to surface every group with these rules before touching anything.
You have two options. The first is to restrict access to a known IP address — your office, your VPN exit node, or your home IP. The second, and better, option is to remove the rule entirely and use AWS Systems Manager Session Manager, which gives you a shell or Remote Desktop session through the AWS console with no open inbound ports at all. Session Manager requires the SSM Agent to be running on the instance (it is pre-installed on most current AWS AMIs) and the instance to have an IAM role with the AmazonSSMManagedInstanceCore policy attached.
To remove the rule in the console: EC2 console → Security Groups → select the group → Inbound rules → Edit inbound rules → delete the row where the port is 3389 or 22 and the source is 0.0.0.0/0 → Save rules. If you want to restrict rather than remove, change the source from 0.0.0.0/0 to your specific IP address in CIDR notation (e.g., 203.0.113.45/32).
To remove the rule from the CLI, run the following command, replacing sg-XXXXXXXX with your actual security group ID:
aws ec2 revoke-security-group-ingress --group-id sg-XXXXXXXX --protocol tcp --port 3389 --cidr 0.0.0.0/0
Run the same command a second time for port 22 if SSH is also open, changing --port 3389 to --port 22.
If you revoke the rule before you have another way into the instance, you will lock yourself out. Before making any change, confirm that Session Manager is working — go to Systems Manager → Session Manager → Start session and verify your instance appears in the list. If it does not appear, check that the instance has an IAM instance profile with AmazonSSMManagedInstanceCore and that the SSM Agent is running. Alternatively, confirm your VPN or office IP is already allowed in a separate rule. Do not revoke the open rule until you have tested the alternative access method and can actually reach the instance through it.
One-time fixes drift. Attach an AWS Config rule — specifically the restricted-ssh and restricted-common-ports managed rules — to your account so that any security group that re-opens these ports to 0.0.0.0/0 triggers an alert or an automatic remediation action. If your team uses infrastructure as code, add a policy check in your CI pipeline (tools like Checkov or cfn-nag flag this pattern before anything is deployed). Review Security Hub findings weekly; it surfaces this misconfiguration under CIS AWS Foundations Benchmark control 5.2 automatically if Security Hub is enabled.
No. Security group changes take effect immediately but only affect new and existing network connections — the instance keeps running. Any active RDP or SSH session you are currently in may drop, so make sure you have Session Manager or another access method ready before you apply the change.
Session Manager is a feature of AWS Systems Manager that lets you open a browser-based shell or Remote Desktop connection to an EC2 instance through the AWS console, with no inbound port open and no SSH key required. There is no additional charge for Session Manager itself; you pay only for the EC2 instance as normal.
You can, but you will need to update the security group rule each time your IP changes, which becomes tedious quickly. A more reliable approach is to set up a small VPN (AWS Client VPN or a self-hosted option) with a stable endpoint, restrict the port to the VPN's IP, or switch to Session Manager entirely so no inbound port is needed at all.
Is this open in your environment?
Cybermatic checks for "RDP or SSH open to the internet in a security group" automatically — on every connected account, every day — and shows you the exact fix above next to each one it finds. The free scan takes about ten minutes and needs no credit card.
Run the free scan All guides →Part of The Cybermatic Signal. Written by the Cybermatic editorial agent from the configuration check Cybermatic runs for this setting (ID aws-open-admin-port) and reviewed before publication. The click path, command and caution in the fix card are the vendor's documented procedure as of 2026-10-24. Found an error? Write to info@cybermatic.ai.
BriefingIssuesFlashGuidesInsurance checkDomain checkSubscribe
Cybermatic.ai by Ironhawk Group · 9330 Lyndon B Johnson Fwy, Suite 900 · Dallas, TX 75243 · Privacy · cybermatic.ai