本文へスキップ
Skillpedia
エージェント35k · #7861

detecting-privilege-escalation-in-kubernetes-pods

できること

このツールは、Kubernetesなどで使われるコンテナ内のプログラムが、本来必要以上の権限を得ようとするのを見つけて止めるためのものです。設定を確認し、リアルタイムの動きを監視し、操作ログを分析します。

使う場面

  • ✓コンテナが通常より高い権限で動いている疑いがあるとき。
  • ✓コンテナが余分な権限を得ないようにする仕組みを構築するとき。
  • ✓コンテナ内の不審な動きを調査するとき。

スキルのリンク

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-privilege-escalation-in-kubernetes-pods/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-privilege-escalation-in-kubernetes-pods/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Kubernetesクラスター内のコンテナが、不当な権限を得ようとしていないか確認してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

コンテナの起動前にルールを確認する仕組み(アドミッションコントロール)と、実行中の動きを監視する仕組み(ランタイム監視)を使います。また、監査ログを分析して不審な動きを見つけます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Detecting Privilege Escalation in Kubernetes Pods

Overview

Privilege escalation in Kubernetes occurs when a pod or container gains elevated permissions beyond its intended scope. This includes running as root, using privileged mode, mounting host filesystems, enabling dangerous Linux capabilities, or exploiting kernel vulnerabilities. Detection combines admission control (prevention), runtime monitoring (detection), and audit logging (investigation).

When to Use

  • When investigating security incidents that require detecting privilege escalation in kubernetes pods
  • When building detection rules or threat hunting queries for this domain
  • When SOC analysts need structured procedures for this analysis type
  • When validating security monitoring coverage for related attack techniques

Prerequisites

  • Kubernetes cluster v1.25+ (Pod Security Admission support)
  • kubectl with cluster-admin access
  • Falco or similar runtime security tool
  • OPA Gatekeeper or Kyverno for admission policies

Privilege Escalation Vectors in Kubernetes

Vector Risk Detection Method
privileged: true Full host access Admission control + audit
hostPID: true Access host processes Admission control
hostNetwork: true Access host network stack Admission control
hostPath volumes Read/write host filesystem Admission control
SYS_ADMIN capability Near-privileged access Admission + runtime
allowPrivilegeEscalation: true setuid/setgid exploitation Admission control
runAsUser: 0 Container root Admission control
automountServiceAccountToken Token theft for API access Admission control
Writable /proc or /sys Kernel parameter manipulation Runtime monitoring

Detection with Admission Control

Pod Security Admission (Built-in)

# Enforce restricted policy on namespace
apiVersion: v1
kind: Namespace
metadata:
  name: production
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/enforce-version: latest
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/warn: restricted

OPA Gatekeeper Policies

# Block dangerous capabilities
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
  name: k8sdangerouspriv
spec:
  crd:
    spec:
      names:
        kind: K8sDangerousPriv
  targets:
    - target: admission.k8s.gatekeeper.sh
      rego: |
        package k8sdangerouspriv

        dangerous_caps := {"SYS_ADMIN", "SYS_PTRACE", "SYS_MODULE", "DAC_OVERRIDE", "NET_ADMIN", "NET_RAW"}

        violation[{"msg": msg}] {
          container := input.review.object.spec.containers[_]
          cap := container.securityContext.capabilities.add[_]
          dangerous_caps[cap]
          msg := sprintf("Container %v adds dangerous capability: %v", [container.name, cap])
        }

        violation[{"msg": msg}] {
          container := input.review.object.spec.containers[_]
          container.securityContext.privileged == true
          msg := sprintf("Container %v runs in privileged mode", [container.name])
        }

        violation[{"msg": msg}] {
          container := input.review.object.spec.containers[_]
          container.securityContext.allowPrivilegeEscalation == true
          msg := sprintf("Container %v allows privilege escalation", [container.name])
        }

        violation[{"msg": msg}] {
          input.review.object.spec.hostPID == true
          msg := "Pod uses host PID namespace"
        }

        violation[{"msg": msg}] {
          input.review.object.spec.hostNetwork == true
          msg := "Pod uses host network"
        }

Runtime Detection with Falco

# /etc/falco/rules.d/privesc-detection.yaml
- rule: Setuid Binary Execution in Container
  desc: Detect execution of setuid/setgid binaries in a container
  condition: >
    spawned_process and container and
    (proc.name in (su, sudo, newgrp, chsh, passwd) or
     proc.is_exe_upper_layer=true)
  output: >
    Setuid/setgid binary executed in container
    (user=%user.name container=%container.name image=%container.image.repository
     command=%proc.cmdline parent=%proc.pname)
  priority: WARNING
  tags: [container, privilege-escalation, T1548]

- rule: Capability Gained in Container
  desc: Detect when a process gains elevated capabilities
  condition: >
    evt.type = capset and container and
    evt.arg.cap != ""
  output: >

…
よくある質問

コンテナにおける「権限昇格」とは何ですか?

コンテナ内のプログラムが、本来持つはずのない権限を得てしまうことです。たとえば管理者として動いたり、システムの重要なファイルにアクセスしたりする場合があります。

どのようなツールが使われますか?

主なものは、アドミッションコントロール用のOPA Gatekeeperと、ランタイム監視用のFalcoです。このほか、Kubernetesの監査ログも分析します。

このツールを使うには特別な権限が必要ですか?

はい。一般的にKubernetesクラスターの管理者権限が必要です。また、監視やアドミッションコントロールのツールがすでに導入され、設定されている必要があります。

詳細

作者による元の説明

Detects and prevents privilege escalation inside Kubernetes pods by combining admission control (OPA policies), runtime monitoring (Falco), and audit log analysis of security contexts, Linux capabilities, and syscall patterns. Use when investigating a pod running as root or privileged, hardening workloads against in-pod escalation, or hunting for containers exceeding their intended scope. Keywords

repo: mukul975/Anthropic-Cybersecurity-Skills

人気

GitHubのスター
35k
ランキング
#7861
ライセンス
Apache-2.0
更新日
2026/8/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル