SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
Kubernetes Network
Policy Bypass
@mfdii
About me.
Kaizhe Huang
Security Researcher, Sysdig
@kaizhe @kaizhe
Agenda
● CNI
● CNI Plugins
● Kubernetes Network Policy
● Bypass Network Policy
● Mitigation Strategy
CNI
CNI (Container Network Interface), a Cloud Native Computing Foundation project,
consists of:
1. A specification
2. Libraries for writing plugins to configure network interfaces in Linux
containers,
3. Some supported plugins.
CNI
CNI concerns itself only with network connectivity of containers and removing
allocated resources when the container is deleted.
Operation Requirement (container runtime)
● add container to network
● delete container to network
Communication Requirement (k8s cluster network model)
● pods on a node can communicate with all pods on all nodes without NAT
● agents on a node (e.g. system daemons, kubelet) can communicate with all
pods on that node
Note: CNI plugins are one of the flavors of k8s network plugins
CNI Plugins
● Executable binaries
● Implement CNI Spec
○ Create network interfaces for
containers
○ Allocate IP address (by calling
other IPAM plugin like host-local)
● Implement Network Policy (maybe)
Kubernetes Network Policy
A network policy is a specification of how groups of pods are allowed to
communicate with each other and other network endpoints. It is implemented by
the network plugin.
Kubernetes Network Policy
● Namespaced Object - Enforcement applies for pods in the namespace
● Whitelist Policy - Define what network communication is allowed
○ Ingress Rule
○ Egress Rule
Note: There is a deny all (both ingress and egress)
Kubernetes Network Policy
● spec.pod Selector - grouping of pods to
which the policy applies
● spec.ingress
○ ip Block - IP CIDR ranges to allow as
ingress sources
○ namespace Selector - namespaces
for which all Pods should be allowed
as ingress sources
○ podSelector - particular Pods in the
same namespace as the
NetworkPolicy which should be
allowed as ingress sources
● spec.egress - same as spec.ingress except
for egress destination
Kubernetes Network Policy
Example:
● create an ingress rule allow for a specific
service
Enforcement:
Allow connections from Pods with the label
role=client in namespaces with the label
user=alice.
A Basic Example
Namespace: default
Nginx-web
Namespace: good
Good Pod
Label:
From: good
Namespace: bad
Bad Pod
Label:
From: bad
Network Policy Ingress Rules:
1. Namespace label: from:good
2. Pod label: from:good
Bypass Network Policies
Question: assume you have network policies properly configured, can they still
be bypassed?
Patch Network Policy
Namespace: default
Nginx-web
Namespace: good
Good Pod
Label:
From: good
Namespace: bad
Bad Pod
Label:
From: bad
Network Policy Ingress Rules:
1. Namespace label: from:bad
2. Pod label: from:bad
Privilege to patch network
policy (cluster)
Create Pod in Allowed Namespace
Namespace: default
Nginx-web
Namespace: good
Good Pod
Label:
From: good
Namespace: bad
Bad Pod
Label:
From: bad
Network Policy Ingress Rules:
1. Namespace label: from:good
2. Pod label: from:good
bad-pod
Privilege to create pod
(cluster)
Exec into Good Pod
Namespace: default
Nginx-web
Namespace: good
Good Pod
Label:
From: good
Namespace: bad
Bad Pod
Label:
From: bad
Network Policy Ingress Rules:
1. Namespace label: from:good
2. Pod label: from:good
Privilege to exec into
Good pod or Nginx-web
(cluster)
Edit Labels
Namespace: default
Nginx-web
Namespace: good
Good Pod
Label:
From: good
Namespace: good
Bad Pod
Label:
From: good
Network Policy Ingress Rules:
1. Namespace label: from:good
2. Pod label: from:good
Privilege to edit labels
(namespaced)
Via Kubelet
Namespace: default
Nginx-web
Namespace: good
Good Pod
Label:
From: good
Namespace: bad
Bad Pod
Label:
From: bad
Network Policy Ingress Rules:
1. Namespace label: from:good
2. Pod label: from:good
Privilege to create
nodes/proxy (cluster)
kubelet
Via Kubelet
Namespace: default
Nginx-web
Namespace: good
Good Pod
Label:
From: good
Namespace: bad
Bad Pod
Label:
From: bad
Network Policy Ingress Rules:
1. Namespace label: from:good
2. Pod label: from:good
Kubelet
misconfiguration
kubelet
Insecure Host Mount
Namespace: default
Nginx-web
Namespace:
good
Good Pod
Label:
From: good
Namespace: bad
Bad Pod
Label:
From: bad
Network Policy Ingress Rules:
1. Namespace label: from:good
2. Pod label: from:good
Write to static pod path
Write to /etc/kubernetes/manifest
Bad-static-pod
Label:
From: good
Recap
● Risk Types
○ Excessive Privileges Grant
■ Create pod/deployment/[Cron]jobs/statefulset/daemonSet/pods-exec/nodes-proxy
■ Patch networkpolicy/namespace/pod
○ Insecure Host Mount
■ Static pod path
○ Insecure Kubelet Configuration
■ With default authorization (AlwaysAllow)
● Asset Access Path
○ Via network
○ Via kubelet
Mitigation Strategy
● Watch [cluster]rolebinding create/patch events where roles including:
○ Create pod/deployment/[Cron]jobs/statefulset/daemonSet/pods-exec/nodes-proxy
○ Patch networkpolicy/namespace/pod
○ Get secrets
○ Impersonate [privileged subjects]
● Watch pods create event with host mounts including
○ Static pod path
○ /var/lib/kubelet/pods or its parent path
● Enforce CIS benchmark in k8s cluster
Mitigation Tools
● Detection
○ Falco
○ K8s audit webhook
● Prevention
○ OPA
○ Admission Controller
○ PodSecurityPolicy (kube-psp-advisor can help)
● https://github.com/containernetworking/cni
● https://github.com/containernetworking/cni/blob/master/SPEC.md
● Kubernetes Networking
● Network Policies
● Understand Kubernetes Networking
● Container Networking Interface aka CNI
● Introduction to Container Network Interface (CNI)
● Kubernetes Network Plugins
● Benchmark results of Kubernetes network plugins (CNI)
References

