SlideShare a Scribd company logo
Hijack a Kubernetes Cluster – a Walkthrough
ContainerDays 2022
Nico Meisenzahl
• Head of DevOps Consulting & Operations
at white duck
• Microsoft MVP, GitLab Hero
• Cloud Native, Kubernetes & Azure
© white duck GmbH 2022
Email: nico.meisenzahl@whiteduck.de
Twitter: @nmeisenzahl
LinkedIn: https://www.linkedin.com/in/nicomeisenzahl
Blog: https://meisenzahl.org
About this talk
• this is not an in-depth security talk
• it should make you aware of common attack vectors and
how to prevent them
• you will see demos on how to hijack a cluster
• you will learn how to prevent those with common best practices
• three more slide, then we will start hijacking
• https://github.com/nmeisenzahl/hijack-kubernetes
© white duck GmbH 2022
Why do we need to care about security?
https://www.redhat.com/en/resources/state-kubernetes-security-report
What we will do
© white duck GmbH 2022
Log4Shell
https://www.splunk.com/en_us/surge/log4shell-log4j-response-overview.html
Security quick wins through the DevOps cycle
© white duck GmbH 2022
Ensure secure application code
• automate and enforce code checks
• schedule dependency scanning
• e.g. Dependabot
• enforce Static Application Security Testing (SAST) in PRs
• scans your code to identify potential security vulnerabilities
• more details: https://owasp.org/www-
community/Source_Code_Analysis_Tools
© white duck GmbH 2022
Build secure container images
• build secure/small container images – less is more
• do only include required dependencies (no debugging tools!)
• use self-contained binaries or “distroless” if possible
• https://github.com/GoogleContainerTools/distroless
• otherwise, use a small and secure Linux distro
• use and enforce SAST for validating your Dockerfiles
• scan your container images (on build and regularly)
© white duck GmbH 2022
Build secure container images
• build secure/small container images – less is more
• do only include required dependencies (no debugging tools!)
• use self-contained binaries or “distroless” if possible
• https://github.com/GoogleContainerTools/distroless
• otherwise, use a small and secure Linux distro
• use and enforce SAST for validating your Dockerfiles
• scan your container images (on build and regularly)
© white duck GmbH 2022
Would have made it
much harder to
hijack the container
and further expend
Would have shown
the possibility of code
injection
Ensure secure deployment code
• as important as secure application code and Dockerfiles
• validate your deployment manifests using SAST
• and enforce them via PRs
• can help you to implement best practices like denying
• containers running as root
• mounting hostPath
• …
© white duck GmbH 2022
Ensure secure deployment code
• as important as secure application code and Dockerfiles
• validate your deployment manifests using SAST
• and enforce them via PRs
• can help you to implement best practices like denying
• containers running as root
• mounting hostPath
• …
© white duck GmbH 2022
Would have made it
much harder to hijack
the node
SAST Tooling
• Source code
• https://codeql.github.com
• https://security-code-scan.github.io
• https://securego.io
• Kubernetes manifests
• https://kubesec.io
• https://github.com/aquasecurity/trivy
• https://github.com/bridgecrewio/checkov
• Dockerfiles
• https://github.com/aquasecurity/trivy
• https://github.com/bridgecrewio/checkov
• Terraform
• https://github.com/tfsec/tfsec
• https://github.com/aquasecurity/trivy
• https://github.com/bridgecrewio/checkov
© white duck GmbH 2022
Kubernetes policies
• enforce compliance and governance within clusters
• verifying manifests is not enough!
• examples include enforcement of
• read-only filesystems
• denying hostPath mounts
• denying containers running as root
• …
© white duck GmbH 2022
Kubernetes policies
• enforce compliance and governance within clusters
• verifying manifests is not enough!
• examples include enforcement of
• read-only filesystems
• denying hostPath mounts
• denying containers running as root
• …
© white duck GmbH 2022
Would have made it
much harder to
further hijack the
nodes and cloud
resources
Kubernetes policy tooling
• Pod Security Admission
• stable since 1.25
• https://kubernetes.io/docs/concepts/security/pod-security-
admission
• Open Policy Agent Gatekeeper
• https://github.com/open-policy-agent/gatekeeper
• Kyverno
• https://kyverno.io
© white duck GmbH 2022
Network Policies
• granular deny or explicitly allow between containers and
ingress/egress of the cluster
• limit egress access to the internet
• limit access between applications/namespaces
• deny access to the Cloud provider metadata service
• https://kubernetes.io/docs/concepts/services-
networking/network-policies
© white duck GmbH 2022
Network Policies
• granular deny or explicitly allow between containers and
ingress/egress of the cluster
• limit egress access to the internet
• limit access between applications/namespaces
• deny access to the Cloud provider metadata service
• https://kubernetes.io/docs/concepts/services-
networking/network-policies
© white duck GmbH 2022
Would have denied
network connections
(reverse shell, Redis,
Internet, metadata
service)
Container Runtime Security
• helps to detect malicious threads and workloads
• untrusted process within container
• a shell is running inside a container
• container process mounting a sensitive path
• a process making outbound network connections
• container runtime security tools like Falco of Tetragon can
help
© white duck GmbH 2022
Container Runtime Security
• helps to detect malicious threads and workloads
• untrusted process within container
• a shell is running inside a container
• container process mounting a sensitive path
• a process making outbound network connections
• container runtime security tools like Falco of Tetragon can
help
© white duck GmbH 2022
Container Runtime Security
• helps to detect malicious threads and workloads
• untrusted process within container
• a shell is running inside a container
• container process mounting a sensitive path
• a process making outbound network connections
• container runtime security tools like Falco of Tetragon can
help
© white duck GmbH 2022
Would have detect all
our “work” within the
containers
Further best practises
• do not
• share service accounts between applications
• enable higher access levels for the default service account if not
required
• mount service account token if not required
• https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-
account/#use-the-default-service-account-to-access-the-api-server
• changed with 1.24
• review all third-party snippets before applying them
• implement a Web Application Firewall (WAF) to further secure
your application
© white duck GmbH 2022
Further best practises
• do not
• share service accounts between applications
• enable higher access levels for the default service account if not
required
• mount service account token if not required
• https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-
account/#use-the-default-service-account-to-access-the-api-server
• changed with 1.24
• review all third-party snippets before applying them
• implement a Web Application Firewall (WAF) to further secure
your application
© white duck GmbH 2022
Wouldn’t have
allowed us to talk to
the API server
Would have denied
our code injection
ContainerDays 2022 Post-Conference Meetup
• https://www.meetup.com/hamburg-kubernetes-meetup/events/287713443
© white duck GmbH 2022
Questions?
• Slides: https://www.slideshare.net/nmeisenzahl
• Demo: https://github.com/nmeisenzahl/hijack-kubernetes
© white duck GmbH 2022
Email: nico.meisenzahl@whiteduck.de
Twitter: @nmeisenzahl
LinkedIn: https://www.linkedin.com/in/nicomeisenzahl
Blog: https://meisenzahl.org

