🛡️ 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 Type:
COMPLIANCE_POLICY - Policy Categories:
SECURITY
Logic
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.