# Kubernetes Security - [Introduction](#introduction) - [Service Accounts](#service-accounts) - [Kubernetes Secrets](#kubernetes-secrets) - [Encrypting the certificate for Kubernetes. SSL certificates with Let's Encrypt in Kubernetes Ingress via cert-manager](#encrypting-the-certificate-for-kubernetes-ssl-certificates-with-lets-encrypt-in-kubernetes-ingress-via-cert-manager) - [RBAC](#rbac) - [Admission Control](#admission-control) - [Security Best Practices Across Build, Deploy, and Runtime Phases](#security-best-practices-across-build-deploy-and-runtime-phases) - [Kubernetes Authentication and Authorization](#kubernetes-authentication-and-authorization) - [Kubernetes Authentication Methods](#kubernetes-authentication-methods) - [X.509 client certificates](#x509-client-certificates) - [Static HTTP Bearer Tokens](#static-http-bearer-tokens) - [OpenID Connect](#openid-connect) - [Implementing a custom Kubernetes authentication method](#implementing-a-custom-kubernetes-authentication-method) - [Pod Security Policies (SCCs - Security Context Constraints in OpenShift)](#pod-security-policies-sccs---security-context-constraints-in-openshift) - [EKS Security](#eks-security) - [Tweets](#tweets) ## Introduction * [cilium.io](https://cilium.io/) * [Dzone - devops security at scale](https://dzone.com/articles/devops-security-at-scale) * [Dzone - Kubernetes Policy Management with Kyverno](https://dzone.com/articles/kubernetes-policy-management-with-kyverno) * [github Kyverno - Kubernetes Native Policy Management](https://github.com/nirmata/kyverno/) * [nirmata.com: Auto-labeling Kubernetes resources with Kyverno](https://nirmata.com/2020/10/30/auto-labeling-kubernetes-resources-with-kyverno) * [Dzone - OAuth 2.0](https://dzone.com/articles/oauth-20-beginners-guide) * [Kubernetes Security Best Practices π](https://github.com/freach/kubernetes-security-best-practice/blob/master/README.md#firewall-ports-fire) * [jeffgeerling.com: Everyone might be a cluster-admin in your Kubernetes cluster](https://www.jeffgeerling.com/blog/2020/everyone-might-be-cluster-admin-your-kubernetes-cluster) * [Microsoft.com: Attack matrix for Kubernetes π](https://www.microsoft.com/security/blog/2020/04/02/attack-matrix-kubernetes/) * [codeburst.io: 7 Kubernetes Security Best Practices You Must Follow](https://codeburst.io/7-kubernetes-security-best-practices-you-must-follow-ae32f1ed6444) * [thenewstack.io: Laying the Groundwork for Kubernetes Security, Across Workloads, Pods and Users](https://thenewstack.io/laying-the-groundwork-for-kubernetes-security-across-workloads-pods-and-users/) * [horovits.wordpress.com: Kubernetes Security Best Practices](https://horovits.wordpress.com/2020/07/15/kubernetes-security-best-practices/) * [containerjournal.com: How to Secure Your Kubernetes Cluster π](https://containerjournal.com/topics/container-security/how-to-secure-your-kubernetes-cluster/) * [medium: How to Harden Your Kubernetes Cluster for Production π](https://medium.com/better-programming/how-to-harden-your-kubernetes-cluster-for-production-7e47990efc2a) * [kubernetes.io: Cloud native security for your clusters](https://kubernetes.io/blog/2020/11/18/cloud-native-security-for-your-clusters/) * [tldrsec.com: Risk8s Business: Risk Analysis of Kubernetes Clusters π](https://tldrsec.com/guides/kubernetes/) A zero-to-hero guide for assessing the security risk of your Kubernetes cluster and hardening it. * [microsoft.com: Threat matrix for Kubernetes π](https://www.microsoft.com/security/blog/2020/04/02/attack-matrix-kubernetes/) * [labs.bishopfox.com: Bad Pods: Kubernetes Pod Privilege Escalation π](https://labs.bishopfox.com/tech-blog/bad-pods-kubernetes-pod-privilege-escalation) What are the risks associated with overly permissive pod creation in Kubernetes? The answer varies based on which of the hostβs namespaces and security contexts are allowed. In this post, I will describe eight insecure pod configurations and the corresponding methods to perform privilege escalation. This article and the accompanying repository were created to help penetration testers and administrators better understand common misconfiguration scenarios. * [sysdig.com: Kubernetes Security Guide π](https://sysdig.com/resources/ebooks/kubernetes-security-guide/) Best practices, guidance and steps for implementing Kubernetes security. * [resources.whitesourcesoftware.com: Kubernetes Security Best Practices π](https://resources.whitesourcesoftware.com/blog-whitesource/kubernetes-security) * [sysdig.com: Getting started with Kubernetes audit logs and Falco π](https://sysdig.com/blog/kubernetes-audit-log-falco/) * [thenewstack.io: Jetstack Secure Promises to Ease Kubernetes TLS Security](https://thenewstack.io/jetstack-secure-promises-to-ease-kubernetes-tls-security/) * [thenewstack.io: Best Practices for Securely Setting up a Kubernetes Cluster](https://thenewstack.io/best-practices-for-securely-setting-up-a-kubernetes-cluster/) * [stackrox/Kubernetes_Security_Specialist_Study_Guide π](https://github.com/stackrox/Kubernetes_Security_Specialist_Study_Guide) * [thenewstack.io: A Security Comparison of Docker, CRI-O and Containerd π](https://thenewstack.io/a-security-comparison-of-docker-cri-o-and-containerd/) * [github.com/stackrox: Certified Kubernetes Security Specialist Study Guide π](https://github.com/stackrox/Kubernetes_Security_Specialist_Study_Guide) * [youtube: Kubernetes Security: Attacking and Defending K8s Clusters - by Magno Logan](https://www.youtube.com/watch?v=OOHmg1J_8ck&ab_channel=RedTeamVillage) * [cncf.io: Kubernetes Security π](https://www.cncf.io/blog/2021/03/22/kubernetes-security/) * [microsoft.com: Secure containerized environments with updated threat matrix for Kubernetes](https://www.microsoft.com/security/blog/2021/03/23/secure-containerized-environments-with-updated-threat-matrix-for-kubernetes/) * [kyverno.io π](https://kyverno.io/) Kubernetes Native Policy Management. Open Policy Agent? Thatβs old school. Securely manage workloads on your kubernetesio clusters with this handy new tool, Kyverno.Kyverno is a policy engine designed for Kubernetes. With Kyverno, policies are managed as Kubernetes resources and no new language is required to write policies. This allows using familiar tools such as kubectl, git, and kustomize to manage policies. Kyverno policies can validate, mutate, and generate Kubernetes resources. The Kyverno CLI can be used to test policies and validate resources as part of a CI/CD pipeline. [youtube: The Way of the Future | Kubernetes Policy Management with Kyverno](https://www.youtube.com/watch?v=8fgrjBnxqi0&t=270s&ab_channel=AppSecEngineer) - [youtube: Securing and Automating Kubernetes with Kyverno](https://www.youtube.com/watch?v=0cJAfmQ7Emg&ab_channel=CloudNativeIslamabad) * [kyverno.io/policies π](https://kyverno.io/policies/) K8s policies available in the community repository * [cyberark.com: Attacking Kubernetes Clusters Through Your Network Plumbing: Part 1](https://www.cyberark.com/resources/threat-research-blog/attacking-kubernetes-clusters-through-your-network-plumbing-part-1?utm_sq=goa40uvlx1) * [redkubes.com: 10 Kubernetes Security Risks & Best Practices](https://redkubes.com/10-kubernetes-security-risks-best-practices/) * [thenewstack.io: Defend the Core: Kubernetes Security at Every Layer](https://thenewstack.io/defend-the-core-kubernetes-security-at-every-layer/) * [techmanyu.com: Kubernetes Security with Kube-bench and Kube-hunter π](https://www.techmanyu.com/kubernetes-security-with-kube-bench-and-kube-hunter-6765bf44ebc6) * [kube-bench π](https://github.com/aquasecurity/kube-bench) Checks whether Kubernetes is deployed according to security best practices as defined in the CIS Kubernetes Benchmark * [kube-hunter π](https://github.com/aquasecurity/kube-hunter) Hunt for security weaknesses in Kubernetes clusters * [k21academy.com: Secure and Harden Kubernetes, AKS and EKS Cluster with kube-bench, kube-hunter and CIS Benchmarks π](https://k21academy.com/docker-kubernetes/kubernetes-security/kube-bench-cis/) * [Analyze Kubernetes Audit logs using Falco π](https://github.com/developer-guy/falco-analyze-audit-log-from-k3s-cluster) Detect intrusions that happened in your Kubernetes cluster through audit logs using Falco * [blog.kasten.io: Kubernetes Ransomware Protection with Kasten K10 v4.0](https://blog.kasten.io/ransomware-protection-kasten-k10-v4) * [helpnetsecurity.com: Kubestriker: A security auditing tool for Kubernetes clusters π](https://www.helpnetsecurity.com/2021/05/04/security-kubernetes/) Kubestriker is an open-source, platform-agnostic tool for identifying security misconfigurations in Kubernetes clusters. * [Kubernetes Goat π](https://madhuakula.com/kubernetes-goat) is designed to be an intentionally vulnerable cluster environment to learn and practice Kubernetes security. * [itnext.io: How-To: Kubernetes Cluster Network Security π](https://itnext.io/how-to-kubernetes-cluster-network-security-f19bc99161f5) * [gist.github.com: How to protect your ~/.kube/ configuration](https://gist.github.com/PatrLind/e651d3cbc3bf68e4bd9fcc9568cbd3fb) * [levelup.gitconnected.com: Enforce Audit Policy in Kubernetes (k8s)](https://levelup.gitconnected.com/enforce-audit-policy-in-kubernetes-k8s-34e504733300) * [snyk.io: 10 Kubernetes Security Context settings you should understand](https://snyk.io/blog/10-kubernetes-security-context-settings-you-should-understand/) * [magalix.com: Top 8 Kubernetes Security Best Practices π](https://www.magalix.com/blog/top-8-kubernetes-security-best-practices) * [redhat.com: The State of Kubernetes Security](https://www.redhat.com/en/blog/state-kubernetes-security) * [igorzhivilo.com: Network policy and Calico CNI to Secure a Kubernetes cluster](https://igorzhivilo.com/saas/network-policy-calico-kubernetes/) * [fairwinds.com: Discover the Top 5 Kubernetes Security Mistakes You're (Probably) Making](https://www.fairwinds.com/blog/top-5-kubernetes-security-mistakes) * [tigera.io: Kubernetes security policy design: 10 critical best practices π](https://www.tigera.io/blog/kubernetes-security-policy-10-critical-best-practices/) * [empresas.blogthinkbig.com: Descubierta una vulnerabilidad en Kubernetes que permite acceso a redes restringidas (CVE-2020-8562)](https://empresas.blogthinkbig.com/descubierta-vulnerabilidad-kubernetes-permite-acceso-redes-restringidas-cve-2020-8562/) * [thenewstack.io: Kubernetes: An Examination of Major Attacks π](https://thenewstack.io/kubernetes-an-examination-of-major-attacks/) Constant vigilance is required to ensure that cloud infrastructure is locked down and that DevSecOps teams have the right tools for the job. * [nsa.gov: NSA, CISA release Kubernetes Hardening Guidance ππ](https://www.nsa.gov/News-Features/Feature-Stories/Article-View/Article/2716980/nsa-cisa-release-kubernetes-hardening-guidance/) * [Kubernetes Hardening Guidance ππ](https://media.defense.gov/2021/Aug/03/2002820425/-1/-1/1/CTR_KUBERNETES%20HARDENING%20GUIDANCE.PDF) * [thenewstack.io: The NSA Can Help Secure Your Kubernetes Clusters](https://thenewstack.io/the-nsa-can-help-you-secure-your-kubernetes-clusters/) * [therecord.media: NSA, CISA publish Kubernetes hardening guide ππ](https://therecord.media/nsa-cisa-publish-kubernetes-hardening-guide/) - Scan containers and Pods for vulnerabilities or misconfigurations. - Run containers and Pods with the least privileges possible. - Use network separation to control the amount of damage a compromise can cause. - Use firewalls to limit unneeded network connectivity and encryption to protect confidentiality. - Use strong authentication and authorization to limit user and administrator access as well as to limit the attack surface. - Use log auditing so that administrators can monitor activity and be alerted to potential malicious activity. - Periodically review all Kubernetes settings and use vulnerability scans to help ensure risks are appropriately accounted for and security patches are applied. * [cloud.redhat.com: OpenShift and the NSA-CISA βKubernetes Hardening Guidanceβ](https://cloud.redhat.com/blog/openshift-and-the-nsa-cisa-kubernetes-hardening-guidance) Red Hat OpenShift is the quickest path to meeting the NSAβs Kubernetes hardening guidance * [Kubescape π](https://github.com/armosec/kubescape) **kubescape is the first tool for testing if Kubernetes is deployed securely as defined in Kubernetes Hardening Guidance by to NSA and CISA.** Tests are configured with YAML files, making this tool easy to update as test specifications evolve. * [cloud.redhat.com: Top Open Source Kubernetes Security Tools of 2021 ππ](https://cloud.redhat.com/blog/top-open-source-kubernetes-security-tools-of-2021) * [csoonline.com: Kubernetes hardening: Drilling down on the NSA/CISA guidance](https://www.csoonline.com/article/3629049/kubernetes-hardening-drilling-down-on-the-nsa-cisa-guidance.html) The new guidance gives a solid foundation for hardening Kubernetes container environments. These are its key components and why they are important. * [cncf.io: How to secure your Kubernetes control plane and node components](https://www.cncf.io/blog/2021/08/20/how-to-secure-your-kubernetes-control-plane-and-node-components/) * [redhat.com: State of Kubernetes Security Report - Spring 2021 (PDF) π](https://www.redhat.com/rhdc/managed-files/cl-state-kubernetes-security-report-ebook-f29117-202106-en.pdf) * [kubernetes.io: Overview of Cloud Native Security ππ](https://kubernetes.io/docs/concepts/security/overview/) This overview defines a model for thinking about Kubernetes security in the context of Cloud Native security. * [elastisys.com: NSA and CISA Kubernetes Security Guidance: Summarized and Explained](https://elastisys.com/nsa-and-cisa-kubernetes-security-guidance-summarized-and-explained/)
Kubernetes base64 encodes secrets because that makes arbitrary data play nice with JSON. It had nothing to do with the security model (or lack thereof). It did not occur to us at the time that people could mistake base64 for some form of encryption.
— Daniel Smith (@originalavalamp) July 4, 2021
#OAuth has 4 Flows for retrieving an Access Token.
— Rohit (@sec_r0) January 8, 2021
If you have worked with it, you know how difficult is it to remember what is what.
A Zine says a lot, seriously a lot. Check this out.
Idea credits @b0rk #IAM #security #infosec #webdev #web #webcomic #webcomics
RT if useful pic.twitter.com/fbrls0V08K