Contenu connexe

Tendances

Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...Vietnam Open Infrastructure User Group
 
Kubernetes networking
Kubernetes networkingKubernetes networking
Kubernetes networkingSim Janghoon
 
Scaling Microservices with Kubernetes
Scaling Microservices with KubernetesScaling Microservices with Kubernetes
Scaling Microservices with KubernetesDeivid Hahn Fração
 
K8s beginner 2_advanced_ep02_201904221130_post
K8s beginner 2_advanced_ep02_201904221130_postK8s beginner 2_advanced_ep02_201904221130_post
K8s beginner 2_advanced_ep02_201904221130_postInho Kang
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumScyllaDB
 
Understanding kube proxy in ipvs mode
Understanding kube proxy in ipvs modeUnderstanding kube proxy in ipvs mode
Understanding kube proxy in ipvs modeVictor Morales
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overviewGabriel Carro
 
Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18CodeOps Technologies LLP
 
Replacing iptables with eBPF in Kubernetes with Cilium
Replacing iptables with eBPF in Kubernetes with CiliumReplacing iptables with eBPF in Kubernetes with Cilium
Replacing iptables with eBPF in Kubernetes with CiliumMichal Rostecki
 
Kubernetes networking: Introduction to overlay networks, communication models...
Kubernetes networking: Introduction to overlay networks, communication models...Kubernetes networking: Introduction to overlay networks, communication models...
Kubernetes networking: Introduction to overlay networks, communication models...Murat Mukhtarov
 
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...Jérôme Petazzoni
 
Secure container: Kata container and gVisor
Secure container: Kata container and gVisorSecure container: Kata container and gVisor
Secure container: Kata container and gVisorChing-Hsuan Yen
 
Kubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep DiveKubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep DiveMichal Rostecki
 
Introduction to CNI (Container Network Interface)
Introduction to CNI (Container Network Interface)Introduction to CNI (Container Network Interface)
Introduction to CNI (Container Network Interface)HungWei Chiu
 
Introduction of CCE and DevCloud
Introduction of CCE and DevCloudIntroduction of CCE and DevCloud
Introduction of CCE and DevCloudOpsta
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetesKrishna-Kumar
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introductionSparkbit
 
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2InfraEngineer
 

Tendances (20)

Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
 
Kubernetes networking
Kubernetes networkingKubernetes networking
Kubernetes networking
 
Scaling Microservices with Kubernetes
Scaling Microservices with KubernetesScaling Microservices with Kubernetes
Scaling Microservices with Kubernetes
 
K8s beginner 2_advanced_ep02_201904221130_post
K8s beginner 2_advanced_ep02_201904221130_postK8s beginner 2_advanced_ep02_201904221130_post
K8s beginner 2_advanced_ep02_201904221130_post
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in Cilium
 
