Check ID:
Provider: AWS
Service:
Severity: HIGH
Categories:
Resource type:
ec2_securitygroup_allow_ingress_from_internet_to_tcp_port_postgres_5432Provider: AWS
Service:
ec2Severity: HIGH
Categories:
internet-exposedResource type:
AwsEc2SecurityGroupWhat this check verifies
EC2 security groups are evaluated for inbound rules that expose Postgres onTCP 5432 to the Internet. Rules permitting 0.0.0.0/0 or ::/0 to this port, or policies that open all ports publicly, are identified.
Risk
Exposing5432 to the Internet enables credential stuffing and Postgres exploits, risking data disclosure (confidentiality), unauthorized changes (integrity), and service disruption via brute force or DoS (availability).
Recommendation
Apply least privilege on security groups: remove0.0.0.0/0 and ::/0 for 5432, allow only trusted CIDRs or private peers. Prefer private access (VPC-only) via VPN, bastion, or proxy. Add defense in depth with SG references and network ACLs, and enforce TLS and strong authentication.
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_securitygroup_allow_ingress_from_internet_to_tcp_port_postgres_5432. 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