π 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
- 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-63737248
Similar Internal Rulesβ
Rule | Policies | Flags |
---|---|---|
βοΈ dec-x-63737248 | 1 |
Logicβ
- π§ prod.logic.yaml π’
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
INCOMPLIANT
if it contains a rule that meets all the following conditions:
- The
Direction
is 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-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==`27017`].{CIDR:IpRanges[*].CidrIp,Port:FromPort}'
- Monitor MongoDB access to ensure it's unaffected by the changes.