5 Open Source Tools For Container Security
5 Open Source Tools For Container Security
5 Open Source Tools For Container Security
com
LO G I N
By Sathyajith Bhat
August 22, 2018 | 0 Comments | 14 min read 338 readers like this.
Anchore
Linux Containers
What is Kubernetes?
The Anchore engine is an open source project that inspects, analyzes, and certifies
Docker images. Anchore is available as a Docker image that can be run standalone
or with orchestration platforms such as Kubernetes. Anchore fetches security data
from Anchore’s hosted cloud service. Anchore is also available as a Jenkins plugin,
allowing you to integrate container image scanning as part of the CI/CD workflow.
To initiate a scan, add the image to the Anchore Engine with the following
command:
https://opensource.com/article/18/8/tools-container-security 2/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
This command submits the image to be scanned. Once submitted, Anchore will
initiate a scan of the image. Unfortunately, there seems to be no way to know when
the scan is completed, except by typing (or writing a script):
to monitor the status. Once an image is scanned, use the following command to
list the reported CVEs in the image:
ID
1000379
14062 tracker.debian.org/tracker/CVE-2017-14062
Although the CLI reports CVE vulnerabilities, the vuln command can report non-
OS vulnerabilities. Running it did not report any data in this example:
https://opensource.com/article/18/8/tools-container-security 3/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
Anchore scan can also report the artifacts present in the image, including Python
packages, Ruby gems, os packages, and all other files on the filesystem:
mercurial 4 /usr/lib/python2.7/dist-packages
https://opensource.com/article/18/8/tools-container-security 4/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
With this data, Anchore lets you evaluate the image against policies to check for
security compliance. To do this, type:
By default, Anchore will only provide a summary of the evaluation. To obtain a full
evaluation, you can pass the --detail flag, which provides the full evaluation:
dockerfile instruction Dockerfile directive 'HEALTHCHECK' not found, matching condition warn
'not_exists' check
vulnerabilities package MEDIUM Vulnerability found in os package type (dpkg) - imagemagick- warn
tracker.debian.org/tracker/CVE-2008-3134)
https://opensource.com/article/18/8/tools-container-security 5/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
vulnerabilities package MEDIUM Vulnerability found in os package type (dpkg) - imagemagick- warn
tracker.debian.org/tracker/CVE-2017-14528)
vulnerabilities package MEDIUM Vulnerability found in os package type (dpkg) - imagemagick- warn
tracker.debian.org/tracker/CVE-2018-5248)
vulnerabilities package MEDIUM Vulnerability found in os package type (dpkg) - imagemagick- warn
tracker.debian.org/tracker/CVE-2018-11251)
vulnerabilities package MEDIUM Vulnerability found in os package type (dpkg) - mercurial warn
(CVE-2018-1000132 - https://security-tracker.debian.org/tracker/CVE-
2018-1000132)
The gates, thresholds, and evaluations are performed against a policy whose ID is
mentioned above. Examine the policy by typing:
This outputs a JSON of the policy. The open source Anchore Engine lets you
define and activate custom policies, but it doesn’t come with a visual policy editor,
so trying to edit the policies by hand can be tricky. Anchore also works well with
private registries; add them using:
Anchore can also be configured to scan repositories and add any tags found in the
repository. Once added, the Anchore engine will poll the registry periodically and
schedule them to be analyzed.
Clair
https://opensource.com/article/18/8/tools-container-security 6/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
An open source vulnerability scanner and static analysis tool for container images
by CoreOS, Clair is the same tool that powers CoreOS’s container registry,
Quay.io.
Clair regularly ingests vulnerability information from various sources and saves it in
the database. Clair exposes APIs for clients to invoke and perform scans. That
said, Clair is a “backend-only” tool and doesn’t come with scanners or a frontend
for initiating a scan. There are a few third-party tools that integrate with Clair, but
to scan images from a terminal as part of a deploy script, the only reasonable
option seems to be klar by optiopay.
Clair’s install instructions can found on its Github repo and can be run as a
container with Docker. Clair also comes with a Docker Compose file and a Helm
Chart to simplify installation, or it can be compiled from source. These steps only
bootstrap the server—to run a scan, you need a compatible frontend.
While Clair’s integrations page lists the options available, for this article, I looked at
the available command-line utilities available. Of these, klar was the simplest and
quickest. klar can be downloaded from its GitHub releases page or compiled from
scratch.
For instance, assuming that we used the Docker Compose file to bring up the Clair
server and we want to scan python:3 Docker image, the command would be like
this:
Klar will pull the Docker image (if not present on the host) and run the scan against
Clair. When it's done, it will present a report like the following:
Analysing 9 layers
Unknown: 22
Negligible: 181
Low: 150
Medium: 113
High: 22
CVE-2017-12424: [High]
Fixed By:
In shadow before 4.5, the newusers tool could be made to manipula
https://security-tracker.debian.org/tracker/CVE-2017-12424
Klar lets you customize its features via environment variables. Some noteworthy
ones include:
CLAIR_OUTPUT: Lets you define the severity of the vulnerabilities klar displays. For
instance, setting CLAIR_OUTPUT to Medium means klar will display only
vulnerabilities that are tagged as medium severity or higher.
JSON_OUTPUT: klar will output the vulnerability report in JSON if this is set to true.
WHITELIST_FILE: klar will not report the CVEs listed here as a vulnerability. The is a
YAML file; a sample configuration is available in klar’s repository.
Dagda
Dagda performs static analysis of known vulnerabilities. It uses the ClamAV anti-
virus engine to scan and detect trojans, viruses, and malware contained within
Docker images. Dagda also integrates with Sysdig Falco to monitor running Docker
containers for anomalies.
https://opensource.com/article/18/8/tools-container-security 8/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
Dagda comes with a Docker Compose file as well, making it easy to evaluate. The
Docker Compose file and related installation instructions are available in Dagda’s
Github repository. Prior to running the Dagda CLI, you must set the Dagda server’s
hostname and port. To do this, use the following commands:
export DAGDA_HOST='127.0.0.1'
export DAGDA_PORT=5000
Before using Dagda for analysis, you need to initialize the vulnerability database.
To do this, use the following command:
This takes a bit of time and can be monitored by watching the result of the
following command using the --init_status option:
https://opensource.com/article/18/8/tools-container-security 10/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
15. "cvss_vector": [
16. "AV:L",
17. "AC:L",
18. "Au:N",
19. "C:P",
20. "I:N",
21. "A:N"
22. ],
23. "cweid": "CWE-0",
24. "mod_date": "17-10-2016",
25. "pub_date": "14-12-1999",
26. "summary": "An SSH 1.2.27 server allows a client
27. }
The ID obtained above can be used to fetch a detailed report using the following:
The analysis can take some time, so be patient. Once analyzed, you can get a
detailed report by using the following command:
https://opensource.com/article/18/8/tools-container-security 11/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
Although Dagda does support monitoring of containers, this requires Sysdig Falco
to be running. Dagda doesn’t support scanning of repositories or registries, making
it more suitable for on-demand scans than scheduled or automatic registry scans.
OpenSCAP
Security Content Automation Protoco (SCAP) enables automated vulnerability
management, measurement, and policy compliance evaluation using a specific set
of standards. OpenSCAP is an example of SCAP implementation. OpenSCAP
provides a set of tools for scanning and compliance management, including
oscap-docker, which can scan a container image.
https://opensource.com/article/18/8/tools-container-security 14/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
OpenSCAP’s CVE scan for container images seems to work only for RHEL images;
for others, oscap-docker kept showing the message:
Sysdig Falco
While it's not a pure container security or CVE scanning solution, Sysdig Falco
deserves a mention. Sysdig Falco monitors our running Docker containers and
https://opensource.com/article/18/8/tools-container-security 15/19
31/05/2024, 13:00 5 open source tools for container security | Opensource.com
Sysdig Falco works within containers as well as on the Linux host, but Sysdig
recommends installing it on the host operating system. Instructions for installing
Sysdig Falco on containers and on the host operating system are available below:
Installing on containers
sudo falco
Falco will load the rules and provide the following message when ready:
Falco will display messages at different severity levels according to the rules:
What good are these alerts? First, they can be forwarded to a SIEM tool like Splunk
and we can further create/emit alerts based on the count and frequency of these
alerts. Falco can also call a program and send the alerts to that program. For
example, we can configure Falco to send notifications to Slack by making a cURL
call to the webhook endpoint.
Conclusion
https://opensource.com/article/18/8/tools-container-security 16/19