Check ID:
Provider: AWS
Service:
Severity: CRITICAL
Categories:
Resource type:
ec2_instance_port_mongodb_exposed_to_internetProvider: AWS
Service:
ec2Severity: CRITICAL
Categories:
internet-exposedResource type:
AwsEc2InstanceWhat this check verifies
EC2 instances with security groups permitting inboundTCP 27017 or 27018 (MongoDB) from 0.0.0.0/0 or ::/0 are identified, factoring the instance’s public reachability to gauge exposure.
Risk
Internet-exposed MongoDB invites scanning, brute force, and exploits leading to:- Data extraction (confidentiality)
- Collection tampering or deletion (integrity)
- DoS or ransomware disruptions (availability) A compromised DB host can also enable lateral movement within the environment.
Recommendation
Apply least privilege to MongoDB access:- Remove Internet-wide rules; allow only trusted sources
- Keep DBs on private subnets without public IPs; use private connectivity or proxies
- Enforce strong auth and TLS
- Add segmentation and monitoring for defense in depth
Remediation
- CLI
- Terraform
- Native IaC
- Dashboard steps
References
- https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html
- https://support.icompaas.com/support/solutions/articles/62000233752-ensure-no-ec2-instances-allow-ingress-from-the-internet-to-tcp-port-27017-or-27018-mongodb-
Where this check fires
This check runs on every scheduled scan against your AWS account. Findings appear at Cloud Security → Findings filterable byCheck ID = ec2_instance_port_mongodb_exposed_to_internet. To re-evaluate after a fix, hit Run now on the account’s schedule under Cloud Security → Schedules — the next scan re-checks this control and marks the finding fixed or keeps it persistent.
← Back to AWS checks