Don't Let Open Source Vulnerabilities Crawl Into Your Docker Images
We look into the frequency of vulnerabilities in Docker images and to use a freely available tool to detect them.
Join the DZone community and get the full member experience.Join For Free
When we choose a base image for our Docker container, we indirectly take upon ourselves the risk of all the security concerns that the base image is bundled with.
This can be poorly configured defaults that don’t contribute to the security of the operating system, as well as system libraries that are bundled with the base image we chose.
Based on scans performed by Snyk users, it was found that 44% of Docker image scans had known vulnerabilities, and for which there were newer and more secure base images available.
A good first step is to make use of as minimal a base image as is possible while still being able to run your application without issues.
This helps reduce the attack surface by limiting exposure to vulnerabilities; on the other hand, it doesn’t run any audits on its own, nor does it protect you from future vulnerabilities that may be disclosed for the version of the base image that you are using.
Therefore, one way of protecting against vulnerabilities in open source software is to use tools to add continuous scanning and monitoring of vulnerabilities that may exist across all of the Docker image layers that are in use.
In action, a snyk test for a Docker image:
To practice the same workflow you can use Snyk to scan a Docker image for known vulnerabilities with these commands:
# fetch the image to be tested so it exists locally $ docker pull node:10 # scan the image with snyk $ snyk test --docker node:10 --file=path/to/Dockerfile
Monitoring vulnerabilities as they get discovered is not any less important than scanning them to begin with.
Monitor a Docker image for known vulnerabilities so that once newly-discovered vulnerabilities are found in the image, Snyk can notify and provide remediation advice:
$ snyk monitor --docker node:10
Snyk also found that for 20% out of all Docker image scans, only a rebuild of the Docker image would be necessary in order to reduce the number of vulnerabilities.
The original blog post includes a high-resolution printable PDF like the snippet you see below. Check it out
Opinions expressed by DZone contributors are their own.