Slide 1

Slide 1 text

Kubernetes Security Detection Engineering - Mapping Back to MITRE ATT&CK Matrix HITB 2023 AMS Madhu Akula

Slide 2

Slide 2 text

About Me - Madhu Akula πŸ‘‰ Pragmatic Security Leader, working on Cloud Native Infra, Security, and Startups πŸ‘‰ Creator of Kubernetes Goat, Hacker Container, tools.tldr.run, many other OSS projects. πŸ‘‰ Speaks & Trains at Black Hat (USA, EU, Asia), DEF CON, GitHub, USENIX, OWASP, All Day DevOps, SANS, DevSecCon, CNCF, c0c0n, Nullcon, null, many others around the globe. πŸ‘‰ Author of Security Automation with Ansible2, OWASP KSTG, whitepapers, etc. πŸ‘‰ Technical reviewer (multiple books) & Review board member of multiple conferences, organizations, communities, advisory, etc. πŸ‘‰ Found security vulnerabilities in 200+ organizations and products including Google, Microsoft, AT&T, Adobe, eBay, WordPress, Ntop, Cloudflare, Yahoo, LocalBitcoins, etc. πŸ‘‰ Certified Kubernetes(CKA/CKS), Offensive Security Certified Professional, etc. πŸ‘‰ Never ending learner! @madhuakula https://madhuakula.com

Slide 3

Slide 3 text

What is Docker? https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/#going-back-in-time @madhuakula

Slide 4

Slide 4 text

What is Docker? ● Docker is an open source platform for building, deploying, and managing containerized applications ● Docker became the de facto standard to build and share containerized apps - from desktop, to the cloud, even edge devices ● Docker enables developers to easily pack, ship, and run any application as a lightweight, portable, self-sufficient container, which can run virtually anywhere https://docs.docker.com/get-started/overview/ @madhuakula

Slide 5

Slide 5 text

What is Kubernetes? Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available. https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/ @madhuakula

Slide 6

Slide 6 text

What is Kubernetes? @madhuakula

Slide 7

Slide 7 text

The illustrated children's guide to Kubernetes https://www.youtube.com/watch?v=3I9PkvZ80BQ @madhuakula

Slide 8

Slide 8 text

Why Kubernetes Security? @madhuakula Lack of knowledge in security teams

Slide 9

Slide 9 text

Rapidly growing Cloud Native Landscape ecosystem Why Kubernetes Security? @madhuakula

Slide 10

Slide 10 text

Technology Gap Adoption & Maturity Why Kubernetes Security? @madhuakula

Slide 11

Slide 11 text

Why Kubernetes Security? @madhuakula

Slide 12

Slide 12 text

MITRE ATT&CK for Kubernetes https://attack.mitre.orghttps//microsoft.github.io/Threat-Matrix-for-Kubernetes/ @madhuakula

Slide 13

Slide 13 text

Kubernetes Attack Path / Kill Chain @madhuakula

Slide 14

Slide 14 text

Practical MITRE ATT&CK for Kubernetes - Attack Path https://youtu.be/7nc78ZrvP4Y @madhuakula

Slide 15

Slide 15 text

Let’s map back Attack Path to Detection Engineering @madhuakula

Slide 16

Slide 16 text

Defense In Depth - Layered Approach Some of the very high level abstraction layers, each layer contains many ways how we can secure and defend against attackers. ● Application Security ● Supply Chain Security ● Infrastructure Security ● Runtime Security ● Continuous Security @madhuakula

Slide 17

Slide 17 text

Why Layered Approach? https://github.com/cncf/financial-user-group/blob/master/projects/k8s-threat-model/AttackTrees/AttackerOnTheNetwork.md Attackers have many ways! Defenders have many layers! @madhuakula

Slide 18

Slide 18 text

@madhuakula πŸ”₯ Let’s focus on detecting Container Escape / Privilege Escalation

Slide 19

Slide 19 text

