Many organizations are running applications in cloud native environments, using containers and orchestration to facilitate scalability and resilience. If youre a member of the Operations, DevOps or even DevSecOps team setting up these environments for your company, how do you know whether your deployments are secure? If youre a security professional with experience of traditional server- or virtual machine-based systems, how can you adapt your existing knowledge ready for container-based deployments? And as a developer in the cloud native world, what do you need to think about to improve the security of your containerized applications? This book dives into some of the key underlying technologies that containers and cloud native rely on, to leave you better equipped to assess the security risks and potential solutions applicable to your environment, and to help you avoid falling into bad practices that will leave your technology deployments exposed.
In this book you will learn about many of the building block technologies and mechanisms that are commonly used in container-based systems, and how they are constructed in the Linux operating system. Together we will dive deep into the underpinnings of how containers work and how they communicate, so that you are well versed in not just the what of container security, but more importantly the why. My goal in writing it is to help you to better understand whats happening when you deploy containers. I want to encourage you to build mental models that allow you to make your own assessment of potential security risks that could affect your deployments.
This book primarily considers the kind of application containers that many businesses are using these days to run their business applications in systems like Kubernetes and Docker. This is in contrast to system containers such as LXC and LXD from the ). However, the basic mechanisms used to create application and system containers alike are control groups, namespaces and chroot, so this book will give you a solid foundation from which you may wish to explore the differences in approach taken by the different container projects.
Who this book is for
Whether you consider yourself a developer, a security professional, an operator or a manager, this book will suit you best if you like to get into the nitty-gritty of how things work, and you enjoy time spent in a Linux terminal.
If you are looking for an instruction manual that gives a step-by-step guide to securing containers, this may not be the book for you. I dont believe there is a one-size-fits-all approach that would work for every application in every environment and every organization. Instead, I want to help you understand what is happening when you run applications in containers, and how different security mechanisms work, so that you can judge the risks for yourself.
As youll find out later in this book, containers are made with a combination of features from the Linux kernel. Securing containers involves using a lot of the same mechanisms as you would use on a Linux host. (I use the term host to cover both virtual machines and bare-metal servers.) I lay out how these mechanisms work, and then show how they apply in containers. If you are an experienced sysadmin, youll be able to skip over some sections to get to the container-specific information.
I assume that you have some basic familiarity with containers, and you have probably at least toyed with Docker or Kubernetes. You will understand terms like pulling a container image from a registry or running a container even if you dont know exactly what is happening under the covers when you take these actions. I dont expect you to know the details of how containers work - at least, not until you have read the book.
What this book covers
Well start in by considering threat model and attack vectors that affect container deployments, and the aspects that differentiate container security from traditional deployment security. The remainder of the book is concerned with helping you build a thorough understanding of containers and these container-specific threats, and how you can defend against them.
Before you can really think about how to secure containers, youll need to know how they work..
In addresses the need to identify container images with known software vulnerabilities.
In .
Then we will turn to the communications between containers. we will see how certificates and other credentials can be safely (or not so safely) passed to containers at runtime.
In we will consider ways in which security tooling can prevent attacks at runtime, taking advantage of the features of containers.
Finally, reviews the top ten security risks published by the Open Web Application Security Project, and considers container-specific approaches for addressing them. Spoiler alert: some of the top security risks are addressed in exactly the same way whether your application is containerized or not.
A note about Kubernetes
These days the majority of folks using containers are doing so under the Kubernetes orchestrator. An orchestrator automates the process of running different workloads in a cluster of machines, and there are places in this book where I will assume that you have a basic grasp of this concept. In general, I have tried to stay focused on concepts that act at the level of the underlying containers - the data plane in a Kubernetes deployment.
Because Kubernetes workloads run in containers, this book is relevant to Kubernetes security, but it is not a comprehensive treatment of everything related to securing Kubernetes or cloud native deployments. There are many other concerns around the configuration and use of the control plane components that are outside the scope of this book. If you would like more on this topic, you might be interested in the OReilly Kubernetes Security report (which I co-authored with Michael Hausenblas).