More Related Content

PPTX
Hijack a Kubernetes Cluster - a Walkthrough
PDF
Hijack a Kubernetes Cluster - a Walkthrough
PDF
ContainerConf 2022: Hijack Kubernetes
PDF
How to Prevent Your Kubernetes Cluster From Being Hacked
PDF
KCD Munich 2022: How to Prevent Your Kubernetes Cluster From Being Hacked
PDF
KCD Munich 2022: Hijack a Kubernetes Cluster - a Walkthrough
PDF
Microsoft DevOps Forum 2021 – DevOps & Security
PPTX
Kubernetes and container security
Hijack a Kubernetes Cluster - a Walkthrough
Hijack a Kubernetes Cluster - a Walkthrough
ContainerConf 2022: Hijack Kubernetes
How to Prevent Your Kubernetes Cluster From Being Hacked
KCD Munich 2022: How to Prevent Your Kubernetes Cluster From Being Hacked
KCD Munich 2022: Hijack a Kubernetes Cluster - a Walkthrough
Microsoft DevOps Forum 2021 – DevOps & Security
Kubernetes and container security

Similar to Container Days: Hijack a Kubernetes Cluster - a Walkthrough (20)

PDF
ContainerConf 2022: Kubernetes is awesome - but...
PDF
Cloud Love Conference: Kubernetes is awesome, but...
PDF
Container Day Security: How to Prevent Your Kubernetes Cluster From Being Hacked
PDF
GitLab Remote Meetup: Enhance Your Kubernetes CI/CD Pipelines with GitLab & O...
PDF
GitLab Remote Meetup: Enhance Your Kubernetes CI/CD Pipelines with GitLab & ...
PDF
How to Prevent Your Kubernetes Cluster From Being Hacked by Nico Meisenzahl
PDF
How to Prevent Your Kubernetes Cluster From Being Hacked by Nico Meisenzahl
PDF
Secure Your Code Implement DevSecOps in Azure
PDF
Effiziente CI/CD-Pipelines – mit den richtigen Tools klappt das
PDF
DevOpsCon London: How containerized Pipelines can boost your CI/CD
PDF
GitLab London Meetup: How Containerized Pipelines and Kubernetes Can Boost Yo...
PDF
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
PPTX
FestiveTechCalendar2021 - Have Yourself An​ Azure Container Registry
PPTX
Kubernetes Security
PDF
Mitigate potential compliance risks
PPTX
Aleksei Dremin - Application Security Pipeline - phdays9
PPTX
10 tips for Cloud Native Security
PPTX
Secure your web app presentation
PDF
Docker Rosenheim Meetup: Policy & Governance for Kubernetes
PPTX
Tips and best practices for Docker
ContainerConf 2022: Kubernetes is awesome - but...
Cloud Love Conference: Kubernetes is awesome, but...
Container Day Security: How to Prevent Your Kubernetes Cluster From Being Hacked
GitLab Remote Meetup: Enhance Your Kubernetes CI/CD Pipelines with GitLab & O...
GitLab Remote Meetup: Enhance Your Kubernetes CI/CD Pipelines with GitLab & ...
How to Prevent Your Kubernetes Cluster From Being Hacked by Nico Meisenzahl
How to Prevent Your Kubernetes Cluster From Being Hacked by Nico Meisenzahl
Secure Your Code Implement DevSecOps in Azure
Effiziente CI/CD-Pipelines – mit den richtigen Tools klappt das
DevOpsCon London: How containerized Pipelines can boost your CI/CD
GitLab London Meetup: How Containerized Pipelines and Kubernetes Can Boost Yo...
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
FestiveTechCalendar2021 - Have Yourself An​ Azure Container Registry
Kubernetes Security
Mitigate potential compliance risks
Aleksei Dremin - Application Security Pipeline - phdays9
10 tips for Cloud Native Security
Secure your web app presentation
Docker Rosenheim Meetup: Policy & Governance for Kubernetes
Tips and best practices for Docker
Ad

