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

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

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

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

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
kubesec — Kubernetesリソースのセキュリティリスク分析 | Kitploit
ツール/GitHubGitHub/controlplaneio/kubesec
クラウドインフラストラクチャセキュリティ防御ツール静的分析コンテナセキュリティ構成監査クラウドセキュリティDevSecOps設定ミス
GitHubcontrolplaneio/kubesec

kubesec

Kubernetesリソースのセキュリティリスク分析

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

人気

すべて見る →

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

すべてのツールを探索

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

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

Kubesec

Testing Workflow Security Analysis Workflow Release Workflow

Go Report Card PkgGoDev

🚨 v1 API は非推奨です。リリースノートをお読みください 🚨

Kubernetesリソースのセキュリティリスク分析

🎬 デモ

Kubesec CLI demo

その他の例については、ControlPlaneのホスティングAPIを利用している Kubesec.io をご覧ください(v2.kubesec.io/scan)。


  • クイックスタート
  • Kubesecのダウンロード
  • 使用例
    • スキャン
      • Dockerでの使用
      • 出力形式
    • ルールの表示
    • カスタムスキーマ
  • HTTPサーバーモード
  • Kubesec-as-a-Service
  • コントリビューション
  • ヘルプの入手
  • 変更履歴

🚀 クイックスタート

1. マニフェストを準備する

スキャンするKubernetesリソースファイル(例: kubesec-test.yaml)を作成します。簡単なテストとして、次のPodマニフェストを保存できます:

root@kitploit:~
$ cat <<EOF > kubesec-test.yaml
apiVersion: v1
kind: Pod
metadata:
  name: kubesec-demo
spec:
  containers:
  - name: kubesec-demo
    image: gcr.io/google-samples/node-hello:1.0
    securityContext:
      readOnlyRootFilesystem: true
EOF

2. 最初のスキャンを実行する

マニフェストファイルに対してスキャンを実行します:

root@kitploit:~
# Using the local binary
kubesec scan kubesec-test.yaml

# Or using Docker
docker run -i kubesec/kubesec:v2 scan /dev/stdin < kubesec-test.yaml

# Using the local binary with a human-readable table output format
kubesec scan kubesec-test.yaml --format table

[!TIP] 結果をデフォルトのJSON形式ではなく人間が読みやすいテーブルで表示するには、--format table フラグを使用してください

kubesec はセキュリティスコアとリソースの詳細な分析を出力します。

📦 Kubesecのダウンロード

Kubesecは次の形式で利用できます:

  • Dockerコンテナイメージ(docker.io/kubesec/kubesec:v2)
  • Linux/MacOS/Winバイナリ(最新リリースを入手)
  • Kubernetes Admission Controller
  • Kubectlプラグイン

または、GitHubから最新コミットをインストールします:

Go 1.16+

root@kitploit:~
$ go install github.com/controlplaneio/kubesec/v2@latest

Go バージョン < 1.16

root@kitploit:~
$ GO111MODULE="on" go get github.com/controlplaneio/kubesec/v2

📖 使用例

スキャン

ローカルファイルまたは標準入力からKubernetesリソースをスキャンします。

Kubesecは、単一の入力ファイル内の複数のYAMLドキュメントをスキャンできます。また、--- で区切られた複数のドキュメントとして正しくフォーマットされていれば、複数のファイルから同時にスキャンすることもできます。

root@kitploit:~
# Scan a specific local YAML file
kubesec scan ./deployment.yaml

# Scan from standard input (JSON or YAML)
cat file.json | kubesec scan -

# Scan a rendered Helm chart
helm template -f values.yaml ./chart | kubesec scan /dev/stdin

# Scan multiple YAML documents separated by '---'
{ cat test/asset/multi.yml; echo "---"; cat test/asset/critical.yml; } | kubesec scan -

Dockerでの使用

公式Dockerイメージを使用して同じスキャンコマンドを実行できます:

root@kitploit:~
# Scan a file via Docker using standard input
docker run -i kubesec/kubesec:v2 scan /dev/stdin < kubesec-test.yaml

出力形式

Kubesecは、--format / -f フラグで指定する3つの異なる出力形式(json(デフォルト)、table、template)をサポートしており、単一の入力ファイル内の複数のYAMLドキュメントをスキャンできます。

root@kitploit:~
# JSON array output (default behaviour)
kubesec scan ./deployment.yaml --format json

# Human-readable table output
kubesec scan ./deployment.yaml --format table

# Use a custom template for the output
kubesec scan ./deployment.yaml --format template --template report-template.tmpl

特定のルールのスキャン

root@kitploit:~
# One rule
kubesec scan --rules CapSysAdmin kubesec-test.yaml

# Multiple rules
kubesec scan --rules RunAsNonRoot,SeccompAny,ApparmorAny kubesec-test.yaml
JSON出力の例
root@kitploit:~
[
  {
    "object": "Pod/security-context-demo.default",
    "valid": true,
    "message": "Failed with a score of -30 points",
    "score": -30,
    "scoring": {
      "critical": [
        {
          "selector": "containers[] .securityContext .capabilities .add == SYS_ADMIN",
          "reason": "CAP_SYS_ADMIN is the most privileged capability and should always be avoided",
          "points": -30
        }
      ],
      "advise": [
        {
          "selector": "containers[] .securityContext .runAsNonRoot == true",
          "reason": "Force the running image to run as a non-root user to ensure least privilege",
          "points": 1
        },
        {
          // ...
        }
      ]
    }
  }
]
テーブル出力の例

