๐ก๏ธ AWS EC2 Security Group allows unrestricted traffic to PostgreSQL๐ข
- Contextual name: ๐ก๏ธ Security Group allows unrestricted traffic to PostgreSQL๐ข
- ID:
/ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-postgres - Tags:
- ๐ข Policy with categories
- ๐ข Policy with type
- ๐ข Production policy
- Policy Type:
COMPLIANCE_POLICY - Policy Categories:
SECURITY
Logicโ
- ๐ง prod.logic.yaml๐ข
Similar Policiesโ
- Cloud Conformity: Unrestricted PostgreSQL Access
- Internal:
dec-x-ca1c0c0d
Similar Internal Rulesโ
| Rule | Policies | Flags |
|---|---|---|
| โ๏ธ dec-x-ca1c0c0d | 1 |
Descriptionโ
Descriptionโ
Audit and modify the AWS EC2 Security Group configurations to prevent unrestricted inbound access to PostgreSQL on port 5432. Security Groups should be configured to allow inbound access only from trusted IP addresses or internal networks, minimizing exposure to threats and ensuring database integrity.
Rationalโ
Allowing unrestricted access to PostgreSQL on port 5432 significantly increases the risk of malicious actors exploiting vulnerabilities, brute-force attacks, and unauthorized data access. PostgreSQL is a widely used relational database management system, and exposing it to the public internet can result in sensitive data being compromised. By restricting access to trusted sources, you limit the attack surface, ensuring the database remains secure and that only authorized users or systems can interact with it.
Impactโ
Requires careful implementation to avoid disrupting legitimate connections or business processes that require access to the database.
Auditโ
This policy marks an EC2 Security Group as
INCOMPLIANTif it contains a rule that meets all the following conditions:... see more
Remediationโ
Remediationโ
From Command Lineโ
- Run the following command to remove or modify the unrestricted rule for PostgreSQL access:
aws ec2 revoke-security-group-ingress \
--region {{region-name}} \
--group-id {{security-group-id}} \
--protocol {{protocol}} \
--port 5432 \
--cidr {{0.0.0.0/0 or ::/0}}
Optionally, run the
authorise-security-group-ingresscommand to create a new rule, specifying a trusted CIDR range instead of0.0.0.0/0.
- Confirm the changes by describing the security group again and ensuring the unrestricted access rule has been removed or appropriately restricted:
aws ec2 describe-security-groups \
--region {{region-name}} \
--group-ids {{security-group-id}} \
--query 'SecurityGroups[*].IpPermissions[?FromPort==`5432`].{CIDR:IpRanges[*].CidrIp,Port:FromPort}'
- Monitor PostgreSQL access to ensure it's unaffected by the changes.