Check ID:
Provider: AWS
Service:
Severity: CRITICAL
Categories:
Resource type:
ec2_instance_port_postgresql_exposed_to_internetProvider: AWS
Service:
ec2Severity: CRITICAL
Categories:
internet-exposedResource type:
AwsEc2InstanceWhat this check verifies
EC2 instances with security group rules allowing inbound PostgreSQL onTCP 5432 from the Internet (0.0.0.0/0 or ::/0) are identified, considering the instance’s public reachability via IP and subnet.
Risk
ExposedTCP 5432 enables unauthenticated Internet probes and brute-force attempts against PostgreSQL, risking database confidentiality, integrity, and availability. Attackers could dump data, alter schemas, create backdoor accounts, pivot within the VPC, or exploit unpatched flaws at scale.
Recommendation
Restrict PostgreSQL to trusted sources only:- Remove
0.0.0.0/0and::/0rules - Apply least privilege security groups (allow from app tier or VPN)
- Place instances in private subnets without public IPs
- Enforce TLS and strong auth; disable unused listeners
- Layer with NACLs and monitoring for defense in depth
Remediation
- CLI
- Terraform
- Native IaC
- Dashboard steps
aws ec2 revoke-security-group-ingress —group-id <SECURITY_GROUP_ID> —protocol tcp —port 5432 —cidr 0.0.0.0/0
References
- https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html
- https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/aws/EC2/unrestricted-postgresql-access.html
Where this check fires
This check runs on every scheduled scan against your AWS account. Findings appear at Cloud Security → Findings filterable byCheck ID = ec2_instance_port_postgresql_exposed_to_internet. To re-evaluate after a fix, hit Run now on the account’s schedule under Cloud Security → Schedules — the next scan re-checks this control and marks the finding fixed or keeps it persistent.
← Back to AWS checks