Understanding kube proxy in ipvs mode
Understanding kube proxy in ipvs modeUnderstanding kube proxy in ipvs mode
Understanding kube proxy in ipvs mode
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overview
 
Ingress overview
Ingress overviewIngress overview
Ingress overview
 
Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18
 
Replacing iptables with eBPF in Kubernetes with Cilium
Replacing iptables with eBPF in Kubernetes with CiliumReplacing iptables with eBPF in Kubernetes with Cilium
Replacing iptables with eBPF in Kubernetes with Cilium
 
Kubernetes networking: Introduction to overlay networks, communication models...
Kubernetes networking: Introduction to overlay networks, communication models...Kubernetes networking: Introduction to overlay networks, communication models...
Kubernetes networking: Introduction to overlay networks, communication models...
 
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
 
Secure container: Kata container and gVisor
Secure container: Kata container and gVisorSecure container: Kata container and gVisor
Secure container: Kata container and gVisor
 
eBPF maps 101
eBPF maps 101eBPF maps 101
eBPF maps 101
 
Kubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep DiveKubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep Dive
 
Introduction to CNI (Container Network Interface)
Introduction to CNI (Container Network Interface)Introduction to CNI (Container Network Interface)
Introduction to CNI (Container Network Interface)
 
Introduction of CCE and DevCloud
Introduction of CCE and DevCloudIntroduction of CCE and DevCloud
Introduction of CCE and DevCloud
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetes
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introduction
 
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
[MeetUp][2nd] 오리뎅이의_쿠버네티스_네트워킹_v1.2
 

Similaire à K8s network policy bypass

Container network security
Container network securityContainer network security
Container network securityDaisuke Nakajima
 
Kubernetes Security with Calico and Open Policy Agent
Kubernetes Security with Calico and Open Policy AgentKubernetes Security with Calico and Open Policy Agent
Kubernetes Security with Calico and Open Policy AgentCloudOps2005
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive OverviewBob Killen
 
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetesJuraj Hantak
 
Comparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetesComparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetesAdam Hamsik
 
Kubernetes acomprehensiveoverview
Kubernetes acomprehensiveoverviewKubernetes acomprehensiveoverview
Kubernetes acomprehensiveoverviewAnkit Shukla
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewBob Killen
 
Docker Networking - Current Status and goals of Experimental Networking
Docker Networking - Current Status and goals of Experimental NetworkingDocker Networking - Current Status and goals of Experimental Networking
Docker Networking - Current Status and goals of Experimental NetworkingSreenivas Makam
 
Kubernetes from scratch at veepee sysadmins days 2019
Kubernetes from scratch at veepee   sysadmins days 2019Kubernetes from scratch at veepee   sysadmins days 2019
Kubernetes from scratch at veepee sysadmins days 2019🔧 Loïc BLOT
 
Open stackaustinmeetupsept21
Open stackaustinmeetupsept21Open stackaustinmeetupsept21
Open stackaustinmeetupsept21Brent Doncaster
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!DoiT International
 
kubernetesssssssssssssssssssssssssss.pdf
kubernetesssssssssssssssssssssssssss.pdfkubernetesssssssssssssssssssssssssss.pdf
kubernetesssssssssssssssssssssssssss.pdfbchiriamina2
 
Kubernetes Basis: Pods, Deployments, and Services
Kubernetes Basis: Pods, Deployments, and ServicesKubernetes Basis: Pods, Deployments, and Services
Kubernetes Basis: Pods, Deployments, and ServicesJian-Kai Wang
 
Netfilter: Making large iptables rulesets scale
Netfilter: Making large iptables rulesets scaleNetfilter: Making large iptables rulesets scale
Netfilter: Making large iptables rulesets scalebrouer
 
Network Intent Composition in OpenDaylight
Network Intent Composition in OpenDaylightNetwork Intent Composition in OpenDaylight
Network Intent Composition in OpenDaylightOpenDaylight
 
Walls Within Walls: What if your attacker knows parkour?
Walls Within Walls: What if your attacker knows parkour?Walls Within Walls: What if your attacker knows parkour?
Walls Within Walls: What if your attacker knows parkour?Greg Castle
 
Kubermatic How to Migrate 100 Clusters from On-Prem to Google Cloud Without D...
Kubermatic How to Migrate 100 Clusters from On-Prem to Google Cloud Without D...Kubermatic How to Migrate 100 Clusters from On-Prem to Google Cloud Without D...
Kubermatic How to Migrate 100 Clusters from On-Prem to Google Cloud Without D...Tobias Schneck
 

Similaire à K8s network policy bypass (20)

