More Info:
No security group should allow unrestricted inbound access to TCP port 9200 (Elasticsearch).Risk Level
MediumAddress
SecurityCompliance Standards
CBP, AWSWAFTriage and 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: