Essential (and Free) Security Tools for Docker
Essential (and Free) Security Tools for Docker
In this post, we look at some of the best freely available Docker security solutions and explain what problem each of them helps to solve.
Join the DZone community and get the full member experience.Join For Free
Docker makes it easy for developers to package up and push out application changes, and spin up run-time environments on their own. Maybe too easy.
With Docker, developers can make their own decisions on how to configure and package applications. But this also means that they can make simple but dangerous mistakes that will leave the system unsafe without anyone noticing until it is too late.
Fortunately, there are some good tools that can catch many of these problems early, as part of your build pipelines and run-time configuration checks. Toni de la Fuente maintains a helpful list of Docker security and auditing tools here.
Unfortunately, many of the open source projects in this list have been shelved or orphaned. So, I want to put together a short list of the essential open source tools that are available today to help you secure your Docker environment.
Check Your Container Configuration Settings
As part of your build process and continuous run-time checks, it is important that you enforce safe and consistent configuration defaults for containers and the hosts that they run on.
The definitive guidelines for setting up Docker safely is the CIS Docker Benchmark, which lists over 100 recommendations and best practices for hardening the host configuration and Docker daemon configuration (including Swarm configuration settings), file permissions rules, container images and build file management, container runtime settings, and operations practices.
The Docker security team has provided a free tool, Docker Bench for Security, that checks Docker containers against this hardening guide (although the tests are organized a bit differently - the Swarm checks that are all run together in a separate section, for example). Docker Bench is updated for each release of the CIS benchmark guide, which is updated with each release of Docker, although there tends to be a brief lag.
Docker Bench ships as a small container which runs with high privilege, and executes a set of tests against all containers that it can find. Tests return PASS or WARN (clear fail) status, or INFO (for findings that need to be manually reviewed to see if they match expected results). NOTEs are printed for manual checks that need to be done separately.
After you run Docker Bench, you will need to work through fussy detailed findings and decide what makes sense for your environment. Docker Bench is an auditing tool, designed to be run and reviewed manually. Docker Bench Test shows how you can run Docker Bench in an automated test pipeline, by wrapping it inside the Bats test framework, although unfortunately it hasn't been updated for a couple of years.
Another free auditing tool from the Docker security team is Actuary. According to Diogo Monica at Docker, Actuary checks the same rules as Docker Bench (for now) but runs across all nodes in a Docker Swarm. Actuary is positioned as a future replacement for Docker Bench: it is written in Go (instead of Bash scripts) and is more extensible, using configurable templates for checking and testing.
Image Scanning and Policy Enforcement
In addition to making sure that your container run-time is configured correctly, you need to ensure that all of the image layers in a container are free from known vulnerabilities. This is done by static scanning of "cold images" in repos, or before they are pushed to a repo, as part of your image build process.
Commercial Docker customers can take advantage of Docker Security Scanning (DSS) (formerly known as Nautilus) to automatically and continuously check images in private registries on Docker Hub or Docker Cloud for known vulnerabilities. DSS is also used to scan Official Repositories on Docker Hub.
If you're using open source Docker, you'll need to do your own checking. There are a few good open source tools available, all of which work basically the same way:
- Scan the image (generally a binary scan), pull apart the layers, and build a detailed manifest or bill of materials of the contents.
- Take a snapshot of OS and software package vulnerability data.
- Compare the contents of the image manifest against the list of known vulnerabilities and report any matches.
The effectiveness of these security scanning tools depends on:
- Depth and completeness of static analysis - the scanner's ability to see inside image layers and the contents of those layers (packages and files).
- Quality of vulnerability feeds - coverage, and how up to date the vulnerability lists are.
- How results are presented - is it clear what the problem is, where to find it, and what to do about it.
- De-duplication and whitelisting capabilities to reduce noise.
- Scanning speed.
First, there is Clair from CoreOS, the scanning engine used in the Quay.io public container registry (an alternative to Docker Hub). Clair is a static analysis tool for Docker and appc containers, which scans an image and compares the vulnerabilities found against a whitelist to see if they have already been reviewed and accepted. It can be controlled through a JSON API or CLI.
If you're using OpenSCAP there is the oscap-docker util which can be used to scan Docker images and running containers for CVEs and compliance violations against SCAP policy guides.
Anchore is a powerful and flexible automated scanning and policy enforcement engine that is easy to integrate into your CI/CD build pipelines to check for CVEs - and much more - in Docker images. You can create whitelists (to suppress findings that you've determined are not exploitable) and blacklists (for required packages or banned packages, and prohibited content such as source code or secrets), as well as custom checks on container or application configuration rules, etc.
Anchore is available as a free SaaS online Navigator for public registries, and an open source engine for on-prem scanning. The scanning engine can be wired into your CI/CD pipelines using CLI or REST or a Jenkins plugin, to automatically analyze images as changes are checked in, and fail the build if checks don't pass. A nice overview of running Anchore can be found here.
Anchore comes with a built-in set of security and compliance policies, analysis functions, and decision gates. You can write your own analysis modules and policies, reports, and certification workflows in a high-level language, or extend the analysis engine with custom plugins.
You can also integrate the Anchore scanning engine with Anchore Navigator so that you can define policies and whitelists using Navigator's graphical editor. Anchore will subscribe to updates so that you will be automatically notified of new CVEs or updates to images in public registries.
Anchore (the company) offers premium support subscriptions, and enterprise solutions to discover, explore, and analyze images, with additional analysis modules and policies, data feeds, tooling, and workflow integration options.
Another new and ambitious open source container scanner is Dagda. Dagda builds a consolidated vulnerability database, taking snapshots of CVE information from NIST's NVD, publicly-reported security bugs in the SecurityFocus Bugtraq database, and known exploits from the Offensive Security database, and uses OWASP Dependency Check and Retire.js to analyze dependencies, to identify known security vulnerabilities in Docker images. Dagda can be controlled through the command line or its REST API, and keeps a history of all checks for auditing and trend analysis.
It also runs ClamAV against Docker images to check for trojans and other malware, and integrates with Sysdig's powerful (and free) Falco run-time anomaly checker to monitor containers on Linux hosts. Falco is installed as an agent on each host, which taps into kernel syscalls and filters against rules in a signature database to identify suspicious activity and catch attacks or operational problems on the host and inside containers.
Dagda throws everything but the kitchen sink at container security. It is a lot of work to set this up and keep all of it working, but it shows you how far you can go without having to roll out a commercial container protection solution.
Don't Leave Container Security Up to Chance
What makes Docker so compelling is also what makes it dangerous: it takes work and decisions out of Ops's hands, and gives it to developers who may not understand (or care about) the details or why they are important. Using Docker moves responsibility for packaging and configuring application run-times from Ops (who are responsible for making sure that this is done carefully and safely) to developers (who want to get it done quickly and simply).
This is why it is so important to add checks that can be run continuously to catch mistakes and known vulnerabilities in dependencies, and to enforce security and compliance policies when changes are made. The tools listed here can help you to reduce operational risks, without getting in the way of teams getting valuable work done.
Published at DZone with permission of Jim Bird , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.