Container network security
Container network securityContainer network security
Container network security
 
Kubernetes Security with Calico and Open Policy Agent
Kubernetes Security with Calico and Open Policy AgentKubernetes Security with Calico and Open Policy Agent
Kubernetes Security with Calico and Open Policy Agent
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview
 
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
 
Intro to firewalls
Intro to firewallsIntro to firewalls
Intro to firewalls
 
Comparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetesComparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetes
 
Kubernetes acomprehensiveoverview
Kubernetes acomprehensiveoverviewKubernetes acomprehensiveoverview
Kubernetes acomprehensiveoverview
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive Overview
 
Docker Networking - Current Status and goals of Experimental Networking
Docker Networking - Current Status and goals of Experimental NetworkingDocker Networking - Current Status and goals of Experimental Networking
Docker Networking - Current Status and goals of Experimental Networking
 
Kubernetes from scratch at veepee sysadmins days 2019
Kubernetes from scratch at veepee   sysadmins days 2019Kubernetes from scratch at veepee   sysadmins days 2019
Kubernetes from scratch at veepee sysadmins days 2019
 
Demystfying container-networking
Demystfying container-networkingDemystfying container-networking
Demystfying container-networking
 
Open stackaustinmeetupsept21
Open stackaustinmeetupsept21Open stackaustinmeetupsept21
Open stackaustinmeetupsept21
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!
 
kubernetesssssssssssssssssssssssssss.pdf
kubernetesssssssssssssssssssssssssss.pdfkubernetesssssssssssssssssssssssssss.pdf
kubernetesssssssssssssssssssssssssss.pdf
 
Kubernetes PPT.pptx
Kubernetes PPT.pptxKubernetes PPT.pptx
Kubernetes PPT.pptx
 
Kubernetes Basis: Pods, Deployments, and Services
Kubernetes Basis: Pods, Deployments, and ServicesKubernetes Basis: Pods, Deployments, and Services
Kubernetes Basis: Pods, Deployments, and Services
 
Netfilter: Making large iptables rulesets scale
Netfilter: Making large iptables rulesets scaleNetfilter: Making large iptables rulesets scale
Netfilter: Making large iptables rulesets scale
 
Network Intent Composition in OpenDaylight
Network Intent Composition in OpenDaylightNetwork Intent Composition in OpenDaylight
Network Intent Composition in OpenDaylight
 
Walls Within Walls: What if your attacker knows parkour?
Walls Within Walls: What if your attacker knows parkour?Walls Within Walls: What if your attacker knows parkour?
Walls Within Walls: What if your attacker knows parkour?
 
Kubermatic How to Migrate 100 Clusters from On-Prem to Google Cloud Without D...
Kubermatic How to Migrate 100 Clusters from On-Prem to Google Cloud Without D...Kubermatic How to Migrate 100 Clusters from On-Prem to Google Cloud Without D...
Kubermatic How to Migrate 100 Clusters from On-Prem to Google Cloud Without D...
 

