What is Image Scanning?

Image scanning refers to the process of examining container images, for potential vulnerabilities or issues that could compromise security or efficiency. This technique is commonly used in cloud native environments, where images play a crucial role in ensuring system safety and integrity.

Rani Osnat
December 5, 2023

Image scanning involves checking each layer of an image to identify vulnerabilities or threats. This includes scanning the base image, software dependencies, and the application code. As a result, any potential issues can be flagged and rectified before they become a significant problem.

In essence, image scanning is a proactive approach to software security. It’s about identifying and addressing potential issues in the early stages, rather than reacting to security breaches or system failures when they occur. This proactive approach is now recognized as a basic component of a cloud native security strategy.

This is part of a series of articles about containerized architecture.

In this article:

Why Image Scanning is Crucial in Containers 

Attack Surface of Containers

Containers have revolutionized the way we package and distribute software applications, thanks to their portability and efficiency. However, the compact nature of containers also presents a larger attack surface for potential threats.

Every container image comprises multiple layers, each of which could potentially harbor vulnerabilities. Image scanning is therefore essential in identifying and addressing these vulnerabilities before they can be exploited. It’s a crucial step in container security, helping to minimize the attack surface and protect your applications.

Vulnerability Detection

One of the main functions of image scanning is to detect vulnerabilities. These can range from outdated software versions and misconfigured settings to embedded secrets or sensitive information. By scanning container images, we can detect and rectify these issues before they impact production systems.

Vulnerability detection is particularly crucial in a DevOps environment, where continuous integration and delivery (CI/CD) pipelines are central to operations. Image scanning can be integrated into these pipelines, ensuring that any new images or changes to existing images are thoroughly vetted for potential vulnerabilities.

Assurance of Software Integrity

Image scanning not only helps to identify potential threats but also provides assurance of software integrity. By scanning each layer of an image, we can verify that the software hasn’t been tampered with or compromised in any way.

This is particularly important in a world where software is often distributed across multiple platforms and environments. Image scanning provides a level of assurance that the software we’re using is secure, reliable, and free from vulnerabilities. This is an important safeguard against supply chain attacks.

Regulatory Compliance

In many industries, regulatory compliance is a major concern. Regulations often mandate certain levels of security and data protection, and failure to comply can result in hefty fines or other penalties.

Image scanning can play a key role in maintaining compliance, by helping to ensure that your software is free from vulnerabilities that could lead to data breaches or other security incidents. By integrating image scanning into your security practices, you can reduce the risk of non-compliance.

Common Vulnerabilities Detected by Image Scanning 

Outdated Software Versions

One of the most common vulnerabilities detected by image scanning is outdated software versions. Software developers regularly release updates and patches to address known vulnerabilities, so running outdated versions of software can leave your systems exposed to potential threats.

Image scanning can identify outdated software versions, allowing you to update your software and eliminate these vulnerabilities. This is particularly important in the world of containers, where software is often distributed across multiple environments and platforms.

Misconfigured Software Settings

Misconfigured software settings are another common vulnerability detected by image scanning. Incorrect settings can leave your systems vulnerable to attacks, impact performance, or result in data loss. For example, a common misconfiguration is to deploy databases with the default admin username and password, allowing them to be easily accessed by attackers.

Image scanning can identify these misconfigurations, providing you with the opportunity to correct them before they cause problems. It’s a crucial aspect of software management, helping to ensure that your systems are correctly configured and operating efficiently.

Embedded Secrets or Sensitive Information

In some cases, sensitive information or secrets may be inadvertently embedded in container images. This could include passwords, API keys, or other confidential data. If these images are then distributed or made publicly available, this sensitive information could be exposed.

Image scanning can detect embedded secrets or sensitive information, helping to prevent data breaches and protect your confidential data. It’s an essential tool in data security, offering a proactive approach to data protection.

Malicious Software or Code

Finally, image scanning can detect malicious software or code. This could include malware, ransomware, or other types of malicious code that could compromise your systems or data.

By scanning container images, you can identify and remove any malicious software or code before it impacts your systems. Remember that malware in a single container image could potentially propagate to thousands of containers.

Steps in the Image Scanning Process 

1. Image Retrieval

The first step in the image scanning process is image retrieval. This involves accessing the image or container that needs to be scanned. The image could be stored on a local machine or sourced from a container registry. Depending on the image scanning tool used, this process may involve pulling the image from its source or simply accessing its path.

Learn more in our detailed guide to registry scanning 

2. Decomposition and Analysis

After image retrieval, the image scanning tool decomposes the image into layers. Each layer is then analyzed separately to identify any issues. The analysis stage examines each component in the image, such as the operating system (if packaged as part of the image), installed software, and application code.

The image below illustrates the structure of a container image, with a base layer, additional image layers, and a top layer which is writable by the container.

3. Vulnerability Database Comparison

Once the image has been decomposed and analyzed, the findings are compared with a vulnerability database. This database contains known vulnerabilities and threats. The image scanning tool cross-references the findings from the decomposition and analysis stage with this database. This step is vital in validating the identified threats and helps determine the severity of these threats.

4. Results Interpretation and Reporting

In the final step, the image scanning tool provides a report detailing the findings from the scan. This report includes a list of identified vulnerabilities, their severity, and recommendations for remediation. This step is crucial as it provides actionable insights that can be used to address the vulnerabilities identified in the image.

Features to Consider When Selecting an Image Scanning Tool 

When selecting an image scanning tool, there are several features to consider. These features can help optimize the image scanning process and ensure the tool is tailored to your specific needs.

