Profile Applicability:
- Level 1
Description:
Amazon Elastic Container Registry (ECR) is a fully managed Docker container registry that enables developers to store, manage, and deploy container images. Scan on push is a feature in ECR that automatically scans container images for vulnerabilities upon image upload. This SOP ensures that ECR registries have the scan on push feature enabled, which helps identify security vulnerabilities in container images at the time of upload, reducing the risk of deploying vulnerable containers into production.
Rationale:
Security: Scanning images as they are pushed into ECR allows early detection of vulnerabilities, preventing potentially unsafe images from being used in production.
Compliance: Many security standards (e.g., SOC 2, HIPAA) require automated scanning of container images to ensure that they do not contain known security vulnerabilities.
Best Practices: Enabling scan on push ensures that all container images are proactively scanned for vulnerabilities without the need for manual intervention.
Impact:
Pros:
Improved Security: Automatically scans container images for known vulnerabilities, reducing the risk of deploying compromised images.
Proactive Vulnerability Management: Identifies vulnerabilities before containers are deployed, providing better control over container security.
Compliance: Helps meet compliance requirements for vulnerability management and secure software deployment.
Cons:
Performance: Scanning large container images can consume additional time during the image push process, potentially leading to delays.
Cost: While minimal, enabling image scanning may incur additional charges for scanning services.
Default Value:
By default, ECR does not have the scan on push feature enabled. This feature must be explicitly configured during registry creation or updated after creation.
Pre-requisite:
AWS IAM Permissions:
ecr:DescribeRepositories
ecr:PutLifecyclePolicy
ecr:SetRepositoryPolicy
ecr:PutImageScanningConfiguration
AWS CLI installed and configured.
ECR Registry is created and operational.
Test Plan:
Using AWS Console:
Sign in to the AWS Management Console.
Navigate to Amazon ECR under Services.
In the ECR Console, select Repositories.
Choose the repository you want to check for scan on push configuration.
In the Repository details page, under the Scan on Push section, verify if it is enabled.
If Scan on Push is enabled, it will show as enabled. Otherwise, it will be disabled.
If Scan on Push is not enabled, follow the Implementation Steps below to enable it.
Using AWS CLI:
To describe the ECR repository and check if scan on push is enabled, run:
aws ecr describe-repositories --repository-names <repository-name> --query 'repositories[*].imageScanningConfiguration.scanOnPush'
The output should show:
true if scan on push is enabled.
false if scan on push is disabled.
If scan on push is not enabled, follow the steps in the Implementation Steps to enable it.
Implementation Steps:
Using AWS Console:
Sign in to the AWS Management Console and navigate to Amazon ECR.
In the ECR Console, select Repositories and choose the repository you want to configure.
In the Repository details section, click on Edit.
Under the Scan on Push section, select Enable.
Save the changes to enable scan on push.
Using AWS CLI:
To enable scan on push for an ECR repository, run the following command:
aws ecr put-image-scanning-configuration \ --repository-name <repository-name> \ --image-scanning-configuration scanOnPush=true
Verify that scan on push is enabled by running:
aws ecr describe-repositories --repository-names <repository-name> --query 'repositories[*].imageScanningConfiguration.scanOnPush'
The output should show true to confirm that scan on push is enabled for the repository.
Backout Plan:
Using AWS Console:
If enabling scan on push causes issues, sign in to the AWS Management Console.
Navigate to Amazon ECR, select the repository, and click Edit in the Image scanning section.
Disable Scan on push and save the changes.
Ensure that the repository is no longer set to automatically scan images on push.
Using AWS CLI:
To disable scan on push, run the following command:
aws ecr put-image-scanning-configuration --repository-name <REPOSITORY_NAME> --image-scanning-configuration scanOnPush=false --region <REGION>
Verify that scan on push has been disabled by describing the repository again:
aws ecr describe-repositories --repository-names <REPOSITORY_