hacktricks/pentesting/pentesting-kubernetes
2021-12-29 09:30:36 +00:00
..
attacking-kubernetes-from-inside-a-pod.md GitBook: [#2912] No subject 2021-12-23 12:26:59 +00:00
enumeration-from-a-pod.md GitBook: [#2911] No subject 2021-12-23 12:20:46 +00:00
exposing-services-in-kubernetes.md GitBook: [#2924] No subject 2021-12-29 01:10:37 +00:00
hardening-roles-clusterroles.md GitBook: [#2911] No subject 2021-12-23 12:20:46 +00:00
kubernetes-basics.md GitBook: [#2907] No subject 2021-12-22 15:22:43 +00:00
kubernetes-role-based-access-control-rbac.md GitBook: [#2907] No subject 2021-12-22 15:22:43 +00:00
pentesting-kubernetes-from-the-outside.md GitBook: [#2925] No subject 2021-12-29 09:30:36 +00:00
README.md GitBook: [#2924] No subject 2021-12-29 01:10:37 +00:00

Pentesting Kubernetes

Kubernetes Basics

If you don't know anything about Kubernetes this is a good start. Read it to learn about the architecture, components and basic actions in Kubernetes:

{% content-ref url="kubernetes-basics.md" %} kubernetes-basics.md {% endcontent-ref %}

Pentesting Kubernetes

From the Outside

There are several possible Kubernetes services that you could find exposed on the Internet (or inside internal networks). If you find them you know there is Kubernetes environment in there.

Depending on the configuration and your privileges you might be able to abuse that environment, for more information:

{% content-ref url="pentesting-kubernetes-from-the-outside.md" %} pentesting-kubernetes-from-the-outside.md {% endcontent-ref %}

Enumeration inside a Pod

If you manage to compromise a Pod read the following page to learn how to enumerate and try to escalate privileges/escape:

{% content-ref url="attacking-kubernetes-from-inside-a-pod.md" %} attacking-kubernetes-from-inside-a-pod.md {% endcontent-ref %}

Enumerating Kubernetes with Credentials

You might have managed to compromise user credentials, a user token or some service account token. You can use it to talk to the Kubernetes API service and try to enumerate it to learn more about it:

{% content-ref url="enumeration-from-a-pod.md" %} enumeration-from-a-pod.md {% endcontent-ref %}

Another important details about enumeration and Kubernetes permissions abuse is the Kubernetes Role-Based Access Control (RBAC). If you want to abuse permissions, you first should read about it here:

{% content-ref url="kubernetes-role-based-access-control-rbac.md" %} kubernetes-role-based-access-control-rbac.md {% endcontent-ref %}

Knowing about RBAC and having enumerated the environment you can now try to abuse the permissions with:

{% content-ref url="hardening-roles-clusterroles.md" %} hardening-roles-clusterroles.md {% endcontent-ref %}

Labs to practice and learn

Hardening Kubernetes

The tool kube-bench is a tool that checks whether Kubernetes is deployed securely by running the checks documented in the CIS Kubernetes Benchmark.
You can choose to:

  • run kube-bench from inside a container (sharing PID namespace with the host)
  • run a container that installs kube-bench on the host, and then run kube-bench directly on the host
  • install the latest binaries from the Releases page,
  • compile it from source.