Kubernetes Security Strategies Recommended by Owasp
Kubernetes Security Strategies Recommended by Owasp
Mastering
Kubernetes Security
Top Strategies
Recommended
by OWASP
SENTINELONE EBOOK
Table of Contents
Introduction 3
What is Kubernetes? 4
3. Overly-Permissive RBAC 6
4. Policy Enforcement 7
5. Inadequate Logging 8
6. Broken Authentication 9
7. Network Segmentation 10
8. Secrets Management 10
Conclusion 12
In this eBook, we explore the top ten Kubernetes security risks and provide recommenda-
tions for mitigating these risks.
Kubernetes is a powerful tool that offers self-healing, auto-scaling, and service discovery
features. In addition, it allows developers to deploy their applications as workloads that
can run on any platform that supports Docker containers.
03 Understanding Kubernetes
Security
Teams securing Kubernetes are responsible for addressing all its various layers and
services. Kubernetes security comprises three main components: securing the cluster,
securing nodes, and securing applications.
While many security configurations are often set in the securityContext of the manifest
itself, other misconfigurations can be detected elsewhere. They must first be detected in
both runtime and code to prevent misconfigurations. It is imperative to enforce that appli-
cations run as non-root users, run in non-privileged mode, and set ‘AllowPrivilegeEscala-
tion’ to ‘False’ to disallow child processes from gaining more privileges than their parents.
Security teams can use tools such as Open Policy Agent as a policy engine to detect com-
mon misconfigurations like the ones listed above. Using the CIS Benchmark for Kubernetes
is a good starting point for discovering misconfigurations. However, it is important to contin-
uously monitor and remediate any potential misconfigurations to ensure the security and
reliability of a Kubernetes workload.
• Image integrity – Container images are made up of layers, each bringing possible
security risks. Since container images use third-party packages extensively, they can
be dangerous to run within a trusted environment. To mitigate this, it’s important to
ensure image integrity by validating software at each phase using in-toto attestations.
Doing so increases the SLSA level of the build pipeline, which means it is more resilient
against attacks. Additionally, using image signing and verification through cryptographic
key-pairs can detect tampering with the artifacts throughout the DevOps workflow,
which is an essential step in building a secure supply chain.
• Known software vulnerabilities – Security flaws are widespread due to the extensive
use of third-party packages in container images. Image vulnerability scanning is crucial
for enumerating known security issues in container images, which should be used
as a first line of defense. Open-source tools such as Clair and trivy statically analyze
container images for known vulnerabilities such as CVEs, and should be used as early in
the development cycle as reasonably possible.
Enforcing policies to prevent unapproved images from being used is also essential. Kuberne-
tes admission controls and policy engines such as Open Policy Agent and Kyverno can reject
workload images that haven’t been scanned for vulnerabilities, use a base image that’s not
explicitly allowed, don’t include an approved SBOM, or originate from untrusted registries.
3. Overly-Permissive RBAC
Role-based access control (RBAC) allows the definition of who has access to what resources
in a cluster and what they can do with those resources. When configured correctly, RBAC
helps prevent unauthorized access and protect sensitive data.
However, if RBAC is not configured correctly, it can lead to overly-permissive settings that
allow users to access resources that they should not have access to or perform actions that
they should not be able to perform. This can create serious security risks, including data
breaches, data loss, and compromise.
4. Policy Enforcement
Policy enforcement involves the implementation of rules and regulations to ensure compli-
ance with organizational policies. In the context of Kubernetes, policy enforcement ensures
that the Kubernetes cluster adheres to the security policies set by the organization. These
policies could be related to access control, resource allocation, network security, or any
other aspect of the Kubernetes cluster.
Policy enforcement is essential for ensuring the security and compliance of the Kuberne-
tes cluster. Failure to enforce policies can lead to security breaches, data loss, and other
potential risks. Additionally, policy enforcement helps maintain the integrity and stability
of the Kubernetes cluster, ensuring that resources are allocated effectively and efficiently.
• Defining policies that align with organizational goals and regulatory requirements.
• Regularly reviewing and updating policies to ensure they remain relevant and effective.
These logs can help identify system issues and provide valuable insight into system
performance, security breaches, and data loss. Various sources, including application code,
Kubernetes components, and system-level processes, can generate Kubernetes logs.
• Use a Centralized Logging System – A centralized logging system collects and stores
logs from all Kubernetes components and applications in a single location. This makes
it easier to identify and respond to issues with the system. There are many different
centralized logging systems available for Kubernetes. Use SentinelOne Security Data
Lake to centralize event logs from all components of Kubernetes cluster.
• Use Labels and Annotations – Labels and annotations are a powerful feature of Kuber-
netes that can provide additional context to logs. Labels are key-value pairs that can be
attached to Kubernetes objects, such as pods and services. Annotations are similar to
labels but can contain larger amounts of information. Labels and annotations can filter
and search logs based on specific criteria. For example, security teams can add a label
to all pods that are part of a particular application and then search for logs from those
pods based on the label.
• Monitor Kubernetes Logs – Monitoring logs regularly allows security teams to identify
issues with the system and respond to them quickly. There are many different tools
available for monitoring Kubernetes logs. Use SentinelOne Security Data Lake to detect
anomalies from event logs from the entire Kubernetes cluster.
6. Broken Authentication
Broken authentication is a vulnerability that allows attackers to bypass authentication and
gain unauthorized access to an application or system. Authentication is verifying a user’s or
system’s identity, usually by requiring a username and password. If an attacker can bypass
the authentication process, they can gain access to sensitive data, systems, or applications.
In Kubernetes, broken authentication can occur due to several factors, including:
• Strong authentication credentials – Users must use strong and unique passwords or
authentication tokens that are not easily guessable.
By default, any workload can communicate with another workload when no additional
controls are put in place in a Kubernetes network. An attacker can leverage this default
behavior by exploiting a running workload to probe the internal network, move to other
running containers, or even invoke private APIs.
Isolating traffic within the context of a Kubernetes minimizes damage and loss should a
container become compromised. Several techniques can be used to implement network
segmentation in Kubernetes clusters to stop lateral movement and still allow valid traffic to
route as normal. Two important techniques are:
• Using Network Policies – Kubernetes supports network policies, which define how
traffic flows between pods and namespaces. Using network policies controls which
pods can communicate with each other and which ones are isolated from the rest of
the cluster.
• Using Network Segmentation Tools – Many third-party tools can implement network
segmentation in Kubernetes clusters. The most popular ones include Calico, Weave
Net, and Cilium. These tools provide advanced network segmentation capabilities,
such as encryption, firewalling, and intrusion detection.
8. Secrets Management
A “secret” is an object in Kubernetes that contains sensitive data such as passwords,
certificates, and API keys. Secrets store confidential data that should be inaccessible to
other users and processes within the cluster. Kubernetes secrets are stored in etcd, a
distributed key-value store used by Kubernetes to store all cluster data.
Though secrets are a very useful function in the Kubernetes ecosystem, they need to be han-
dled with caution. Managing Kubernetes secrets can be broken down into the following steps:
1. Deploy encryption at rest – A potential attacker can gain considerable visibility into
the state of a cluster by accessing the etcd database, which contains any information
accessible via the Kubernetes API. Kubernetes offers encryption at rest; a feature in-
troduced in version 1.7 and v1 beta since 1.13. Encryption at rest safeguards secret re-
sources in etcd, ensuring that the content of those secrets remains hidden from parties
3. Ensure that logging and auditing are in place – This helps detect malicious or abnor-
mal behavior, including access to secrets. Kubernetes clusters produce useful metrics
around activities that can be leveraged to detect such behaviors. Therefore, enabling
and configuring Kubernetes audit records and centralizing their storage is advisable.
A few more additional tips and tricks include rotating secrets regularly to reduce the risk of
secrets being compromised, auditing secret access to detect any unauthorized access to
secrets, and using third-party secret management tools such as HashiCorp Vault or Cyber-
Ark Conjur to manage Kubernetes secrets.
Cluster compromise can happen when there are misconfigurations in core Kubernetes
components. The most commonly misconfigured components on the Kubernetes control
plan and nodes include the below:
• Kube-apiserver – Inspect the internet accessibility of the API server in use and keep
the Kubernetes API off of any public networks.
Performing CIS Benchmark scans and audits can help security teams focus on eradicating
component misconfigurations. Using hosted services such as EKS, GKE, or AKS can help
implement secure defaults and limit some of the options for component configuration.
• Track CVE databases – A key element in managing known and new vulnerabilities in
Kubernetes is to stay up-to-date on CVE databases, security disclosures, and commu-
nity updates. Security teams can use this intel to build actionable plans to implement
regular patch management processes.
• Implement continuous scanning – Using a tool such as OPA Gatekeeper can be help-
ful in writing custom rules that work to uncover any vulnerable components within a
Kubernetes cluster. Security teams can then track and document these findings to im-
prove their security processes and policies.
05 Conclusion
Though Kubernetes is powerful, its adoption comes with the inevitable introduction of
new risks into an environment’s existing infrastructure and applications. Having a compre-
hensive approach to securing Kubernetes ensures security teams can address all types of
vulnerabilities and risks that can affect the individual layers of a Kubernetes cluster.
Following the recommendations provided in this post can set businesses on the right path
to hardening their Kubernetes environments and reduce its attack surface. Through best
practices implementation, security teams managing Kubernetes can gain visibility into their
environments and better control each layer of their Kubernetes deployment.
LEARN MORE
A Leader in the 2022 Magic Record Breaking ATT&CK Evaluation 96% of Gartner Peer InsightsTM
Quadrant for Endpoint • 100% Protection. 100% Detection EDR Reviewers Recommend
Protection Platforms • Top Analytic Coverage, 3 Years Running SentinelOne Singularity
• 100% Real-time with Zero Delays
About SentinelOne
More Capability. Less Complexity. SentinelOne is pioneering the
future of cybersecurity with autonomous, distributed endpoint
intelligence aimed at simplifying the security stack without
forgoing enterprise capabilities. Our technology is designed to
scale people with automation and frictionless threat resolution.
Are you ready?
sentinelone.com
Mastering_Kubernetes_Security_|_Top_Strategies_Recommended_by_OWASP_05222023
© SentinelOne 2023
SENTINELONE EBOOK