Comprehensive Vulnerability Database

A comprehensive vulnerability database is a cornerstone feature for any image scanning tool. This feature ensures the tool has a wide range of known vulnerabilities to cross-reference during the scanning process. Many image scanning tools use several vulnerability databases. These can include publicly available databases and proprietary databases based on the security vendor’s research.

Integration with CI/CD Pipelines

Another feature to consider in an image scanning tool is its ability to integrate with Continuous Integration/Continuous Deployment (CI/CD) pipelines. This feature allows the image scanning process to be integrated into the development lifecycle, ensuring images are scanned as they’re built and deployed. This integration can help identify and remediate vulnerabilities early in the development process.

Policy-Based Scanning

Consider whether the image scanning tool supports policy-based scanning. This feature allows you to define specific scanning policies based on your organization’s security requirements. With policy-based scanning, you can customize the scanning process, focusing on particular areas of concern or ignoring certain non-threatening vulnerabilities.

False Positive Handling

One of the most crucial aspects to consider while selecting an image scanning tool is how it handles false positives. False positives are essentially harmless elements that are mistakenly flagged as threats. They can lead to false alarms and can consume substantial time and effort. 

A good image scanner should be capable of reducing the number of false positives to a minimum. It should also provide the option to whitelist certain items, allowing them to bypass the scanner if they are known to be safe.

Image scanning tools should also be capable of providing detailed information about each vulnerability detected. This includes the severity of the vulnerability, its location within the image, and potentially its potential impact. This information is crucial in prioritizing responses and remediation efforts. It can also help in identifying recurring vulnerabilities and addressing the root cause to prevent future occurrences.

Role-Based Access Control (RBAC)

Another key feature to look for in an image scanning tool is Role-Based Access Control (RBAC). RBAC allows you to control who can access your image scanning results, who can run scans, and who can modify your image scanning settings. This is critical in maintaining the integrity of your scanning process and preventing unauthorized access or modifications.

RBAC can be particularly useful in larger teams or organizations where multiple individuals or teams need to access the image scanning tool. It can help ensure that only authorized personnel have access to sensitive information and can perform critical functions. It also adds an additional layer of security, as it reduces the number of people who can potentially make changes that could impact the effectiveness of your image scanning.

Learn more in our guide about docker scanning

5 Image Scanning Best Practices 

1. Regularly Update Image Scanning Tools

Image scanning tools and their threat databases should be updated regularly. This is because new vulnerabilities are discovered every day, and it’s crucial that your tools are updated to detect these new threats. Most image scanning tools have an option for automatic updates, which should be utilized to ensure that you always have the most current version.

Regular updates not only help in detecting the latest threats but also improve the overall performance of your image scanning tool. They often include bug fixes, improvements to false positive handling, and other enhancements that can make your image scanning process more effective and efficient.

2. Integrate Image Scanning into the CI/CD Pipeline

Continuous integration and continuous deployment (CI/CD) pipelines are a key part of modern software development processes. Integrating image scanning into your CI/CD pipeline can help ensure that your images are scanned for vulnerabilities at every stage of the development process.

This can help in early detection and remediation of vulnerabilities, reducing the chances of them making it to production. It can also help in maintaining a consistent scanning process, as every image is scanned using the same standards and procedures.

3. Correlate Vulnerabilities with Compounded Risk

Not all vulnerabilities are created equal. Some pose a higher risk than others, and it’s important to understand this when dealing with the results of your image scans. A good practice is to correlate vulnerabilities with their compounded risk, which considers factors like the severity of the vulnerability, its location in the image, and its potential impact.

This can help in prioritizing remediation efforts, focusing on the vulnerabilities that pose the highest risk. It can also provide a clearer picture of your overall security stance, as it takes into account not just the number of vulnerabilities but their potential impact as well.

4. Address Detected Vulnerabilities Promptly

Once a vulnerability has been detected, it’s critical to address it promptly. This could involve patching the vulnerability, removing the vulnerable component from your image, or implementing some form of mitigation to reduce its potential impact.

Prompt response to detected vulnerabilities is crucial in reducing the window of opportunity for attackers. The longer a vulnerability remains unaddressed, the greater the risk of it being exploited.

5. Educate Developers About Image Security Practices

Finally, it’s important to educate your developers about safe practices in image creation. This includes aspects like using only trusted images, minimizing the use of third-party components, and regularly updating images to include the latest security patches.

Educating developers can help reduce the number of vulnerabilities in your images in the first place, making your image scanning process more manageable. It can also promote a culture of security within your organization, where everyone is aware of their role in maintaining the security of your applications.

Image Scanning with Aqua Security

The Aqua Platform enables Aqua’s comprehensive role-based access controls (RBAC) deliver effective separation of duties (SoD) to support security and compliance initiatives for complex and multi-cloud deployments and provide the flexibility to support all deployment configurations and organizational structures. Administrators can configure hierarchies and role-based permissions based on defined scopes, down to the pod level. Limit the use default policies with embedded OPA-based, declarative assurance policies.

Rani Osnat
Rani is the SVP of Strategy at Aqua. Rani has worked in enterprise software companies more than 25 years, spanning project management, product management and marketing, including a decade as VP of marketing for innovative startups in the cyber-security and cloud arenas. Previously Rani was also a management consultant in the London office of Booz & Co. He holds an MBA from INSEAD in Fontainebleau, France. Rani is an avid wine geek, and a slightly less avid painter and electronic music composer.