Coder Social home page Coder Social logo

kube_security_lab's Introduction

Kubernetes Local Security Testing Lab

The goal of this project is to make use of Docker and specifically kind to create a lab environment for testing Kubernetes exploits and security tools entirely locally on a single machine without any requirement for remote resources or Virtual Machines being spun up.

To get the flexibility to set-up the various vulnerable clusters we're using Ansible playbooks.

Pre-requisites

Before starting you'll need to install

  • Docker
  • Ansible
    • Also install the docker python module (e.g. pip3 install docker-py or pip3 install docker)
  • Kind 0.8.0+ - Install guide here

If you're running Ubuntu, you can use the install_ansible_ubuntu.sh file to do the ansible setup.

Client Machine

There's a client machine with tools for Kubernetes security testing which can be brought up with the client-machine.yml playbook. It's best to use this client machine for all CLI tasks when running the scenarios, so you don't accidentaly pick up creds from the host.

  • ansible-playbook client-machine.yml

Once you've run the playbook, you can connect to the client machine with

docker exec -it client /bin/bash

The machine should be on the 172.18.0.0/24 network with the kind clusters (as well as being on the Docker default bridge)

Vulnerable Clusters

There's a number of playbooks which will bring up cluster's with a specific mis-configuration that can be exploited.

  • etcd-noauth.yml - ETCD Server available without authentication
  • insecure-port.yml - Kubernetes API Server Insecure Port available
  • rwkubelet-noauth.yml - Kubelet Read-Write Port available without authentication
  • ssh-to-cluster-master.yml - Access to a running pod with a service account which has cluster-admin rights.
  • ssh-to-create-pods-easy.yml - Access to a running pod with a service account which has rights to manage pods.
  • ssh-to-create-pods-hard.yml - Access to a running pod with a service account which has rights to create pods.
  • ssh-to-get-secrets.yml - Access to a running pod with a service account which has cluster level rights to get secrets.
  • ssrf-to-insecure-port.yml - This cluster has a web application with an SSRF vulnerability in it, which can be exploited to target the insecure port.
  • tiller-noauth.yml - Tiller service configured without authentication.
  • unauth-api-server.yml - API Server with anonymous access possible to sensitive paths.
  • unauth-kubernetes-dashboard.yml - Cluster with the Kubernetes Dashboard installed and available without authentication.

Using the clusters

Each of these can be used to try out various techniques for attacking Kubernetes clusters. In general the goal of each exercise should be to get access to the /etc/kubernetes/pki/ca.key file as that's a "golden key" to persistent cluster access.

For each cluster the place to start is in the Scenario Setups which has details of how to get started. Then if you want some information on one possible solution look in the Scenario Walkthroughs folder

Cleanup

When you're finished with your cluster(s) just use

kind delete cluster --name=[CLUSTERNAME]

and

docker stop client

Demo Setup

There's a specific pair of playbooks which can be useful for demonstrating Kubernetes vulnerabilities. the demo-cluster.yml brings up a kind cluster with multiple vulnerabilities and the demo-client-machine.yml brings up a client container with the Kubernetes Kubeconfig for the demo cluster already installed. For this pair, it's important to bring up the cluster before the client machine, so that the kubeconfig file is available to be installed.

kube_security_lab's People

Contributors

raesene avatar bafdyce avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.