Open security groups: SSH, RDP, and databases reachable from anywhere
Firewall rules that allow 0.0.0.0/0 to management or database ports expose servers to constant scanning. How to find them across AWS, Azure, and GCP, and replace them with private access.
Diagram
Finding wide-open rules
Step 1 of 4
Query
List rules open to the internet on sensitive ports.
$ aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values=0.0.0.0/0 \
--query "SecurityGroups[].{id:GroupId,ports:IpPermissions[].FromPort}"
[{"id":"sg-0a1b","ports":[22,5432]}]The example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
Management ports
- What fails
- SSH (22) and RDP (3389) open to the internet see constant password guessing.
- Who is affected
- The server and anything it can reach.
- What you would notice
- Rules with 0.0.0.0/0 on 22 or 3389.
- What you change
- Use session manager, bastion, or identity-aware proxy access.
Database ports
- What fails
- Databases reachable from the internet rely only on their passwords.
- Who is affected
- All stored data.
- What you would notice
- Rules opening 3306, 5432, 1433, 6379, 9200, or 27017 publicly.
- What you change
- Keep databases on private subnets.
Temporary rules
- What fails
- Rules added for a quick test stay forever.
- Who is affected
- Whatever the rule exposes.
- What you would notice
- Rules with no description or owner.
- What you change
- Require descriptions and expire rules automatically.
Azure and GCP
The same query exists on each platform.
$ az network nsg list --query "[].securityRules[?sourceAddressPrefix=='*' && access=='Allow'].{name:name,port:destinationPortRange}" -o table
$ gcloud compute firewall-rules list --filter="sourceRanges:0.0.0.0/0" --format="table(name,allowed[].ports)"Check yourself
Recognition and the fix. Nothing here is a procedure.
Which replacement removes the need for public SSH on AWS?
Sibling techniques
Pages at the same depth, plus a lab and a glossary card for this one.
- 01Cloud security fundamentals: shared responsibility, identity, and the audit trailWhat the provider secures and what you do, why identity is the cloud perimeter, and the first read-only commands to understand an AWS, Azure, or Google Cloud account you are responsible for.
- 02Cloud accounts and container environmentsCloud failure is usually identity and exposure.
- 03Workload identity instead of static keysA long-lived access key on a laptop or in a repository is a session that does not expire.
- 04Public object storage: finding and closing open buckets and containersBuckets made public by mistake remain one of the most common cloud leaks.
- 05Disabled metadata protections: IMDSv2 and why it blunts SSRFCloud instance metadata services hand out credentials to code on the machine.