Overview
Services and databases store data that may be sensitive, protected by law, subject to regulatory requirements or compliance standards.
Review the affected security group and reduce its scope if possible.
We recommend accessing Elasticsearch only from within your VPC.
Remediation guidance
AWS remediation
Restrict Elasticsearch/OpenSearch ports 9200 and 9300 to trusted sources only.
Console
- Open affected security group.
- Remove 0.0.0.0/0 and ::/0 ingress on ports 9200 and 9300.
- Allow only trusted CIDRs or app security groups.
AWS CLI
aws ec2 revoke-security-group-ingress \
--group-id <sg-id> \
--ip-permissions IpProtocol=tcp,FromPort=9200,ToPort=9200,IpRanges='[{CidrIp=0.0.0.0/0}]'
aws ec2 revoke-security-group-ingress \
--group-id <sg-id> \
--ip-permissions IpProtocol=tcp,FromPort=9300,ToPort=9300,IpRanges='[{CidrIp=0.0.0.0/0}]'
References
- https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html
- https://docs.aws.amazon.com/cli/latest/reference/ec2/revoke-security-group-ingress.html
Service-wide remediation
Recommended when many resources are affected: fix the platform baseline first so new resources inherit the secure setting, then remediate the existing flagged resources in batches.
AWS
Use AWS Organizations guardrails, AWS Config rules or conformance packs where they fit, approved account baselines, and IaC modules so new resources inherit the secure setting.
Operational rollout
- Fix the baseline first at the account, subscription, project, cluster, or tenant scope that owns this control.
- Remediate the currently affected resources in batches, starting with internet-exposed and production assets.
- Re-scan and track approved exceptions with an owner and expiry date.
Query logic
These are the stored checks tied to this control.
Potential Elasticsearch database exposed to the internet (ports 9200 and/or 9300)
Connectors
Covered asset types
Expected check: eq []
{ securityGroups(where: {vms_NOT: null, rules_SOME: {direction: "Inbound", AND: [{OR: [{sources_INCLUDES: "cidr:0.0.0.0/0"}, {sources_INCLUDES: "cidr:::/0"}]}, {OR: [{destFromPort_LTE: 9200, destToPort_GTE: 9200}, {destFromPort_LTE: 9300, destToPort_GTE: 9300}]}]}}) {...AssetFragment}}
AWS