8 Docker security rules to live by

Container-based applications introduce unique security challenges; here’s how to address them

8 Docker security rules to live by
Luke Price (CC BY 2.0)

Odds are, software (or virtual) containers are in use right now somewhere within your organization, probably by isolated developers or development teams to rapidly create new applications. They might even be running in production. Unfortunately, many security teams don’t yet understand the security implications of containers or know if they are running in their companies.

In a nutshell, Linux container technologies such as Docker and CoreOS Rkt virtualize applications instead of entire servers. Containers are superlightweight compared with virtual machines, with no need for replicating the guest operating system. They are flexible, scalable, and easy to use, and they can pack a lot more applications into a given physical infrastructure than is possible with VMs. And because they share the host operating system, rather than relying on a guest OS, containers can be spun up instantly (in seconds versus the minutes VMs require).

June 2016 report from the Cloud Foundry Foundation surveyed 711 companies about their use of containers. More than half had either deployed or were in the process of evaluating containers. Of those, 16 percent have already mainstreamed the use of containers, with 64 percent expecting to do so within the next year. If security teams want to seize the opportunity (borrowing a devops term) to “shift security to the left,” they need to identify and involve themselves in container initiatives now.

Developers and devops teams have embraced containers because they align with the devops philosophy of agile, continuous application delivery. However, as is the case with any new technology, containers also introduce new and unique security challenges. These include the following:

  • Inflow of vulnerable source code: Because containers are open source, images created by an organization’s developers are often updated, then stored and used as necessary. This creates an endless stream of uncontrolled code that may harbor vulnerabilities or unexpected behaviors.
  • Large attack surface: In a given environment, there would be many more containers than there would be applications, VMs, databases, or any other object that requires protecting. The large numbers of containers running on multiple machines, whether on premises or in the cloud, make it difficult to track what’s going on or to detect anomalies through the noise.
  • Lack of visibility: Containers are run by a container engine, such as Docker or Rkt, that interfaces with the Linux kernel. This creates another layer of abstraction that can mask the activity of specific containers or what specific users are doing within the containers.
  • Devops speed: The pace of change is such that containers typically have a lifespan four times shorter than that of VMs, on average. Containers can be executed in an instant, run for a few minutes, then stopped and removed. This ephemerality makes it possible to launch attacks and disappear quickly, with no need to install anything.
  • “Noisy neighbor” containers: A container might behave in a way that effectively creates a DoS attack on other containers. For example, opening sockets repeatedly will quickly bring the entire host machine to a crawl and eventually cause it to freeze up.
  • Container breakout to the host: Containers might run as a root user, making it possible to use privilege escalation to break the “containment” and access the host’s operating system.
  • “East-west” network attacks: A jeopardized container can be leveraged to launch attacks across the network, especially if its outbound network connections and ability to run with raw sockets were not properly restricted.

The best practices for securing container environments are not only about hardening containers or the servers they run on after the fact. They’re focused on securing the entire environment. Security must be considered from the moment container images are pulled from a registry to when the containers are spun down from a runtime or production environment. Given that containers are often deployed at devops speed as part of a CI/CD framework, the more you can automate, the better.

With that in mind, I present this list of best practices. Many of them are not unique to containers, but if they are “baked” into the devops process now, they will have a much greater impact on the security posture of containerized applications than if they are “bolted” on after the fact.

  1. Implement a comprehensive vulnerability management program. Vulnerability management goes way beyond scanning images when they are first downloaded from a registry. Containers can easily pass through the development cycle with access controls or other policies that are too loose, resulting in corruption that causes the application to break down or leading to compromise in runtime. A rigorous vulnerability management program is a proactive initiative with multiple checks from “cradle to grave,” triggered automatically and used as gates between the dev, test, staging, and production environments.
  2. Ensure that only approved images are used in your environment. An effective way of reducing the attack surface and preventing developers from making critical security mistakes is to control the inflow of container images into your development environment. This means using only approved private registries and approved images and versions. For example, you might sanction a single Linux distro as a base image, preferably one that is lean (Alpine or CoreOS rather than Ubuntu) to minimize the surface for potential attacks.
  3. Implement proactive integrity checks throughout the lifecycle. Part of managing security throughout the container lifecycle is to ensure the integrity of the container images in the registry and enforce controls as they are altered or deployed into production. Image signing or fingerprinting can be used to provide a chain of custody that allows you to verify the integrity of the containers.
  4. Enforce least privileges in runtime. This is a basic security best practice that applies equally in the world of containers. When a vulnerability is exploited, it generally provides the attacker with access and privileges equal to those of the application or process that has been compromised. Ensuring that containers operate with the least privileges and access required to get the job done reduces your exposure to risk.
  5. Whitelist files and executables that the container is allowed to access or run. It’s a lot easier to manage a whitelist when it is implemented from the get-go. A whitelist provides a measure of control and manageability as you learn what files and executables are required for the application to function correctly, and it allows you to maintain a more stable and reliable environment. Limiting containers so that they can access or run only pre-approved or whitelisted files and executables is a powerful nethod to mitigate risk. It not only reduces the attack surface, but also can be employed to provide a baseline for anomalies and prevent the use cases of the “noisy neighbor” and container breakout scenarios described above.
  6. Enforce network segmentation on running containers. Maintain network segmentation (or “nano-segmentation”) to segregate clusters or zones of containers by application or workload. In addition to being a highly effective best practice, network segmentation is a must-have for container-based applications that are subject to PCI DSS. It also serves as a safeguard against “east-west” attacks.
  7. Actively monitor container activity and user access. As with any IT environment, you should consistently monitor activity and user access to your container ecosystem to quickly identify any suspicious or malicious activity.
  8. Log all administrative user access to containers for auditing. While strong user access controls can restrict privileges for the majority of people who interact with containers, administrators are in a class by themselves. Logging administrative access to your container ecosystem, container registry, and container images is a good security practice and a common-sense control. It will provide the forensic evidence needed in the case of a breach, as well as a clear audit trail if needed to demonstrate compliance.

Much of the notion of “baking security into IT processes” relates to automating preventive processes from the onset. Getting aggressive about container security now can allow for containerized applications to be inherently more secure than their predecessors. However, given that containers will be deployed ephemerally and in large numbers, active detection and response -- essential to any security program -- will be critical for containerized environments. Container runtime environments will need to be monitored at all times, for anomalies, suspected breaches, and compliance purposes.

Although there’s a growing body of knowledge about container security in the public domain, it’s important to note that we’re still in the early stages. As we discover new container-specific vulnerabilities (or new-old ones such as Dirty COW), and as we make the inevitable mistakes (like the configuration error in Vine’s Docker registry that allowed a security researcher to access Vine's source code), best practices are sure to evolve.

The good news, as far as container adoption goes, is it’s still early enough to automate strong security controls into container environments. The not-so-good news is security teams need to know about container initiatives early enough to make that happen, and more often than not they don’t. To realize the potential security improvements that can be achieved in the transition to container-based application development, that needs to change ... soon. Educating yourself about containers and the security implications of using them is a good start.

New Tech Forum provides a venue to explore and discuss emerging enterprise technology in unprecedented depth and breadth. The selection is subjective, based on our pick of the technologies we believe to be important and of greatest interest to InfoWorld readers. InfoWorld does not accept marketing collateral for publication and reserves the right to edit all contributed content. Send all inquiries to newtechforum@infoworld.com.

Copyright © 2017 IDG Communications, Inc.