There are many things we need to think as you seen it’s a layered approach! πŸ‘‰ Here are some of the things you can think of looking for detection from various perspectives of an attacker Detection - Container Escape / Privilege Escalation @madhuakula πŸ›‘ Standard Linux Server logging (SSH, System, Services, etc. /var/log/*) πŸ›‘ Container/Pod logs, and Node level system logging πŸ›‘ Components (Kubelet, Runtime, Middlewares, Entrypoints, etc.) πŸ›‘ Admission Controller/Audit Logging from Kubernetes πŸ›‘ Runtime Security logging (Things like Falco, Tetragon, etc. - SYSCALLs, PS, FIM, Net, Flow, etc. ) πŸ›‘ [Near] Real-time Proactive Monitoring, Detection / Prevention

Slide 20

Slide 20 text

Demo Time 🀞 @madhuakula

Slide 21

Slide 21 text

What just happened! @madhuakula https://madhuakula.com/kubernetes-goat/docs/scenarios/scenario-21/ebpf-runtime-security-monitoring-and-detection-i n-kubernetes-cluster-using-cilium-tetragon/welcome

Slide 22

Slide 22 text

βœ… List of logs for Kubernetes Security Detection πŸ‘‰ API Server logs: Kubernetes API server, including audit logs, requests and responses, and authentication logs. πŸ‘‰ Kubernetes Audit Logs: Audit Kubernetes can provide insight into activities related to API server requests and resource changes. πŸ‘‰ Controller Manager logs: Kubernetes Controller Manager, including events, component status, and leader election. πŸ‘‰ etcd logs: Kubernetes etcd datastore, including request and response logs, snapshot creation, and cluster state changes. πŸ‘‰ Kubelet logs: Kubernetes Kubelet, including container logs, node status, and pod events. πŸ‘‰ kube-proxy logs: Kubernetes kube-proxy, including service proxying, health checks, and NAT operations. @madhuakula

Slide 23

Slide 23 text

βœ… List of logs for Kubernetes Security Detection πŸ‘‰ Network policy logs: Kubernetes Network Policies, including rule matches and denied connections. πŸ‘‰ Pod logs: Kubernetes pods, including container logs, application logs, and any error or warning messages. πŸ‘‰ RBAC logs: Kubernetes Role-Based Access Control, including user authentication and authorization events. πŸ‘‰ Scheduler logs: Kubernetes scheduler, including scheduling decisions, pod status updates, and failed scheduling attempts. πŸ‘‰ Service Mesh Logs: Service mesh components like Istio or Linkerd can provide insight into network activity within the mesh, including service-to-service communication and security policies. @madhuakula

Slide 24

Slide 24 text

βœ… List of logs for Kubernetes Security Detection πŸ‘‰ Container Runtime Logs: Container runtimes like Docker or containerd can provide insight into container activities such as process execution, file system operations, and network communication. πŸ‘‰ Container Network Interface (CNI) Plugin Logs: CNI plugins can provide visibility into network activities, including network policies, network connectivity, and network segmentation. πŸ‘‰ Host System Logs: The host system can provide insight into activities related to system-level events, including process creation, file system operations, and network communication. πŸ‘‰ Application Logs: Applications running inside containers can provide insight into application-level activities, including user actions and application-level vulnerabilities. πŸ‘‰ Many other context related Telemetry (Open Telemetry), Tracing data is a gold mine of information for the detection engineering to make the most out of the systems @madhuakula

Slide 25

Slide 25 text

How can we learn and practice to defend against MITRE ATT&CK ? @madhuakula

Slide 26

Slide 26 text

Kubernetes Goat is an interactive Kubernetes security learning playground. Intentionally vulnerable by design scenarios to showcase the common misconfigurations, real-world vulnerabilities, and security issues in Kubernetes clusters, containers, and cloud native environments. What is Kubernetes Goat 🐐 @madhuakula

Slide 27

Slide 27 text

⚑ Get Started with Kubernetes Goat 🐐 https://madhuakula.com/kubernetes-goat @madhuakula

Slide 28

Slide 28 text

πŸ”₯ Kubernetes Goat Audience πŸ’₯ Attackers & Red Teams πŸ›‘ Defenders & Blue Teams 🧰 Products & Vendors πŸ” Developers & DevOps Teams πŸ’‘ Interested in Kubernetes Security @madhuakula

Slide 29

Slide 29 text

πŸš€ Scenarios in Kubernetes Goat 1. Sensitive keys in codebases 2. DIND (docker-in-docker) exploitation 3. SSRF in the Kubernetes (K8S) world 4. Container escape to the host system 5. Docker CIS benchmarks analysis 6. Kubernetes CIS benchmarks analysis 7. Attacking private registry 8. NodePort exposed services 9. Helm v2 tiller to PwN the cluster - [Deprecated] 10. Analyzing crypto miner container 11. Kubernetes namespaces bypass 12. Gaining environment information 13. DoS the Memory/CPU resources 14. Hacker container preview 15. Hidden in layers 16. RBAC least privileges misconfiguration 17. KubeAudit - Audit Kubernetes clusters 18. Falco - Runtime security monitoring & detection 19. Popeye - A Kubernetes cluster sanitizer 20. Secure network boundaries using NSP 21. Cilium Tetragon - eBPF-based Security Observability and Runtime Enforcement 22. Securing Kubernetes Clusters using Kyverno Policy Engine More scenarios releasing soon… ❀ @madhuakula

Slide 30

Slide 30 text

🧰 How can I setup Kubernetes Goat ☸ Vanilla Kubernetes Cluster ☁ AWS Kubernetes (EKS) ☁ GCP Kubernetes (GKE) ☁ Azure Kubernetes (AKS) ☸ Kubernetes IN Docker (KiND) ☸ Lightweight Kubernetes (K3S) ☸ Digital Ocean, Vagrant, Many others… @madhuakula

Slide 31

Slide 31 text

⎈ Setting up in your Kubernetes Cluster ● Make sure you have Kubernetes cluster with cluster-admin privileges. Also kubectl and helm installed in your system before running the following commands to setup the Kubernetes Goat ● Now you can access the Kubernetes Goat by navigating to http://127.0.0.1:1234 @madhuakula

Slide 32

Slide 32 text

⚑ Get Started with Kubernetes Goat 🐐 @madhuakula

Slide 33

Slide 33 text

⚑ Get Started with Kubernetes Goat 🐐 @madhuakula

Slide 34

Slide 34 text

πŸ”Ÿ OWASP Kubernetes Top 10 https://owasp.org/www-project-kubernetes-top-ten/ @madhuakula

Slide 35

Slide 35 text

πŸ›‘ MITRE ATT&CK for Kubernetes Goat https://madhuakula.com/kubernetes-goat/docs/mitre/mitre-attack @madhuakula

Slide 36

Slide 36 text

πŸ₯³ Adoption of Kubernetes Goat https://youtu.be/62_Cj6yseno?t=352 @madhuakula

Slide 37

Slide 37 text

Spread the ❀ #KubernetesGoat πŸ™Œ Give it a try πŸš€ Contribute ideas & suggestions 🀝 Work with the project & improve πŸ™ Share your valuable feedback 🌟 Star in GitHub πŸŽ‰ Spread word #KubernetesGoat @madhuakula

Slide 38

Slide 38 text

Thank you! https://madhuakula.com @madhuakula