Description
We have a kubernetes cluster setup and the flag is in the secrets. You think you can get it?
Setup
Launch the challenge instance and SSH in.
A kubeconfig or service account token will be available in the environment.
Solution
- Step 1Check the Kubernetes contextVerify that kubectl is configured and which cluster/namespace you have access to.kubectl config current-contextkubectl get namespaceskubectl auth can-i --list
- Step 2List Kubernetes secretsList all secrets in the current namespace (or all namespaces if you have cluster-wide access).kubectl get secretskubectl get secrets --all-namespaces
- Step 3Retrieve the flag secretDescribe or get the flag secret and decode the base64-encoded value.kubectl get secret flag-secret -o yamlkubectl get secret flag-secret -o jsonpath='{.data.flag}' | base64 -d
Flag
picoCTF{k8s_s3cr3ts_...}
Kubernetes secrets are stored base64-encoded; kubectl get secret with -o jsonpath decodes them.