Dernier

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Dernier (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

K8s network policy bypass

  • 2. @mfdii About me. Kaizhe Huang Security Researcher, Sysdig @kaizhe @kaizhe
  • 3. Agenda ● CNI ● CNI Plugins ● Kubernetes Network Policy ● Bypass Network Policy ● Mitigation Strategy
  • 4. CNI CNI (Container Network Interface), a Cloud Native Computing Foundation project, consists of: 1. A specification 2. Libraries for writing plugins to configure network interfaces in Linux containers, 3. Some supported plugins.
  • 5. CNI CNI concerns itself only with network connectivity of containers and removing allocated resources when the container is deleted. Operation Requirement (container runtime) ● add container to network ● delete container to network Communication Requirement (k8s cluster network model) ● pods on a node can communicate with all pods on all nodes without NAT ● agents on a node (e.g. system daemons, kubelet) can communicate with all pods on that node Note: CNI plugins are one of the flavors of k8s network plugins
  • 6. CNI Plugins ● Executable binaries ● Implement CNI Spec ○ Create network interfaces for containers ○ Allocate IP address (by calling other IPAM plugin like host-local) ● Implement Network Policy (maybe)
  • 7. Kubernetes Network Policy A network policy is a specification of how groups of pods are allowed to communicate with each other and other network endpoints. It is implemented by the network plugin.
  • 8. Kubernetes Network Policy ● Namespaced Object - Enforcement applies for pods in the namespace ● Whitelist Policy - Define what network communication is allowed ○ Ingress Rule ○ Egress Rule Note: There is a deny all (both ingress and egress)
  • 9. Kubernetes Network Policy ● spec.pod Selector - grouping of pods to which the policy applies ● spec.ingress ○ ip Block - IP CIDR ranges to allow as ingress sources ○ namespace Selector - namespaces for which all Pods should be allowed as ingress sources ○ podSelector - particular Pods in the same namespace as the NetworkPolicy which should be allowed as ingress sources ● spec.egress - same as spec.ingress except for egress destination
  • 10. Kubernetes Network Policy Example: ● create an ingress rule allow for a specific service Enforcement: Allow connections from Pods with the label role=client in namespaces with the label user=alice.
  • 11. A Basic Example Namespace: default Nginx-web Namespace: good Good Pod Label: From: good Namespace: bad Bad Pod Label: From: bad Network Policy Ingress Rules: 1. Namespace label: from:good 2. Pod label: from:good
  • 12. Bypass Network Policies Question: assume you have network policies properly configured, can they still be bypassed?
  • 13. Patch Network Policy Namespace: default Nginx-web Namespace: good Good Pod Label: From: good Namespace: bad Bad Pod Label: From: bad Network Policy Ingress Rules: 1. Namespace label: from:bad 2. Pod label: from:bad Privilege to patch network policy (cluster)
  • 14. Create Pod in Allowed Namespace Namespace: default Nginx-web Namespace: good Good Pod Label: From: good Namespace: bad Bad Pod Label: From: bad Network Policy Ingress Rules: 1. Namespace label: from:good 2. Pod label: from:good bad-pod Privilege to create pod (cluster)
  • 15. Exec into Good Pod Namespace: default Nginx-web Namespace: good Good Pod Label: From: good Namespace: bad Bad Pod Label: From: bad Network Policy Ingress Rules: 1. Namespace label: from:good 2. Pod label: from:good Privilege to exec into Good pod or Nginx-web (cluster)
  • 16. Edit Labels Namespace: default Nginx-web Namespace: good Good Pod Label: From: good Namespace: good Bad Pod Label: From: good Network Policy Ingress Rules: 1. Namespace label: from:good 2. Pod label: from:good Privilege to edit labels (namespaced)
  • 17. Via Kubelet Namespace: default Nginx-web Namespace: good Good Pod Label: From: good Namespace: bad Bad Pod Label: From: bad Network Policy Ingress Rules: 1. Namespace label: from:good 2. Pod label: from:good Privilege to create nodes/proxy (cluster) kubelet
  • 18. Via Kubelet Namespace: default Nginx-web Namespace: good Good Pod Label: From: good Namespace: bad Bad Pod Label: From: bad Network Policy Ingress Rules: 1. Namespace label: from:good 2. Pod label: from:good Kubelet misconfiguration kubelet
  • 19. Insecure Host Mount Namespace: default Nginx-web Namespace: good Good Pod Label: From: good Namespace: bad Bad Pod Label: From: bad Network Policy Ingress Rules: 1. Namespace label: from:good 2. Pod label: from:good Write to static pod path Write to /etc/kubernetes/manifest Bad-static-pod Label: From: good
  • 20. Recap ● Risk Types ○ Excessive Privileges Grant ■ Create pod/deployment/[Cron]jobs/statefulset/daemonSet/pods-exec/nodes-proxy ■ Patch networkpolicy/namespace/pod ○ Insecure Host Mount ■ Static pod path ○ Insecure Kubelet Configuration ■ With default authorization (AlwaysAllow) ● Asset Access Path ○ Via network ○ Via kubelet
  • 21. Mitigation Strategy ● Watch [cluster]rolebinding create/patch events where roles including: ○ Create pod/deployment/[Cron]jobs/statefulset/daemonSet/pods-exec/nodes-proxy ○ Patch networkpolicy/namespace/pod ○ Get secrets ○ Impersonate [privileged subjects] ● Watch pods create event with host mounts including ○ Static pod path ○ /var/lib/kubelet/pods or its parent path ● Enforce CIS benchmark in k8s cluster
  • 22. Mitigation Tools ● Detection ○ Falco ○ K8s audit webhook ● Prevention ○ OPA ○ Admission Controller ○ PodSecurityPolicy (kube-psp-advisor can help)
  • 23. ● https://github.com/containernetworking/cni ● https://github.com/containernetworking/cni/blob/master/SPEC.md ● Kubernetes Networking ● Network Policies ● Understand Kubernetes Networking ● Container Networking Interface aka CNI ● Introduction to Container Network Interface (CNI) ● Kubernetes Network Plugins ● Benchmark results of Kubernetes network plugins (CNI) References