{
  "id": "security/kubernetes-secret-exposed-in-env-var-without-encoding",
  "signature": "Kubernetes secret exposed in environment variable due to missing base64 encoding",
  "signature_zh": "Kubernetes密钥因缺少Base64编码在环境变量中暴露",
  "regex": "Secret.*not base64|invalid secret.*encoding|secret.*plaintext.*env",
  "domain": "security",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Kubernetes secrets must be base64-encoded when defined in YAML, but developers often forget to encode the value, leaving the plaintext secret visible in the pod spec and logs.",
  "root_cause_type": "generic",
  "root_cause_zh": "Kubernetes密钥在YAML中定义时必须进行Base64编码，但开发者常忘记编码，导致明文密钥在Pod规范和日志中暴露。",
  "versions": [
    {
      "version": "Kubernetes 1.24+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "kubectl 1.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Helm 3.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Minikube 1.28.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Use the secret value directly in the YAML without encoding, assuming Kubernetes will handle it",
      "why_fails": "Kubernetes requires base64-encoded values; plaintext will either cause a validation error or be stored as-is, exposing the secret.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrap the secret value in single quotes to escape special characters",
      "why_fails": "Quoting does not encode the value; it only prevents YAML parsing issues but still leaves the secret in plaintext.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a ConfigMap instead of a Secret for sensitive data",
      "why_fails": "ConfigMaps store data in plaintext and are not designed for secrets; this exposes the data even more.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Always base64-encode the secret value before placing it in the YAML. For example:\n\necho -n 'my-secret-password' | base64\n# Output: bXktc2VjcmV0LXBhc3N3b3Jk\n\nThen use it in the Secret YAML:\n\napiVersion: v1\nkind: Secret\nmetadata:\n  name: my-secret\ntype: Opaque\ndata:\n  password: bXktc2VjcmV0LXBhc3N3b3Jk",
      "success_rate": 0.95,
      "how": "Always base64-encode the secret value before placing it in the YAML. For example:\n\necho -n 'my-secret-password' | base64\n# Output: bXktc2VjcmV0LXBhc3N3b3Jk\n\nThen use it in the Secret YAML:\n\napiVersion: v1\nkind: Secret\nmetadata:\n  name: my-secret\ntype: Opaque\ndata:\n  password: bXktc2VjcmV0LXBhc3N3b3Jk",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use kubectl to create secrets from literal values, which handles encoding automatically:\n\nkubectl create secret generic my-secret --from-literal=password='my-secret-password'\n\nThis command base64-encodes the value and stores it correctly.",
      "success_rate": 0.9,
      "how": "Use kubectl to create secrets from literal values, which handles encoding automatically:\n\nkubectl create secret generic my-secret --from-literal=password='my-secret-password'\n\nThis command base64-encodes the value and stores it correctly.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use external secrets management tools like HashiCorp Vault with the Kubernetes External Secrets Operator to avoid manual encoding entirely:\n\napiVersion: external-secrets.io/v1beta1\nkind: ExternalSecret\nmetadata:\n  name: my-external-secret\nspec:\n  secretStoreRef:\n    name: vault-backend\n    kind: SecretStore\n  target:\n    name: my-secret\n  data:\n  - secretKey: password\n    remoteRef:\n      key: /myapp/password",
      "success_rate": 0.85,
      "how": "Use external secrets management tools like HashiCorp Vault with the Kubernetes External Secrets Operator to avoid manual encoding entirely:\n\napiVersion: external-secrets.io/v1beta1\nkind: ExternalSecret\nmetadata:\n  name: my-external-secret\nspec:\n  secretStoreRef:\n    name: vault-backend\n    kind: SecretStore\n  target:\n    name: my-secret\n  data:\n  - secretKey: password\n    remoteRef:\n      key: /myapp/password",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Always base64-encode the secret value before placing it in the YAML. For example:\n\necho -n 'my-secret-password' | base64\n# Output: bXktc2VjcmV0LXBhc3N3b3Jk\n\nThen use it in the Secret YAML:\n\napiVersion: v1\nkind: Secret\nmetadata:\n  name: my-secret\ntype: Opaque\ndata:\n  password: bXktc2VjcmV0LXBhc3N3b3Jk",
    "Use kubectl to create secrets from literal values, which handles encoding automatically:\n\nkubectl create secret generic my-secret --from-literal=password='my-secret-password'\n\nThis command base64-encodes the value and stores it correctly.",
    "Use external secrets management tools like HashiCorp Vault with the Kubernetes External Secrets Operator to avoid manual encoding entirely:\n\napiVersion: external-secrets.io/v1beta1\nkind: ExternalSecret\nmetadata:\n  name: my-external-secret\nspec:\n  secretStoreRef:\n    name: vault-backend\n    kind: SecretStore\n  target:\n    name: my-secret\n  data:\n  - secretKey: password\n    remoteRef:\n      key: /myapp/password"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://kubernetes.io/docs/concepts/configuration/secret/",
  "official_doc_section": null,
  "error_code": "SecretDecodeError",
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2024-01-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}