walidshaari / Certified-Kubernetes-Security-Specialist

Curated resources help you prepare for the CNCF/Linux Foundation CKS 2021 "Kubernetes Certified Security Specialist" Certification exam. Please provide feedback or requests by raising issues, or making a pull request. All feedback for improvements are welcome. thank you.
Creative Commons Attribution Share Alike 4.0 International
2k stars 533 forks source link
apparmor certification cks ckss exam-objectives falco kernel-hardening kube-bench kube-hunter kubernetes kubernetes-security mitre-attack open-policy-agent os-footprint pod pod-security-policy policy seccomp security trivy

License: CC BY-SA 4.0 PRs Welcome

Certified Kubernetes Security Specialist - CKS

Online curated resources that will help you prepare for taking the Kubernetes Certified Kubernetes Security Specialist CKS Certification exam.

Resources are primarly cross referenced back to the allowed CKS sites during the exam as per CNCF/Linux Foundation exam allowed search rules. Videos and other third party resources e.g. blogs will be provided as an optional complimentary material and any 3rd party material not allowed in the exam will be designated with :triangular_flag_on_post: in the curriculum sections below.

Ensure you have the right version of Kubernetes documentation selected (e.g. v1.26 as of January 2023) especially for API objects and annotations, however for third party tools, you might find that you can still find references for them in old releases and blogs e.g. Falco install.

Exam Brief

Offical exam objectives you review and understand in order to pass the test.

URLs to prepare for the exam:

Exam interface

According to official Linux Foundation documentation and as of June 2022, there was a change in the exam platform. It is just an exam platform, so the exam questions will not change, but there were a few things that seemed to concern you, so I will write them down:

The new ExamUI includes improved features such as:

CKS repo topics overview


Cluster Setup - 10%

