highCWE-798OWASP A07:2021

Helm Chart Secrets in Values

Passwords, API keys, and other secrets are hardcoded directly in Helm values.yaml files, which get committed to version control and exposed to anyone with repository access.

How It Works

Helm charts use a values.yaml file to parameterize Kubernetes manifests. Developers frequently put database passwords, API keys, and TLS certificates directly in values.yaml because it is the easiest way to pass configuration. The problem is that values.yaml is a plain-text file that gets committed to Git. Anyone with read access to the repository can see every secret. Even if removed later, the secrets remain in Git history forever. Additionally, Helm stores release metadata including rendered templates in Kubernetes Secrets (base64-encoded, not encrypted), so the plaintext secrets are also visible to anyone with cluster access.

Vulnerable Code
# BAD: secrets hardcoded in values.yaml
# values.yaml
database:
  host: prod-db.example.com
  username: admin
  password: "SuperS3cret!Pass"
api:
  stripeKey: "sk_live_abc123def456"
  jwtSecret: "my-jwt-signing-key-do-not-share"
Secure Code
# GOOD: reference external secrets, never store in values.yaml
# values.yaml
database:
  host: prod-db.example.com
  existingSecret: db-credentials  # references a K8s Secret
  existingSecretPasswordKey: password
---
# Create the secret separately (via sealed-secrets or external-secrets)
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: db-credentials
spec:
  secretStoreRef:
    name: vault-backend
  target:
    name: db-credentials
  data:
    - secretKey: password
      remoteRef:
        key: prod/database/password

Real-World Example

In 2021, researchers from Aqua Security scanned public Helm chart repositories and found thousands of charts with hardcoded secrets in values.yaml, including AWS access keys, database passwords, and TLS private keys. Many of these charts were forks of official Bitnami charts where developers had filled in real production credentials before pushing them to public repos.

How to Prevent It

  • Never put passwords, API keys, or certificates directly in values.yaml files -- use existingSecret references instead
  • Use a secrets management tool like HashiCorp Vault, AWS Secrets Manager, or external-secrets-operator to inject secrets at deploy time
  • Use helm-secrets plugin with Mozilla SOPS to encrypt sensitive values before committing them to Git
  • Add values.yaml patterns to .gitignore and use values.yaml.example with placeholder values for documentation

Affected Technologies

TerraformKubernetesDocker

Data Hogo detects this vulnerability automatically.

Scan Your Repo Free

Related Vulnerabilities