SlideShare une entreprise Scribd logo
1  sur  40
K8S security – Best practices
By: Sharon Vendrov
0
500
1000
1500
2000
2500
Mac Os X Windows 7 Windows XP Windows 8.1 Windows 10
CVE Sum
CVE Sum
2
Total Number Of Vulnerabilities in 2017 – Source:
CVEdetails.com
3
4
Sharon Vendrov
Sr. DevOps Engineer
About Me
5
Storm-runner functional
 Infrastructure protection
 K8s internal security
 Authentication & Authorization options
 Network
 Secrets
 Container runtime Security
 Some other security tools and considerations
6
Agenda
Infrastructure protection
7
 Limit SSH access to your cluster
 Use hardened images for your cluster ( )
 Encrypt your storage volume
 Avoid from exposing your cluster to the internet
 Limit the access to the K8s API (consider to use bastion machine)
 Create dedicated cluster for each environment (Prod, Stg, Dev)
 Separate sensitive pods into different nodes
Kubernetes internal security
8
 Use minimal base docker image
 Don’t use arbitrary base images
 Separate sensitive workloads across instances (using anti-affinity,
taints and tolerations)
 Use namespaces for isolation
 Enforce resource quota (CPU, Memory, Storage)
Image Name node:latest ubuntu:latest alpine:latest scratch
Image Size 670MB~ 110MB~ 4.1MB~ 0
Secure kubelet
9
 curl -sk https://<nodeIP>:10250/run/<namespace>/<pod-name>/<container-name> -d
"cmd=ls -la /“
 Protect kubelet by enable authentication and authorization:
start the apiserver with --kubelet-client-certificate and --kubelet-client-key flags
/usr/local/bin/kubelet
--anonymous-auth=false
--authorization-mode=Webhook
--allow-privileged=true
--kubeconfig=/var/lib/kubelet/kubeconfig
--client-ca-file=/var/lib/kubernetes/ca.pem
• Enable kubelet certification rotation (1.8 beta)
Authentication & Authorization
11
12
Authentication
13
 Static password/token file
 Client certificates x509
 Proxy + headers
 OpenID Connect
 Custom (Web hook)
password,user,uid,”group1,group2,group3”
Authentication
14
 Service accounts
 Default service account have full permissions over the cluster, use custom SA instead
 Set “automountServiceAccountToken : false” in your pod spec – when possible
Authorization
15
 ABAC
 Difficult to manage and understand
 Requires ssh and root filesystem access on the master
 For permission changes to take effect the cluster API server must be restarted
{"apiVersion": "abac.authorization.kubernetes.io/v1beta1",
"kind": "Policy",
"spec": {
"user": "bob",
"namespace": "projectSpaceX",
"resource": "pods",
"readonly": true
}
}
Authorization
16
 RBAC (stable 1.8)
Service Account
User
Role binding Role
17
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: read-pods
namespace: default
subjects:
- kind: User
name: Bob
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: default
name: pod-reader
rules:
- apiGroups: [""]
group
resources: ["pods"]
verbs: ["get", "watch", "list"]
Authorization
18
 Custom (Web hook)
 Node
Restrict kubelet to perform R/W operation only to his bound pods
--authorization-mode=Node,RBAC
--admission-control=NodeRestriction
Network
20
Netwok
21
 Limit the access to cloud provider metadata
