etcd Unauthenticated Access
An unauthenticated etcd instance exposes all stored key-value pairs, including Kubernetes secrets, TLS certificates, and service account tokens. In a Kubernetes environment, extracting these secrets typically leads to full cluster compromise. Confirm access is open through etcd enumeration first.
Extracting Kubernetes Secrets
Kubernetes stores secrets in etcd under /registry/secrets/. Values are base64-encoded (or encrypted if encryption-at-rest is configured).
/registry/secrets/default/db-credentials /registry/secrets/default/tls-cert /registry/secrets/kube-system/admin-token-x4b2z /registry/secrets/kube-system/kube-proxy /registry/secrets/monitoring/grafana-admin
The output is a Kubernetes Secret protobuf. Credential values are base64-encoded. Binary data will be mixed with readable strings containing the secret name, namespace, and type.
To extract readable values from the protobuf output, pipe through strings or decode with a protobuf parser.
Service Account Token Extraction
Kubernetes service account tokens stored in etcd grant API access to the cluster. Admin-level tokens allow full cluster control.
/registry/secrets/kube-system/admin-token-x4b2z /registry/secrets/kube-system/default-token-abc12
Tokens in kube-system namespace often have elevated privileges. Extract the token value and use it with kubectl.
Explain command
| --insecure-skip-tls-verify | Skip TLS certificate verification for the API server. |
Replace <extracted-token> with the JWT token from the secret. If successful, enumerate cluster resources and escalate from there.
Bulk Data Dump
Dump all keys and values from etcd for offline analysis.
Explain command
| -w json | Output in JSON format for parsing. |
| --limit=0 | No limit, dump everything. |
Large clusters can have thousands of keys. The JSON dump contains base64-encoded keys and values. Parse with jq to search for specific patterns.
Searches decoded values for common credential keywords. Adjust the word list based on the target environment.
Writing Keys (Persistence)
With write access, an attacker can modify Kubernetes resources directly in etcd, bypassing RBAC and admission controllers.
Warning
Modifying etcd directly can break the Kubernetes cluster. In a pentest, demonstrate the capability by writing a harmless test key rather than modifying real resources.
OK
Proves write access. Clean up after: etcdctl del /test/pentest-proof
References
-
Kubernetes: SecretsDOCS: Kubernetes: Secrets, kubernetes.io/docs/concepts/configuration/secret (opens in new tab)
How Kubernetes stores secrets, including etcd backend details.
-
HackTricks: 2379 Pentesting etcdTOOL: HackTricks: 2379 Pentesting etcd, hacktricks.wiki/en/network-services-pentesting/2379-pentesting-etcd.html (opens in new tab)
etcd enumeration and exploitation with Kubernetes focus.