Triage and Remediation
Remediation
Using Console
Using Console
Sure, here are the step-by-step instructions on how to remediate the “Endpoints Should Not Be Publicly Accessible” misconfiguration in AWS using the AWS console:
- Log in to the AWS Management Console.
- Go to the Amazon VPC service.
- Click on “Endpoints” in the left navigation pane.
- Select the endpoint that you want to remediate.
- Click on the “Actions” button and select “Modify Endpoint”.
- In the “Modify Endpoint” dialog box, select the “Private” option for the endpoint.
- Click “Save Changes” to apply the changes.
Using CLI
Using CLI
To remediate this misconfiguration in AWS using AWS CLI, follow these steps:Replace This command should return an output that includes
- Open the AWS CLI on your local machine.
- Run the following command to list all VPC endpoints in your AWS account:
- Identify the VPC endpoint that is publicly accessible.
- Run the following command to modify the VPC endpoint to make it not publicly accessible:
<VPC_ENDPOINT_ID>
with the ID of the VPC endpoint that you identified in step 3.- Verify that the VPC endpoint is no longer publicly accessible by running the following command:
"PrivateDnsEnabled": true
and "PolicyDocument": {"Statement": [{"Effect": "Deny", "Principal": "*", "Action": "*", "Resource": "*"}], "Version": "2012-10-17"}
for the VPC endpoint that you modified.- Repeat steps 3-5 for any other publicly accessible VPC endpoints in your AWS account.
Using Python
Using Python
To remediate the misconfiguration “Endpoints Should Not Be Publicly Accessible” for AWS using Python, follow these steps:
-
Identify the endpoints that are publicly accessible. You can use the AWS CLI command
aws ec2 describe-security-groups
to list all security groups and their associated rules. -
For each security group that has a rule allowing public access to an endpoint, you will need to remove the rule. You can use the AWS CLI command
aws ec2 revoke-security-group-ingress
to remove the rule. - To automate this process using Python, you can use the Boto3 library, which is the AWS SDK for Python. Here is an example code snippet that will remove all rules allowing public access to endpoints for a specific security group:
- You can run this Python script as a Lambda function and schedule it to run periodically to ensure that any new endpoints that are publicly accessible are remediated automatically. You can also modify the script to remediate all security groups in your AWS account, not just a specific one.