π 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
- Located in: π AWS EC2
Flagsβ
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
Our Metadataβ
- Policy Type:
COMPLIANCE_POLICY
- Policy Category:
SECURITY
Similar Policiesβ
- Cloud Conformity
- Internal
dec-x-ca1c0c0d
Similar Internal Rulesβ
Rule | Policies | Flags |
---|---|---|
βοΈ dec-x-ca1c0c0d | 1 |
Logicβ
- π§ prod.logic.yaml π’
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
INCOMPLIANT
if 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-ingress
command 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.