Vulnerability Assessment on Azure Container Registry with Microsoft Defender and Docker Hub
Hello everyone, welcome to my latest blog post!
My name is Suzaril Shah and I am a Gold Microsoft Learn Student Ambassador and a Microsoft Certified Trainer from Malaysia.
I am excited to share my two favorite image analysis solutions to protect images hosted on Azure Container Registry. Please note that it is not my intention to compare these two solutions because I love working with both Microsoft Defender for Containers and Docker Scout altogether and they complement each other. If anything, they should be used alongside each other to further enhance container security on ACR.
Introduction to Container Technology
Containers help applications execute smoothly across various computer environments by providing a standardized software unit that packages code and its dependencies. Software engineers can improve consistency, efficiency, and scalability by using this technology to separate applications from their underlying infrastructure.
Docker and other container engines enclose the libraries, system tools, and configuration files that a program needs to execute. No matter where the application is deployed on a developer’s local PC, a test environment, or a production server; this encapsulation guarantees that it functions consistently. In comparison to conventional virtual machines which typically contain a full operating system and are consequently bulkier, less efficient, and less portable this degree of consistency and mobility is a huge plus.
VM vs Docker Container deployment (Image Source from F5 – www.f5.com)
The emergence of cloud computing has hastened the adoption of container technology. Platforms such as Azure Container Registry (ACR), provide a safe and expandable place to keep container images and manage them. This makes it easy to deploy and integrate with other Azure services. With this connection, businesses can use Azure’s ecosystem to its fullest potential while also adhering to stringent security and compliance requirements.
Why Container Security is Important?
Container security is crucial in today’s software development landscape to prevent malicious code from compromising apps and systems. Containers are vulnerable to attacks designed to inject malicious code because they contain all dependencies by design. If an attacker successfully infiltrates a container, they can acquire access to the entire application environment, resulting in data breaches, illegal access, and major interruptions in service. Ensuring that containers are secure from the development stage through to deployment is crucial to safeguarding against these risks.
Another important aspect of container security is the need to avoid vulnerabilities and exploits, particularly those identified in the Common Vulnerabilities and Exposures (CVE) database. Containers commonly use a range of third-party libraries and dependencies, which can bring known vulnerabilities if not properly handled. Regularly scanning container images for vulnerabilities and implementing fixes is critical to prevent exploits that could be leveraged by attackers to seize control of programs or access sensitive data. Effective vulnerability management within containers helps ensure the integrity and trustworthiness of the applications they support.
Moreover, configuration and deployment concerns pose major challenges to container security. Misconfigurations, such as incorrectly configured network settings or overly permissive access policies, might expose containers to external attacks. Similarly, insecure deployment procedures might lead to the development of vulnerabilities that could be exploited during runtime. Implementing strong configuration management and adhering to recommended practices for container deployment are critical steps in mitigating these hazards. By addressing these potential security vulnerabilities, companies may ensure that their containerized environments stay robust against a wide range of security threats.
Protecting your Images on ACR with Microsoft Defender for Containers
If you host your images on Azure Container Registry, you can protect the images hosted on the registries by upgrading Microsoft Defender for Cloud to include Microsoft Defender for Containers. Microsoft Defender for Containers is a solution to improve, monitor, and maintain the security of your containerized assets (Kubernetes clusters, Kubernetes nodes, Kubernetes workloads, container registries, container images, and more), and their applications, across multi-cloud and on-premises environments. It integrates a variety of security measures and practices to provide comprehensive protection.
Image Source: Microsoft Learn – learn.microsoft.com
Microsoft Defender provides:
Security posture management: Continuously monitors cloud APIs and Kubernetes workloads to discover resources, detect misconfigurations, and provide mitigation guidelines. Includes comprehensive inventory and enhanced risk hunting through the Defender for Cloud security explorer.
Vulnerability assessment: Offers agentless vulnerability assessment for Azure, AWS, and GCP, with remediation guidelines, zero-configuration, daily rescans, and insights on OS and language package vulnerabilities.
Run-time threat protection: Provides a suite of threat detection for Kubernetes clusters, nodes, and workloads. Powered by Microsoft’s threat intelligence, it maps risks to the MITRE ATT&CK framework and integrates automated responses with SIEM/XDR.
Deployment & monitoring: Monitors Kubernetes clusters for missing sensors, supports frictionless at-scale deployment, integrates with standard monitoring tools, and manages unmonitored resources.
To test the Image Scanning Feature on Microsoft Defender, let’s build an image with a couple of vulnerabilities issue. The Dockerfile below is intentionally created with known vulnerabilities and outdated software versions to highlight security issues.
# Use an old, vulnerable base image
FROM ubuntu:14.04
# Install outdated and vulnerable packages
RUN apt-get update && apt-get install -y \
openssl=1.0.1f-1ubuntu2.27 \
curl=7.35.0-1ubuntu2.20 \
php5=5.5.9+dfsg-1ubuntu4.29
# Expose port 80 for the web server
EXPOSE 80
# Start nginx in the foreground
CMD [“nginx”, “-g”, “daemon off;”]
Then build this image using “docker build” and push the image to Azure Container Registry.
In the previous article I wrote, I set up a Container Registry with the name: suzarilshah. Let’s see the suggestions Microsoft Defender for Cloud has to improve the security of my Container Registry. To view these recommendations, navigate to the Container Registry’s Settings subsection on Azure Container Registry as shown in the screenshot below:
Microsoft Defender for Containers is not automatically included in the free Microsoft Defender for Cloud. To upgrade the Microsoft Defender for Cloud coverage to include Microsoft Defender for Containers, click on the “Visit Microsoft Defender for Cloud” on the blue banner on top of the page > Under Management subsection, select “Environment Settings” > Select your Azure Tenant Root Group subscription. Scroll down to the Cloud Workload Protection (CWP) section and Turn the Status for Containers to “On”.
Then, click on “Settings” under the Monitoring Coverage for Containers and make sure that the “Agentless container vulnerability assessment” component is turned on and Click on “Continue” > “Save” to save the settings.
You might want to wait for at least 20 minutes until all policy definitions for Microsoft Defender for Containers are remediated.
Image Scanning and Analysis
Now, Microsoft Defender for Cloud will scan the images on the Container Registry with the following Scan triggers condition:
The triggers for an image scan are:
One-time triggering:
Each image pushed or imported to a container registry is triggered to be scanned. In most cases, the scan is completed within a few minutes, but in rare cases it might take up to an hour.
Each image pulled from a registry is triggered to be scanned within 24 hours.
Continuous rescan triggering – continuous rescan is required to ensure images that have been previously scanned for vulnerabilities are rescanned to update their vulnerability reports in case a new vulnerability is published.
Re-scan is performed once a day for:
Images pushed in the last 90 days.
Images pulled in the last 30 days.
Images currently running on the Kubernetes clusters monitored by Defender for Cloud (either via Agentless discovery for Kubernetes or the Defender sensor).
Once the images are scanned, navigate to the Microsoft Defender for Cloud and find the “Recommendations” subsection. Click on “Add Filter”, click on “Resource Type” and check the “Container Image” checkbox. You should be able to view the recommendations for your Container Image resource. Click on the resource affected by this recommendation > “Findings”
Microsoft Defender for Cloud will list down all known CVEs associated with the image as shown in the screenshot below:
You can even assign an owner to fix/remediate this vulnerability on the “Take Action” tab, set a time frame to fix this issue and setup notifications to be sent to the person in charge.
Image analysis with Docker Scout
Aside from using Microsoft Defender for Containers, Docker also offers an image vulnerability assessment solution. Docker Scout is a robust solution designed to proactively enhance the security of your software supply chain. By providing comprehensive analysis of your container images, Docker Scout helps ensure your applications remain secure and resilient against potential threats.
At the heart of Docker Scout is the creation of a Software Bill of Materials (SBOM). The SBOM is a detailed inventory of all components within your container images, enabling you to gain deep visibility into the software you deploy. This inventory is continuously matched against an up-to-date vulnerability database, allowing Docker Scout to pinpoint and highlight any security weaknesses within your images. With this valuable information, you can take immediate action to mitigate risks and fortify your applications.
Docker Scout Image Analysis flow (Image source: https://medium.com/@fsegredo2000/docker-scout-e570b63f0257)
Docker Scout seamlessly integrates with popular container registries, including Azure Container Registry, Amazon Elastic Container Registry (ECR), and JFrog Artifactory Container Registry. This broad compatibility ensures that no matter where your images are stored, Docker Scout can provide the security insights you need. By integrating Docker Scout into your existing workflows, you can maintain a consistent security posture across all stages of your software development lifecycle.
Docker Scout Pricing
One of the most compelling aspects of Docker Scout is its accessibility. Docker Scout is free for the first three repositories for any user or organization account, making it an excellent entry point for those looking to enhance their security practices. For larger needs, Docker Scout offers a competitive pricing model at $9 per repository per month, billed in groups of five repositories. This flexible pricing structure ensures that organizations of all sizes can benefit from the advanced security capabilities of Docker Scout.
Docker Scout is available for both CLI and the Docker Scout portal.
Docker Scout CLI
To view a list of vulnerabilities affecting your images in ACR, simply run the following command from your CLI:
docker scout cves [Registry Address]/[Repository]/[Image]
The output from the command above should display the CVES associated with your image:
To view the recommended fixes for the image, simply run:
docker scout recommendations [Registry Address]/[Repository]/[Image]
Docker Scout should display the recommended fixes for the image. In this case, this image needs to be rebuild with a newer base image version.
Similar features can also be accessed from the Docker Scout website at scout.docker.com. Aside from being able to perform local Image analysis (as indicated earlier), Docker Scout can also perform remote image analysis on external registries such as Azure Container Registries, Amazon Elastic Container Registry, and JFrog Artifactory Container Registry.
Docker Scout Remote Integration with Azure Container Registry
To integrate Docker Scout with Azure Container Registry, navigate to the Docker Scout website at scout.docker.com and navigate to the Integration subsection and Find the “Integrate” button on the Microsoft Azure Container Registry section.
Type in your ACR Registry Address in the “Pre-requisites” section and click on “Next” to continue.
Click on “Deploy to Azure” button to deploy Docker Scout resources to Azure.
You should be redirected to Azure to complete the Docker Scout Deployment setup. Specify resource group and Instance details and click on the “Review + create” button to proceed with the next steps.
Navigate to Azure Container Registry > Under Repository Permissions, click on “Tokens” > docker-scout-readonly-token-ACR-X-XXXX > Generate Docker Scout token by clicking on the Refresh icon on the password1 row.
Make sure to set the token scope map and set the expiration date for the Docker Scout tokens on ACR > Click on “Generate” to generate the token.
After the token is generated, copy and paste the token to Docker Scout and click on “Enable Integration”.
The Azure Container Registry integration on Docker Scout should display “Connected” as shown below:
Now to enable Docker Scout Image analysis feature, click on the “Manage repository settings” hyperlink and you should be able to see the images on ACR. Check the image you wish to run Image Analysis on and click “Activate Image Analysis”.
Docker Scout will run an image analysis on all Images selected and it can take up to 10 minutes to complete them. To view the analysis, simply click on “Images” > [Repo/image] > [tags].
Conclusions
Finally, containerised apps hosted in Azure Container Registry can benefit from a thorough security framework that makes use of Docker Scout and Microsoft Defender for Containers. With Microsoft Defender for Containers, you can keep your container workloads secure with advanced threat detection, automatic remediation, continuous monitoring, and thorough vulnerability evaluation. It integrates smoothly with Azure Container Registry.
In addition, Docker Scout can pinpoint security holes in your container images by creating an exhaustive Software Bill of Materials (SBOM) using a vulnerability database that is updated on a regular basis. Consistent security measures are ensured across your software supply chain thanks to its interoperability with leading container registries, such as Azure Container Registry. Protect your containerised apps, stay in compliance, and strengthen your cloud infrastructure’s security with these technologies.
Microsoft Tech Community – Latest Blogs –Read More