More from Nico Meisenzahl (18)

PDF
Cloud-Native & Sustainability: How and Why to Build Sustainable Workloads
PDF
Festive Tech Calendar: Festive time with AKS networking
PDF
Azure Zürich User Group: Azure Kubernetes Service – more than just a managed ...
PDF
azdevcom - Hijack a Kubernetes Cluster
PDF
Continuous Lifecycle: Enhance Your Compliance and Governance With Policy-Base...
PDF
Continuous Lifecycle: Hijack Kubernetes
PDF
Hijack a Kubernetes Cluster - a Walkthrough
PDF
GitLab Commit: Enhance your Compliance with Policy-Based CI/CD
PDF
Azure Meetup Hamburg: Production-Ready Terraform Deployments on Azure
PDF
DevOpsCon Berlin: Helm vs Operators – Do I Need to Decide?
PDF
GitLab Commit DevOps: How GitLab Can Save your Kubernetes environment from Be...
PDF
GitHub Actions 101
PDF
Azure Rosenheim Meetup: Azure Service Operator
PDF
Azure Saturday Hamburg: Containerize Your .NET Microservice - the Right Way!
PDF
Cloud Native Day: Cloud-native Anwendungsentwicklung im Jahr 2021
PDF
Die Evolution von Container Image Builds
PDF
Azure Service Operator - Provision Your Resources in a Cloud-Native Way
PDF
GitLab Commit: Your Attackers Won't Be Happy! How GitLab Can Help You Secure ...
Cloud-Native & Sustainability: How and Why to Build Sustainable Workloads
Festive Tech Calendar: Festive time with AKS networking
Azure Zürich User Group: Azure Kubernetes Service – more than just a managed ...
azdevcom - Hijack a Kubernetes Cluster
Continuous Lifecycle: Enhance Your Compliance and Governance With Policy-Base...
Continuous Lifecycle: Hijack Kubernetes
Hijack a Kubernetes Cluster - a Walkthrough
GitLab Commit: Enhance your Compliance with Policy-Based CI/CD
Azure Meetup Hamburg: Production-Ready Terraform Deployments on Azure
DevOpsCon Berlin: Helm vs Operators – Do I Need to Decide?
GitLab Commit DevOps: How GitLab Can Save your Kubernetes environment from Be...
GitHub Actions 101
Azure Rosenheim Meetup: Azure Service Operator
Azure Saturday Hamburg: Containerize Your .NET Microservice - the Right Way!
Cloud Native Day: Cloud-native Anwendungsentwicklung im Jahr 2021
Die Evolution von Container Image Builds
Azure Service Operator - Provision Your Resources in a Cloud-Native Way
GitLab Commit: Your Attackers Won't Be Happy! How GitLab Can Help You Secure ...
Ad

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PPTX
Cloud computing and distributed systems.
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Modernizing your data center with Dell and AMD
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Review of recent advances in non-invasive hemoglobin estimation
Advanced methodologies resolving dimensionality complications for autism neur...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
The Rise and Fall of 3GPP – Time for a Sabbatical?
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
Cloud computing and distributed systems.
NewMind AI Monthly Chronicles - July 2025
Modernizing your data center with Dell and AMD
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity

