๐ก๏ธ AWS EC2 Security Group allows unrestricted traffic to MongoDB๐ข
- Contextual name: ๐ก๏ธ Security Group allows unrestricted traffic to MongoDB๐ข
- ID:
/ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mongodb - 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 MongoDB Access
- Internal:
dec-x-63737248
Similar Internal Rulesโ
| Rule | Policies | Flags |
|---|---|---|
| โ๏ธ dec-x-63737248 | 1 |
Descriptionโ
Descriptionโ
Audit and modify AWS EC2 Security Group rules to restrict access to MongoDB instances by blocking unrestricted inbound traffic to ports 27017 - 27020. The access should be limited to specific IP addresses or internal networks to reduce the risk of unauthorized access and potential data breaches.
Rationalโ
MongoDB is a NoSQL database, and exposing it to the open internet (e.g., via 0.0.0.0/0) poses a significant security risk. Unrestricted access can lead to data exfiltration, unauthorized changes, and other malicious activities. Restricting access to MongoDB to trusted IP ranges or systems ensures that only authorized users or applications can interact with the database, mitigating the risk of security breaches and reduces the attack surface.
Impactโ
Requires careful implementation to ensure legitimate users and systems maintain access.
Auditโ
This policy marks an EC2 Security Group as
INCOMPLIANTif it contains a rule that meets all the following conditions:
- The
Directionis set to Inbound.... see more
Remediationโ
Remediationโ
From Command Lineโ
- Run the following command to remove or modify the unrestricted rule for MongoDB access:
aws ec2 revoke-security-group-ingress \
--region {{region-name}} \
--group-id {{security-group-id}} \
--protocol {{protocol}} \
--port {{27017}} \
--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==`27017`].{CIDR:IpRanges[*].CidrIp,Port:FromPort}'
- Monitor MongoDB access to ensure it's unaffected by the changes.