More Info:
Blacklist all those AMI to prevent certain security issues to attack your application. Your EC2 Instances should not use any of the blacklisted AMIs.Risk Level
LowAddress
Security, Operational MaturityCompliance Standards
CBPTriage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the issue of blacklisted AMIs in AWS using AWS console, follow the steps below:
- Log in to your AWS console.
- Go to the EC2 dashboard.
- Click on the “AMIs” option on the left-hand menu.
- Identify the blacklisted AMIs from the list of available AMIs.
- Select the blacklisted AMI that you want to remove.
- Click on the “Actions” button and select “Deregister” from the drop-down menu.
- Confirm the action by clicking on the “Deregister” button.
- Once the AMI is deregistered, it will no longer be available for use.
- Ensure that any instances using the blacklisted AMI are terminated and replaced with instances using approved AMIs.
- Implement a process to regularly check and update the list of approved AMIs to prevent the use of blacklisted AMIs in the future.
Using CLI
Using CLI
To remediate the issue of using blacklisted AMIs in AWS, you can follow the below steps using AWS CLI:This command will return a list of all the instances in your AWS account along with their AMI IDs.Replace Replace Replace
- Identify the blacklisted AMIs in your AWS account. You can check the list of blacklisted AMIs on the AWS website.
- Find all the instances that are using the blacklisted AMIs. You can use the following AWS CLI command to get the list of instances:
- Stop the instances that are using the blacklisted AMIs. You can use the following AWS CLI command to stop the instances:
<instance-id-1>, <instance-id-2>, and so on with the instance IDs of the instances that are using the blacklisted AMIs.- Create a new instance using a non-blacklisted AMI. You can use the following AWS CLI command to launch a new instance:
<non-blacklisted-ami-id> with the ID of a non-blacklisted AMI, <instance-type> with the type of instance you want to launch, <key-name> with the name of the key pair you want to use to connect to the instance, <security-group-id> with the ID of the security group you want to use, and <subnet-id> with the ID of the subnet you want to launch the instance in.- Once the new instance is launched, you can transfer any data or configuration from the old instance to the new instance.
- Finally, terminate the instances that were using the blacklisted AMIs. You can use the following AWS CLI command to terminate the instances:
<instance-id-1>, <instance-id-2>, and so on with the instance IDs of the instances that were using the blacklisted AMIs.Using Python
Using Python
To remediate the issue of using blacklisted AMIs in AWS using Python, follow these steps:Note: Make sure you have appropriate permissions to perform these actions in your AWS account.
- Define a list of blacklisted AMIs that you want to avoid using. You can get this list from multiple sources, such as AWS documentation or a security team.
- Use the AWS SDK for Python (Boto3) to get a list of all the AMIs available in your AWS account.
- Loop through each AMI and check if it is blacklisted. If it is, deregister the AMI and delete its associated snapshots.
- Optionally, you can also notify the appropriate team or individual about the remediation action.