Container Days: Hijack a Kubernetes Cluster - a Walkthrough

  • 1. Hijack a Kubernetes Cluster – a Walkthrough ContainerDays 2022
  • 2. Nico Meisenzahl • Head of DevOps Consulting & Operations at white duck • Microsoft MVP, GitLab Hero • Cloud Native, Kubernetes & Azure © white duck GmbH 2022 Email: nico.meisenzahl@whiteduck.de Twitter: @nmeisenzahl LinkedIn: https://www.linkedin.com/in/nicomeisenzahl Blog: https://meisenzahl.org
  • 3. About this talk • this is not an in-depth security talk • it should make you aware of common attack vectors and how to prevent them • you will see demos on how to hijack a cluster • you will learn how to prevent those with common best practices • three more slide, then we will start hijacking • https://github.com/nmeisenzahl/hijack-kubernetes © white duck GmbH 2022
  • 4. Why do we need to care about security? https://www.redhat.com/en/resources/state-kubernetes-security-report
  • 5. What we will do © white duck GmbH 2022
  • 7. Security quick wins through the DevOps cycle © white duck GmbH 2022
  • 8. Ensure secure application code • automate and enforce code checks • schedule dependency scanning • e.g. Dependabot • enforce Static Application Security Testing (SAST) in PRs • scans your code to identify potential security vulnerabilities • more details: https://owasp.org/www- community/Source_Code_Analysis_Tools © white duck GmbH 2022
  • 9. Build secure container images • build secure/small container images – less is more • do only include required dependencies (no debugging tools!) • use self-contained binaries or “distroless” if possible • https://github.com/GoogleContainerTools/distroless • otherwise, use a small and secure Linux distro • use and enforce SAST for validating your Dockerfiles • scan your container images (on build and regularly) © white duck GmbH 2022
  • 10. Build secure container images • build secure/small container images – less is more • do only include required dependencies (no debugging tools!) • use self-contained binaries or “distroless” if possible • https://github.com/GoogleContainerTools/distroless • otherwise, use a small and secure Linux distro • use and enforce SAST for validating your Dockerfiles • scan your container images (on build and regularly) © white duck GmbH 2022 Would have made it much harder to hijack the container and further expend Would have shown the possibility of code injection
  • 11. Ensure secure deployment code • as important as secure application code and Dockerfiles • validate your deployment manifests using SAST • and enforce them via PRs • can help you to implement best practices like denying • containers running as root • mounting hostPath • … © white duck GmbH 2022
  • 12. Ensure secure deployment code • as important as secure application code and Dockerfiles • validate your deployment manifests using SAST • and enforce them via PRs • can help you to implement best practices like denying • containers running as root • mounting hostPath • … © white duck GmbH 2022 Would have made it much harder to hijack the node
  • 13. SAST Tooling • Source code • https://codeql.github.com • https://security-code-scan.github.io • https://securego.io • Kubernetes manifests • https://kubesec.io • https://github.com/aquasecurity/trivy • https://github.com/bridgecrewio/checkov • Dockerfiles • https://github.com/aquasecurity/trivy • https://github.com/bridgecrewio/checkov • Terraform • https://github.com/tfsec/tfsec • https://github.com/aquasecurity/trivy • https://github.com/bridgecrewio/checkov © white duck GmbH 2022
  • 14. Kubernetes policies • enforce compliance and governance within clusters • verifying manifests is not enough! • examples include enforcement of • read-only filesystems • denying hostPath mounts • denying containers running as root • … © white duck GmbH 2022
  • 15. Kubernetes policies • enforce compliance and governance within clusters • verifying manifests is not enough! • examples include enforcement of • read-only filesystems • denying hostPath mounts • denying containers running as root • … © white duck GmbH 2022 Would have made it much harder to further hijack the nodes and cloud resources
  • 16. Kubernetes policy tooling • Pod Security Admission • stable since 1.25 • https://kubernetes.io/docs/concepts/security/pod-security- admission • Open Policy Agent Gatekeeper • https://github.com/open-policy-agent/gatekeeper • Kyverno • https://kyverno.io © white duck GmbH 2022
  • 17. Network Policies • granular deny or explicitly allow between containers and ingress/egress of the cluster • limit egress access to the internet • limit access between applications/namespaces • deny access to the Cloud provider metadata service • https://kubernetes.io/docs/concepts/services- networking/network-policies © white duck GmbH 2022
  • 18. Network Policies • granular deny or explicitly allow between containers and ingress/egress of the cluster • limit egress access to the internet • limit access between applications/namespaces • deny access to the Cloud provider metadata service • https://kubernetes.io/docs/concepts/services- networking/network-policies © white duck GmbH 2022 Would have denied network connections (reverse shell, Redis, Internet, metadata service)
  • 19. Container Runtime Security • helps to detect malicious threads and workloads • untrusted process within container • a shell is running inside a container • container process mounting a sensitive path • a process making outbound network connections • container runtime security tools like Falco of Tetragon can help © white duck GmbH 2022
  • 20. Container Runtime Security • helps to detect malicious threads and workloads • untrusted process within container • a shell is running inside a container • container process mounting a sensitive path • a process making outbound network connections • container runtime security tools like Falco of Tetragon can help © white duck GmbH 2022
  • 21. Container Runtime Security • helps to detect malicious threads and workloads • untrusted process within container • a shell is running inside a container • container process mounting a sensitive path • a process making outbound network connections • container runtime security tools like Falco of Tetragon can help © white duck GmbH 2022 Would have detect all our “work” within the containers
  • 22. Further best practises • do not • share service accounts between applications • enable higher access levels for the default service account if not required • mount service account token if not required • https://kubernetes.io/docs/tasks/configure-pod-container/configure-service- account/#use-the-default-service-account-to-access-the-api-server • changed with 1.24 • review all third-party snippets before applying them • implement a Web Application Firewall (WAF) to further secure your application © white duck GmbH 2022
  • 23. Further best practises • do not • share service accounts between applications • enable higher access levels for the default service account if not required • mount service account token if not required • https://kubernetes.io/docs/tasks/configure-pod-container/configure-service- account/#use-the-default-service-account-to-access-the-api-server • changed with 1.24 • review all third-party snippets before applying them • implement a Web Application Firewall (WAF) to further secure your application © white duck GmbH 2022 Wouldn’t have allowed us to talk to the API server Would have denied our code injection
  • 24. ContainerDays 2022 Post-Conference Meetup • https://www.meetup.com/hamburg-kubernetes-meetup/events/287713443 © white duck GmbH 2022
  • 25. Questions? • Slides: https://www.slideshare.net/nmeisenzahl • Demo: https://github.com/nmeisenzahl/hijack-kubernetes © white duck GmbH 2022 Email: nico.meisenzahl@whiteduck.de Twitter: @nmeisenzahl LinkedIn: https://www.linkedin.com/in/nicomeisenzahl Blog: https://meisenzahl.org