(http://169.254.169.254/latest/meta-data/)
22
$ curl -s 169.254.169.254/latest/meta-data/iam/security-
credentials/kubernetes-worker-iam-policy
{
"Code" : "Success",
"LastUpdated" : "2017-12-25T00:00:00Z",
"Type" : "AWS-HMAC",
"AccessKeyId" : "MyAccessKeyID",
"SecretAccessKey" : "MySecretAccessKey",
"Token" : "MySessionToken",
"Expiration" : "2017-12-25T04:00:00Z"
} @bradgeesaman
23
# Place credentials in ENV vars
$ export AWS_REGION=us-east-1
$ export AWS_ACCESS_KEY_ID=MyAccessKeyID
$ export AWS_SECRET_ACCESS_KEY=MySecretAccessKey
$ export AWS_SESSION_TOKEN=MySessionToken
$ aws ec2 … @bradgeesaman
The solution
24
• For AWS use kube2iam or kiam (using docker proxy for requests to the
metadata)
• For GCE use k8s-metadata-proxy
• Limit egress with network policy
25
 Use network policy (GA from 1.7) https://goo.gl/HRtn5B
 Egress rules are beta from 1.8
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: access-nginx
spec:
podSelector:
matchLabels:
run: nginx
ingress:
- from:
- podSelector:
matchLabels:
access: "true"
• Istio
Network policy guidelines
26
 Label your workloads properly
 Isolate workloads from each other
 Restrict income traffic to the kube-system (except kube-dns)
 Consider limit egress to the internet
“The definition of Secret—
something you tell everybody to
tell nobody.”
– The universe
Treat your secrets with respect
28
 Don’t store your secrets on Git, it will remain in history even If you
delete it.
 Create dedicated secrets for dev and prod environments
 Secrets are stored at etcd as base64 (almost like plain text) 
encrypt your secrets (K8S encryption –alpha 1.7)
 Use Vault as you secret management (starting from Vault 0.8.3)
Security Context
A security context defines privilege and access control settings for a Pod or Container
29
 Discretionary Access Control: Permission to access an object, like a file, is
based on user ID (UID) and group ID (GID).
 Security Enhanced Linux (SELinux): Objects are assigned security labels.
 Running as privileged or unprivileged.
 Linux Capabilities: Give a process some privileges, but not all the privileges
of the root user.
 AppArmor: Use program profiles to restrict the capabilities of individual
programs.
 Seccomp: Limit a process’s access to open file descriptors.
 AllowPrivilegeEscalation: Controls whether a process can gain more
privileges than its parent process.
Example: RunasNonRoot
30
apiVersion: v1
kind: Pod
metadata:
name: security-context-demo
spec:
containers:
- name: sec-ctx-demo
image: gcr.io/google-samples/node-hello:1.0
securityContext:
runAsNonRoot : true
31
Example: readOnlyRootFilesystem
32
apiVersion: v1
kind: Pod
metadata:
name: security-context-demo
spec:
containers:
- name: sec-ctx-demo
image: gcr.io/google-samples/node-hello:1.0
securityContext:
runAsNonRoot : false
readOnlyRootFilesystem : true
33
34
Other security tools and considerations
35
 Scan your docker images for vulnerabilities, (Clair CoreOS /Quay.io,
Docker Security Scanning, aqua, Twistlock).
 Use kube-bench (aqua security) or kubernetes-auto-analyzer
(nccgroup) to execute CIS Kubernetes Benchmark
 Enforce cluster wide security policy w/podSecurityPolicy
 Use only trusted private docker registry
 Always tag your images avoid from using “latest”
 Audit events and store them on external storage (beta 1.8)
 Consider using kubeaudit to audit security issue
36
Other security considerations
37
 Specify an image with its digest (SHA256)
 Keep up with K8S stable releases
 Implement monitoring and set alerts
 Don’t run “kubectl create –f <some unknown URL to some unknown
yamls>
 Keep updated with new security vulnerabilities from the google
group “kubernetes-announces”
https://groups.google.com/forum/#!forum/kubernetes-announce
38
Thanks and credit
39
 My Wife 
 All K8s contributors
 Hacking and Hardening Kubernetes Clusters by Example [I] - Brad Geesaman -
https://goo.gl/komeXN
 Running containers securely with Google Container Engine, Alex Mohr and
Jessica Frazelle - https://goo.gl/AFhTyp
 Shipping in Pirate-Infested Waters: Practical Attack and Defense in Kubernetes
[A] - Greg Castle - https://goo.gl/WFDrrv
 Compliance and Identity Management in Kubernetes [I] Marc Boorshtein -
https://goo.gl/Jf7Rkh
 Securing K8s Microservices with Calico Network Policies, Vadim Solvey -
https://goo.gl/rWGGXM
Thank You.

Contenu connexe

Tendances

An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to KubernetesImesh Gunaratne
 
Introduction to Kubernetes RBAC
Introduction to Kubernetes RBACIntroduction to Kubernetes RBAC
Introduction to Kubernetes RBACKublr
 
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...Brian Grant
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionStefan Schimanski
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopBob Killen
 
Container security
Container securityContainer security
Container securityAnthony Chow
 
Kubernetes + Python = ❤ - Cloud Native Prague
Kubernetes + Python = ❤ - Cloud Native PragueKubernetes + Python = ❤ - Cloud Native Prague
Kubernetes + Python = ❤ - Cloud Native PragueHenning Jacobs
 
Kubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS examKubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS examAhmed AbouZaid
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes VMware Tanzu
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes IntroductionPeng Xiao
 
CKA Certified Kubernetes Administrator Notes
CKA Certified Kubernetes Administrator Notes CKA Certified Kubernetes Administrator Notes
CKA Certified Kubernetes Administrator Notes Adnan Rashid
 
ArgoCD and Tekton: Match made in Kubernetes heaven | DevNation Tech Talk
ArgoCD and Tekton: Match made in Kubernetes heaven | DevNation Tech TalkArgoCD and Tekton: Match made in Kubernetes heaven | DevNation Tech Talk
ArgoCD and Tekton: Match made in Kubernetes heaven | DevNation Tech TalkRed Hat Developers
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking OverviewSreenivas Makam
 
Rancher Rodeo
Rancher RodeoRancher Rodeo
Rancher RodeoSUSE
 
Kubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with DemoKubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with DemoOpsta
 
Container Network Interface: Network Plugins for Kubernetes and beyond
Container Network Interface: Network Plugins for Kubernetes and beyondContainer Network Interface: Network Plugins for Kubernetes and beyond
Container Network Interface: Network Plugins for Kubernetes and beyondKubeAcademy
 

Tendances (20)

An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
Introduction to Kubernetes RBAC
Introduction to Kubernetes RBACIntroduction to Kubernetes RBAC
Introduction to Kubernetes RBAC
 
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and Introduction
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
Container security
Container securityContainer security
Container security
 
Kubernetes networking & Security
Kubernetes networking & SecurityKubernetes networking & Security
Kubernetes networking & Security
 
Kubernetes + Python = ❤ - Cloud Native Prague
Kubernetes + Python = ❤ - Cloud Native PragueKubernetes + Python = ❤ - Cloud Native Prague
Kubernetes + Python = ❤ - Cloud Native Prague
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Kubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS examKubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS exam
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
CKA Certified Kubernetes Administrator Notes
CKA Certified Kubernetes Administrator Notes CKA Certified Kubernetes Administrator Notes
CKA Certified Kubernetes Administrator Notes
 
ArgoCD and Tekton: Match made in Kubernetes heaven | DevNation Tech Talk
ArgoCD and Tekton: Match made in Kubernetes heaven | DevNation Tech TalkArgoCD and Tekton: Match made in Kubernetes heaven | DevNation Tech Talk
ArgoCD and Tekton: Match made in Kubernetes heaven | DevNation Tech Talk
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking Overview
 
Multi Stage Docker Build
Multi Stage Docker Build Multi Stage Docker Build
Multi Stage Docker Build
 
Rancher Rodeo
Rancher RodeoRancher Rodeo
Rancher Rodeo
 
Kubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with DemoKubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with Demo
 
Container Network Interface: Network Plugins for Kubernetes and beyond
Container Network Interface: Network Plugins for Kubernetes and beyondContainer Network Interface: Network Plugins for Kubernetes and beyond
Container Network Interface: Network Plugins for Kubernetes and beyond
 

Similaire à K8S security best practices by Sharon Vendrov

K8s security best practices
K8s security best practicesK8s security best practices
K8s security best practicesSharon Vendrov
 
Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2Imesh Gunaratne
 
Container security
Container securityContainer security
Container securityAnthony Chow
 
Security best practices for kubernetes deployment
Security best practices for kubernetes deployment  Security best practices for kubernetes deployment
Security best practices for kubernetes deployment Aqua Security
 
Security best practices for kubernetes deployment
Security best practices for kubernetes deploymentSecurity best practices for kubernetes deployment
Security best practices for kubernetes deploymentMichael Cherny
 
Container & kubernetes
Container & kubernetesContainer & kubernetes
Container & kubernetesTed Jung
 
Docker London: Container Security
Docker London: Container SecurityDocker London: Container Security
Docker London: Container SecurityPhil Estes
 
Who is afraid of privileged containers ?
Who is afraid of privileged containers ?Who is afraid of privileged containers ?
Who is afraid of privileged containers ?Marko Bevc
 
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...Michael Man
 
New and smart way to develop microservice for istio with micro profile
New and smart way to develop microservice for istio with micro profileNew and smart way to develop microservice for istio with micro profile
New and smart way to develop microservice for istio with micro profileEmily Jiang
 
Veer's Container Security
Veer's Container SecurityVeer's Container Security
Veer's Container SecurityJim Barlow
 
Docker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your containerDocker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your containerRonak Kogta
 
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
 
Evolution of security strategies in K8s environments- All day devops
Evolution of security strategies in K8s environments- All day devops Evolution of security strategies in K8s environments- All day devops
Evolution of security strategies in K8s environments- All day devops Jose Manuel Ortega Candel
 
Three Years of Lessons Running Potentially Malicious Code Inside Containers
Three Years of Lessons Running Potentially Malicious Code Inside ContainersThree Years of Lessons Running Potentially Malicious Code Inside Containers
Three Years of Lessons Running Potentially Malicious Code Inside ContainersBen Hall
 
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications PrimerCloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications PrimerPhil Estes
 
Meetup 12-12-2017 - Application Isolation on Kubernetes
Meetup 12-12-2017 - Application Isolation on KubernetesMeetup 12-12-2017 - Application Isolation on Kubernetes
Meetup 12-12-2017 - Application Isolation on Kubernetesdtoledo67
 
Securing the Infrastructure and the Workloads of Linux Containers
Securing the Infrastructure and the Workloads of Linux ContainersSecuring the Infrastructure and the Workloads of Linux Containers
Securing the Infrastructure and the Workloads of Linux ContainersMassimiliano Mattetti
 
Evolution of security strategies in K8s environments.pdf
Evolution of security strategies in K8s environments.pdfEvolution of security strategies in K8s environments.pdf
Evolution of security strategies in K8s environments.pdfJose Manuel Ortega Candel
 

Similaire à K8S security best practices by Sharon Vendrov (20)

K8s security best practices
K8s security best practicesK8s security best practices
K8s security best practices
 
Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2
 
Container security
Container securityContainer security
Container security
 
Security best practices for kubernetes deployment
Security best practices for kubernetes deployment  Security best practices for kubernetes deployment
Security best practices for kubernetes deployment
 
Security best practices for kubernetes deployment
Security best practices for kubernetes deploymentSecurity best practices for kubernetes deployment
Security best practices for kubernetes deployment
 
Container & kubernetes
Container & kubernetesContainer & kubernetes
Container & kubernetes
 
Docker London: Container Security
Docker London: Container SecurityDocker London: Container Security
Docker London: Container Security
 
Who is afraid of privileged containers ?
Who is afraid of privileged containers ?Who is afraid of privileged containers ?
Who is afraid of privileged containers ?
 
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...
 
New and smart way to develop microservice for istio with micro profile
New and smart way to develop microservice for istio with micro profileNew and smart way to develop microservice for istio with micro profile
New and smart way to develop microservice for istio with micro profile
 
Veer's Container Security
Veer's Container SecurityVeer's Container Security
Veer's Container Security
 
Docker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your containerDocker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your container
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!
 
Evolution of security strategies in K8s environments- All day devops
Evolution of security strategies in K8s environments- All day devops Evolution of security strategies in K8s environments- All day devops
Evolution of security strategies in K8s environments- All day devops
 
Three Years of Lessons Running Potentially Malicious Code Inside Containers
Three Years of Lessons Running Potentially Malicious Code Inside ContainersThree Years of Lessons Running Potentially Malicious Code Inside Containers
Three Years of Lessons Running Potentially Malicious Code Inside Containers
 
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications PrimerCloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications Primer
 
Meetup 12-12-2017 - Application Isolation on Kubernetes
Meetup 12-12-2017 - Application Isolation on KubernetesMeetup 12-12-2017 - Application Isolation on Kubernetes
Meetup 12-12-2017 - Application Isolation on Kubernetes
 
Securing the Infrastructure and the Workloads of Linux Containers
Securing the Infrastructure and the Workloads of Linux ContainersSecuring the Infrastructure and the Workloads of Linux Containers
Securing the Infrastructure and the Workloads of Linux Containers
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Evolution of security strategies in K8s environments.pdf
Evolution of security strategies in K8s environments.pdfEvolution of security strategies in K8s environments.pdf
Evolution of security strategies in K8s environments.pdf
 

Dernier

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 

Dernier (20)

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 

K8S security best practices by Sharon Vendrov

  • 1. K8S security – Best practices By: Sharon Vendrov
  • 2. 0 500 1000 1500 2000 2500 Mac Os X Windows 7 Windows XP Windows 8.1 Windows 10 CVE Sum CVE Sum 2 Total Number Of Vulnerabilities in 2017 – Source: CVEdetails.com
  • 3. 3
  • 4. 4
  • 5. Sharon Vendrov Sr. DevOps Engineer About Me 5 Storm-runner functional
  • 6.  Infrastructure protection  K8s internal security  Authentication & Authorization options  Network  Secrets  Container runtime Security  Some other security tools and considerations 6 Agenda
  • 7. Infrastructure protection 7  Limit SSH access to your cluster  Use hardened images for your cluster ( )  Encrypt your storage volume  Avoid from exposing your cluster to the internet  Limit the access to the K8s API (consider to use bastion machine)  Create dedicated cluster for each environment (Prod, Stg, Dev)  Separate sensitive pods into different nodes
  • 8. Kubernetes internal security 8  Use minimal base docker image  Don’t use arbitrary base images  Separate sensitive workloads across instances (using anti-affinity, taints and tolerations)  Use namespaces for isolation  Enforce resource quota (CPU, Memory, Storage) Image Name node:latest ubuntu:latest alpine:latest scratch Image Size 670MB~ 110MB~ 4.1MB~ 0
  • 9. Secure kubelet 9  curl -sk https://<nodeIP>:10250/run/<namespace>/<pod-name>/<container-name> -d "cmd=ls -la /“  Protect kubelet by enable authentication and authorization: start the apiserver with --kubelet-client-certificate and --kubelet-client-key flags /usr/local/bin/kubelet --anonymous-auth=false --authorization-mode=Webhook --allow-privileged=true --kubeconfig=/var/lib/kubelet/kubeconfig --client-ca-file=/var/lib/kubernetes/ca.pem • Enable kubelet certification rotation (1.8 beta)
  • 11. 11
  • 12. 12
  • 13. Authentication 13  Static password/token file  Client certificates x509  Proxy + headers  OpenID Connect  Custom (Web hook) password,user,uid,”group1,group2,group3”
  • 14. Authentication 14  Service accounts  Default service account have full permissions over the cluster, use custom SA instead  Set “automountServiceAccountToken : false” in your pod spec – when possible
  • 15. Authorization 15  ABAC  Difficult to manage and understand  Requires ssh and root filesystem access on the master  For permission changes to take effect the cluster API server must be restarted {"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": { "user": "bob", "namespace": "projectSpaceX", "resource": "pods", "readonly": true } }
  • 16. Authorization 16  RBAC (stable 1.8) Service Account User Role binding Role
  • 17. 17 kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: read-pods namespace: default subjects: - kind: User name: Bob apiGroup: rbac.authorization.k8s.io roleRef: kind: Role name: pod-reader apiGroup: rbac.authorization.k8s.io kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: namespace: default name: pod-reader rules: - apiGroups: [""] group resources: ["pods"] verbs: ["get", "watch", "list"]
  • 18. Authorization 18  Custom (Web hook)  Node Restrict kubelet to perform R/W operation only to his bound pods --authorization-mode=Node,RBAC --admission-control=NodeRestriction
  • 20. 20
  • 21. Netwok 21  Limit the access to cloud provider metadata (http://169.254.169.254/latest/meta-data/)
  • 22. 22 $ curl -s 169.254.169.254/latest/meta-data/iam/security- credentials/kubernetes-worker-iam-policy { "Code" : "Success", "LastUpdated" : "2017-12-25T00:00:00Z", "Type" : "AWS-HMAC", "AccessKeyId" : "MyAccessKeyID", "SecretAccessKey" : "MySecretAccessKey", "Token" : "MySessionToken", "Expiration" : "2017-12-25T04:00:00Z" } @bradgeesaman
  • 23. 23 # Place credentials in ENV vars $ export AWS_REGION=us-east-1 $ export AWS_ACCESS_KEY_ID=MyAccessKeyID $ export AWS_SECRET_ACCESS_KEY=MySecretAccessKey $ export AWS_SESSION_TOKEN=MySessionToken $ aws ec2 … @bradgeesaman
  • 24. The solution 24 • For AWS use kube2iam or kiam (using docker proxy for requests to the metadata) • For GCE use k8s-metadata-proxy • Limit egress with network policy
  • 25. 25  Use network policy (GA from 1.7) https://goo.gl/HRtn5B  Egress rules are beta from 1.8 kind: NetworkPolicy apiVersion: networking.k8s.io/v1 metadata: name: access-nginx spec: podSelector: matchLabels: run: nginx ingress: - from: - podSelector: matchLabels: access: "true" • Istio
  • 26. Network policy guidelines 26  Label your workloads properly  Isolate workloads from each other  Restrict income traffic to the kube-system (except kube-dns)  Consider limit egress to the internet
  • 27. “The definition of Secret— something you tell everybody to tell nobody.” – The universe
  • 28. Treat your secrets with respect 28  Don’t store your secrets on Git, it will remain in history even If you delete it.  Create dedicated secrets for dev and prod environments  Secrets are stored at etcd as base64 (almost like plain text)  encrypt your secrets (K8S encryption –alpha 1.7)  Use Vault as you secret management (starting from Vault 0.8.3)
  • 29. Security Context A security context defines privilege and access control settings for a Pod or Container 29  Discretionary Access Control: Permission to access an object, like a file, is based on user ID (UID) and group ID (GID).  Security Enhanced Linux (SELinux): Objects are assigned security labels.  Running as privileged or unprivileged.  Linux Capabilities: Give a process some privileges, but not all the privileges of the root user.  AppArmor: Use program profiles to restrict the capabilities of individual programs.  Seccomp: Limit a process’s access to open file descriptors.  AllowPrivilegeEscalation: Controls whether a process can gain more privileges than its parent process.
  • 30. Example: RunasNonRoot 30 apiVersion: v1 kind: Pod metadata: name: security-context-demo spec: containers: - name: sec-ctx-demo image: gcr.io/google-samples/node-hello:1.0 securityContext: runAsNonRoot : true
  • 31. 31
  • 32. Example: readOnlyRootFilesystem 32 apiVersion: v1 kind: Pod metadata: name: security-context-demo spec: containers: - name: sec-ctx-demo image: gcr.io/google-samples/node-hello:1.0 securityContext: runAsNonRoot : false readOnlyRootFilesystem : true
  • 33. 33
  • 34. 34
  • 35. Other security tools and considerations 35  Scan your docker images for vulnerabilities, (Clair CoreOS /Quay.io, Docker Security Scanning, aqua, Twistlock).  Use kube-bench (aqua security) or kubernetes-auto-analyzer (nccgroup) to execute CIS Kubernetes Benchmark  Enforce cluster wide security policy w/podSecurityPolicy  Use only trusted private docker registry  Always tag your images avoid from using “latest”  Audit events and store them on external storage (beta 1.8)  Consider using kubeaudit to audit security issue
  • 36. 36
  • 37. Other security considerations 37  Specify an image with its digest (SHA256)  Keep up with K8S stable releases  Implement monitoring and set alerts  Don’t run “kubectl create –f <some unknown URL to some unknown yamls>  Keep updated with new security vulnerabilities from the google group “kubernetes-announces” https://groups.google.com/forum/#!forum/kubernetes-announce
  • 38. 38
  • 39. Thanks and credit 39  My Wife   All K8s contributors  Hacking and Hardening Kubernetes Clusters by Example [I] - Brad Geesaman - https://goo.gl/komeXN  Running containers securely with Google Container Engine, Alex Mohr and Jessica Frazelle - https://goo.gl/AFhTyp  Shipping in Pirate-Infested Waters: Practical Attack and Defense in Kubernetes [A] - Greg Castle - https://goo.gl/WFDrrv  Compliance and Identity Management in Kubernetes [I] Marc Boorshtein - https://goo.gl/Jf7Rkh  Securing K8s Microservices with Calico Network Policies, Vadim Solvey - https://goo.gl/rWGGXM

Notes de l'éditeur

  1. https://www.youtube.com/watch?v=sdF5IsyOxU4
  2. Using the firewall will force the attacker to run from the cluster and not from his “friendly environment”
  3. Public images – we aren’t aware who build them and what they contain Enforcing quota will protected us in some cases of DOS Quota doesn’t currently support ASG
  4. Who need to authenticate to the Kubernetes API?
  5. Why certificates are better? You can enable multiple authentication methods at once. You should usually use at least two methods: Reverse proxy – not secure enough we need to take into account possibility the some is already in our network. OpenID connect – no web oauth2 client and token no revokeable usually requires refresh
  6. Normal users are assumed to be managed by an outside, independent service.  Kubernetes does not have objects which represent normal user accounts. In contrast, service accounts are users managed by the Kubernetes API.
  7. Example attacker needs curl
  8. Many security features have been implemented for each release you must keep updated with them