:large_blue_circle: Securing a Cluster

  1. Use Network security policies to restrict cluster level access

  2. :triangular_flag_on_post: Use CIS benchmark to review the security configuration of Kubernetes components (etcd, kubelet, kubedns, kubeapi)

    • :triangular_flag_on_post: Kube-bench - Checks whether Kubernetes is deployed securely by running the checks documented ain the CIS Kubernetes Benchmark.
  3. Properly set up Ingress objects with security control

  4. Protect node metadata and endpoints

    Using Kubernetes network policy to restrict pods access to cloud metadata * This example assumes AWS cloud, and metadata IP address is 169.254.169.254 should be blocked while all other external addresses are not. ```yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-only-cloud-metadata-access spec: podSelector: {} policyTypes: - Egress egress: - to: - ipBlock: cidr: 0.0.0.0/0 except: - 169.254.169.254/32 ```
  5. Minimize use of, and access to, GUI elements

  6. Verify platform binaries before deploying

    :clipboard: Kubernetes binaries can be verified by their digest **sha512 hash** - Checking the Kubernetes release page for the specific release - Checking the change log for the [images and their digests](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.19.md#downloads-for-v1191)

Cluster Hardening - 15%

  1. Restrict access to Kubernetes API

  2. Use Role-Based Access Controls to minimize exposure

  3. Exercise caution in using service accounts e.g. disable defaults, minimize permissions on newly created ones

    :clipboard: Opt out of automounting API credentials for a service account #### Opt out at service account scope ```yaml apiVersion: v1 kind: ServiceAccount metadata: name: build-robot automountServiceAccountToken: false ``` #### Opt out at pod scope ```yaml apiVersion: v1 kind: Pod metadata: name: cks-pod spec: serviceAccountName: default automountServiceAccountToken: false ```
  4. Update Kubernetes frequently

System Hardening - 15%

  1. Minimize host OS footprint (reduce attack surface)

    :clipboard: :confused: Reduce host attack surface * [seccomp which stands for secure computing was originally intended as a means of safely running untrusted compute-bound programs](https://kubernetes.io/docs/tutorials/clusters/seccomp/) * [AppArmor can be configured for any application to reduce its potential host attack surface and provide greater in-depth defense.](https://kubernetes.io/docs/tutorials/clusters/apparmor/) * [PSA enforces](https://kubernetes.io/docs/concepts/security/pod-security-admission/) * Apply host updates * Install minimal required OS fingerprint * Identify and address open ports * Remove unnecessary packages * Protect access to data with permissions * [Restirct allowed hostpaths](https://kubernetes.io/docs/concepts/policy/pod-security-policy/#volumes-and-file-systems)
  2. Minimize IAM roles

  3. Minimize external access to the network

    :clipboard: :confused: if it means deny external traffic to outside the cluster?!! * not tested, however, the thinking is that all pods can talk to all pods in all name spaces but not to the outside of the cluster!!! ```yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-external-egress spec: podSelector: {} policyTypes: - Egress egress: to: - namespaceSelector: {} ```
  4. Appropriately use kernel hardening tools such as AppArmor, seccomp

Minimize Microservice Vulnerabilities - 20%

  1. Setup appropriate OS-level security domains e.g. using PSA, OPA, security contexts
  2. Manage kubernetes secrets
  3. Use container runtime sandboxes in multi-tenant environments (e.g. gvisor, kata containers)
  4. Implement pod to pod encryption by use of mTLS
    • [ ] :pencil: check if service mesh is part of the CKS exam

Supply Chain Security - 20%

  1. Minimize base image footprint

    :clipboard: Minimize base Image * Use distroless, UBI minimal, Alpine, or relavent to your app nodejs, python but the minimal build. * Do not include uncessary software not required for container during runtime e.g build tools and utilities, troubleshooting and debug binaries. * :triangular_flag_on_post: [Learnk8s: 3 simple tricks for smaller Docker images](https://learnk8s.io/blog/smaller-docker-images) * :triangular_flag_on_post: [GKE 7 best practices for building containers](https://cloud.google.com/blog/products/gcp/7-best-practices-for-building-containers)
  2. Secure your supply chain: whitelist allowed image registries, sign and validate images

  3. Use static analysis of user workloads (e.g. kubernetes resources, docker files)

  4. Scan images for known vulnerabilities

  5. Perform behavioural analytics of syscall process and file activities at the host and container level to detect malicious activities

  6. Detect threats within a physical infrastructure, apps, networks, data, users and workloads

  7. Detect all phases of attack regardless where it occurs and how it spreads

    :clipboard: Attack Phases - :triangular_flag_on_post: [Kubernetes attack martix Microsoft blog](https://www.microsoft.com/security/blog/2020/04/02/attack-matrix-kubernetes/) - :triangular_flag_on_post: [MITRE attack framwork using Falco](https://sysdig.com/blog/mitre-attck-framework-for-container-runtime-security-with-sysdig-falco/) - :triangular_flag_on_post: [Lightboard video: Kubernetes attack matrix - 3 steps to mitigating the MITRE ATT&CK Techniques](https://www.youtube.com/watch?v=0fnWu06eQCU) - :triangular_flag_on_post: [CNCF Webinar: Mitigating Kubernetes attacks](https://www.cncf.io/webinars/mitigating-kubernetes-attacks/)
  8. Perform deep analytical investigation and identification of bad actors within the environment

  9. Ensure immutability of containers at runtime

  10. Use Audit Logs to monitor access


Extra helpful material

Slack

  1. Kubernetes Community - #cks-exam-prep
  2. Kubernauts Community - #cks
  3. Saiyam's Pathak OpenSource Discord #CKS channel

Twitch

  1. KubeNativeSecurity twitch stream Talk Shows & Podcasts

Books

  1. Aqua Security Liz Rice:Free Container Security Book
  2. Learn Kubernetes security: Securely orchestrate, scale, and manage your microservices in Kubernetes deployments
  3. Let's Learn CKS Scenarios

Youtube Videos

  1. Killer Shell: Kubernetes CKS Full Course Theory + Practice + Browser Scenarios
  2. Google/Ian Lewis: Kubernetes security best practices
  3. Code in Action for the book Learn Kubernetes Security playlist
  4. Kubernetes security concepts and demos
  5. Webinar | Certified Kubernetes Security Specialist (CKS), January 2022

Containers and Kubernetes Security Training

  1. Killer.sh CKS practice exam - use code walidshaari for 20% discount.
  2. UDEMY Kim Wüstkamp's Kubernetes CKS 2021 Complete Course with killer.sh Simulator (discounted price)
  3. Linux Foundation Kubernetes Security essentials LFS 260
  4. Mumshad's KodeCloud "Certified Kubernetes Security Specialist" CKS and training and labs
  5. Linux Academy/ACloudGuru Kubernetes security
  6. Zeal Vora's Udemy Certified Kubernetes Security Specialist 2021 - Link includes a discount till 28th January 2021
  7. Cloud native security defending containers and kubernetes
  8. Tutorial: Getting Started With Cloud-Native Security - Liz Rice, Aqua Security & Michael Hausenblas
  9. K21 academy CKS step by step activity hands-on-lab activity guide
  10. Andrew Martin Control Plane Security training
  11. Free Exam simulators from killer.sh available with CKS certification from Linux Foundation
  12. Sysdig Falco 101
  13. Killercoda in-browser CKS Playground and Challenges - FREE

Other CKS related repos

  1. Stackrox CKS study guide - Brief and informative study guide from Stackrox @mfosterrox
  2. Kim's CKS Challenge series - also posted on medium @ https://wuestkamp.medium.com/
  3. Abdennour
  4. Ibrahim Jelliti
  5. Viktor Vedmich
  6. Kubernetes Security Checklist and Requirements
  7. CKS Exam series