More Info:
No security group should allow unrestricted inbound access to TCP port 9200 (Elasticsearch).Risk Level
MediumAddress
SecurityCompliance Standards
- APRA CPS 234 (Australia)
- AWS Startup Security Baseline
- AWS Well Architected Framework
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- Cloudanix Best Practice
- DPDPA
- Digital Operational Resilience Act (EU)
- Essential 8
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- Reserve Bank of India (RBI) Cyber Security Framework
- Reserve Bank of India (RBI) Master Direction – Information Technology Framework
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the issue of unrestricted Elasticsearch access in AWS, you can follow the below steps:
- Login to the AWS console and navigate to the Elasticsearch service.
- Select the Elasticsearch domain that needs to be remediated.
- Click on the “Modify access” button under the “Actions” dropdown.
- In the “Configure access” section, select the option “Limit access to specific IP addresses or VPCs”.
- Enter the IP addresses or CIDR blocks that should be allowed to access the Elasticsearch domain.
- Click on the “Submit” button to save the changes.
Using CLI
Using CLI
To remediate unrestricted Elasticsearch access in AWS using AWS CLI, follow these steps:
-
Open the AWS CLI and run the following command to list all Elasticsearch domains in your account:
- Identify the Elasticsearch domain that has unrestricted access.
-
Run the following command to update the Elasticsearch domain’s access policy to restrict access:
Replace
<domain-name>with the name of the Elasticsearch domain and<master-username>and<master-password>with the credentials for the Elasticsearch master user. -
Verify that access to the Elasticsearch domain is now restricted by running the following command:
This command should return the updated access policy for the Elasticsearch domain.
- Ensure that you have a backup of the Elasticsearch domain before making any changes to it.
Using Python
Using Python
To remediate unrestricted Elasticsearch access in AWS using Python, you can follow these steps:By following these steps, you can remediate unrestricted Elasticsearch access in AWS using Python.
- Install the AWS SDK for Python (Boto3) using the following command:
- Create an AWS Identity and Access Management (IAM) client using the following code snippet:
- Create an Elasticsearch service client using the following code snippet:
- Use the Elasticsearch service client to retrieve the Elasticsearch domain policies using the following code snippet:
- Check if the Elasticsearch domain policies allow unrestricted access using the following code snippet:
- Use the Elasticsearch service client to update the Elasticsearch domain policies using the following code snippet:
- Verify that the remediation was successful by checking the Elasticsearch domain policies again using the following code snippet:
Using Terraform
Using Terraform
aws_vpc.MY_VPC.idwith your VPC resource or ID.TRUSTED_IPV4_CIDR/TRUSTED_IPV6_CIDRwith the narrowest CIDR(s) that should access Elasticsearch.
aws_vpc_security_group_ingress_rule (or inline ingress blocks) on this security group that have:cidr_ipv4 = "0.0.0.0/0"withfrom_port = 9200,to_port = 9200,ip_protocol = "tcp", and/orcidr_ipv6 = "::/0"withfrom_port = 9200,to_port = 9200,ip_protocol = "tcp".
terraform plan should show the offending ingress rule resources with cidr_ipv4 = "0.0.0.0/0" and/or cidr_ipv6 = "::/0" on port 9200 being destroyed or modified to the new restricted CIDRs, with no new rule reintroducing 0.0.0.0/0 or ::/0 on port 9200.