Table output

ルールの表示

root@kitploit:~
# Print all scanning rules with their associated point scores
kubesec print-rules

# Print all scanning rules with their associated point scores as a table
kubesec print-rules --format table

ルール出力JSONの例

root@kitploit:~
[
  {
    "id": "AllowPrivilegeEscalation",
    "selector": "containers[] .securityContext .allowPrivilegeEscalation == true",
    "reason": "Ensure a non-root process can not gain more privileges",
    "kinds": [
      "Pod",
      "Deployment",
      "StatefulSet",
      "DaemonSet"
    ],
    "points": -7,
    "advise": 0
  },
...
]

カスタムスキーマ

Kubesecはkubeconform(@yannhに感謝)を利用して、スキャン対象のマニフェストを検証します。 つまり、別のスキーマ場所を指定する場合は、kubeconform READMEに記載されているルールに従います。

root@kitploit:~
# Usees the latest schema from upstream
# Schema will be fetched from: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/pod-v1.json
kubesec scan ./pod.yaml

# Use a specific schema version from upstream (format x.y.z with no v prefix)
# Schema will be fetched from: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.25.3-standalone-strict/pod-v1.json
kubesec scan ./pod.yaml --kubernetes-version 1.25.3

# Use a specific schema version in an airgapped environment over HTTP
# Schema will be fetched from: `https://host.server/v<version>-standalone-strict/pod-v1.json`
kubesec scan ./deployment.yaml --kubernetes-version <version> --schema-location https://host.server

# Use a specific schema version in an airgap environment with local files
# Schema will be read from: `/opt/schemas/v<version>-standalone-strict/pod-v1.json`
kubesec scan ./deployment.yaml --kubernetes-version <version> --schema-location /opt/schemas

注記: 外部ネットワーク呼び出しを制限し、インターネットに接続されていない環境での使用を可能にするため、kubesec イメージにはスキーマが組み込まれています。スキーマの場所を変更する場合は、実行時に K8S_SCHEMA_VER と SCHEMA_LOCATION 環境変数を変更する必要があります。

HTTPサーバーモード

Kubesecには、ネットワーク経由でスキャン要求を受け付けるHTTPサーバーが同梱されており、ローカルまたはコンテナ内で実行できます。

CLIでの使用

root@kitploit:~
# Start the HTTP server in the background on port 8080
kubesec http 8080 &

# Send a file to the running server via POST
curl -sSX POST --data-binary @deployment.yaml http://localhost:8080/scan

# Stop the background local server when finished
kill %

Dockerでの使用

root@kitploit:~
# Start the HTTP server using Docker
docker run -d -p 8080:8080 kubesec/kubesec:v2 http 8080

# Send a file to the running server via POST
curl -sSX POST --data-binary @deployment.yaml http://localhost:8080/scan

サーバーを停止することを忘れないでください。

Kubesec-as-a-Service

KubesecはHTTPSでも v2.kubesec.io/scan で利用できます。

機密性の高いYAMLをこのパブリックサービスに送信しないでください。

このサービスは、ベストエフォートで運営されています。

root@kitploit:~
# Submit a manifest directly to the hosted v2 API
curl -sSX POST --data-binary @"deployment.yaml" https://v2.kubesec.io/scan

# Parse the API output using jq to return a non-zero exit code if the score is <= 10
curl -sSX POST --data-binary @"deployment.yaml" https://v2.kubesec.io/scan | jq --exit-status '.score > 10'

# Use the "rule" query parameter to scan only specific rules (multiple supported)
curl -sSX POST --data-binary @test/asset/score-0-cap-sys-admin.yml "http://localhost:8080/scan?rule=SeccompAny&rule=ApparmorAny"

Bash関数を定義することもできます。例:

root@kitploit:~
# Define a BASH function
$ kubesec ()
{
    local FILE="${1:-}";
    [[ ! -e "${FILE}" ]] && {
        echo "kubesec: ${FILE}: No such file" >&2;
        return 1
    };
    curl --silent \
      --compressed \
      --connect-timeout 5 \
      -sSX POST \
      --data-binary=@"${FILE}" \
      https://v2.kubesec.io/scan
}


# POST a Kubernetes resource to v2.kubesec.io/scan
$ kubesec ./deployment.yml

# Return non-zero status code is the score is not greater than 10
$ kubesec ./score-9-deployment.yml | jq --exit-status '.score > 10' >/dev/null
# status code 1

コントリビューション

詳細は CONTRIBUTING.md を参照してください。

ヘルプの入手

KubesecとKubernetesセキュリティについてご質問がある場合は:

  • Kubesecのドキュメントを読む
  • Twitterで @sublimino または @controlplaneio に連絡する
  • イシューを報告する

フィードバックはいつでも歓迎します!


❤を込めて ControlPlane より

ツールをダウンロード