Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 38 ยท Testing and Security

Chart Security: Provenance, Secrets and RBAC

Secure the Helm supply chain: sign and verify charts with provenance files, handle secrets safely, set secure pod defaults, limit RBAC and scan charts, with stand-ins.

Helm touches two sensitive things at once: the code you run in your cluster and the secrets that code needs. A chart can create ClusterRoles, mount host paths or pull images from anywhere, and a release record in the cluster may contain passwords. Security for Helm therefore has four parts: trust in what you install, safe handling of secrets, secure defaults in the manifests, and least privilege for Helm itself.

1. Trust: provenance and signing

A provenance file (.prov) is a signed record that proves a chart package came from a known publisher and was not modified. It contains the chart metadata, the SHA-256 of the archive and a PGP signature.

Terminal
helm package ./webapp --sign --key "Platform Team" --keyring ~/.gnupg/secring.gpg
# creates webapp-0.3.0.tgz and webapp-0.3.0.tgz.prov

helm verify webapp-0.3.0.tgz --keyring ~/.gnupg/pubring.gpg
helm install shop webapp-0.3.0.tgz --verify --keyring ~/.gnupg/pubring.gpg
helm pull mycharts/webapp --verify --keyring pubring.gpg

helm verify checks two things: the signature is valid for a key in your keyring, and the archive's hash matches the one in the .prov file. For OCI charts, many teams use cosign (Sigstore) instead, which signs the registry digest:

Terminal
cosign sign ghcr.io/my-org/charts/webapp@sha256:4e6f...
cosign verify ghcr.io/my-org/charts/webapp@sha256:4e6f... \
  --certificate-identity-regexp 'https://github.com/my-org/.*' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

Whatever you choose, pin by digest for production deployments: a version tag can be re-pushed, a digest cannot.

The stand-in below shows what verification protects against, using a hash and a keyed signature (HMAC) in place of PGP. Real provenance uses public-key signatures, but the effect is the same: any change to the archive is detected.

Python Stand-in: detect a tampered chart package

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

2. Secrets

Values are not secret. Anything passed with --set or -f is stored in the release record, and helm get values prints it. Helm stores each revision as a Kubernetes Secret named sh.helm.release.v1.<name>.v<n>, base64 encoded and gzipped but not encrypted. Anyone who can read Secrets in the namespace can read your passwords.

Safer patterns:

Pattern How it works
Reference an existing Secret The chart takes existingSecret: db-credentials; the Secret is created out of band
External secret operators The chart creates an ExternalSecret; a controller syncs from Vault or a cloud secret manager
Sealed or SOPS-encrypted values Secrets are encrypted in Git; the helm secrets plugin or a controller decrypts them
Generated passwords with lookup Generate once and reuse on upgrades (see below)

A template that accepts an existing Secret or creates one:

YAML
{{- if not .Values.auth.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "webapp.fullname" . }}
type: Opaque
data:
  password: {{ .Values.auth.password | required "auth.password or auth.existingSecret is required" | b64enc | quote }}
{{- end }}

Never commit plain-text passwords to values.yaml. Keep the default empty and require users to supply a value.

The lookup function reads live objects, so a chart can keep a generated password stable across upgrades instead of regenerating it each time:

YAML
{{- $existing := lookup "v1" "Secret" .Release.Namespace "webapp-auth" }}
password: {{ if $existing }}{{ index $existing.data "password" }}{{ else }}{{ randAlphaNum 24 | b64enc }}{{ end }}

(lookup returns an empty result under helm template and --dry-run=client, because there is no cluster.)

3. Secure manifests by default

Charts are often copied with all their defaults. Ship safe ones:

YAML
# values.yaml
podSecurityContext:
  runAsNonRoot: true
  seccompProfile:
    type: RuntimeDefault
securityContext:
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ["ALL"]
resources:
  requests: { cpu: 100m, memory: 128Mi }
  limits: { memory: 256Mi }

Other rules: pin image tags or digests (never latest), set automountServiceAccountToken: false when the app does not call the API, do not default to hostNetwork, privileged or host paths, and provide a NetworkPolicy template. The target is a chart that passes the Kubernetes restricted Pod Security Standard with no extra values.

Python Stand-in: audit rendered containers for risky settings

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

4. Least privilege for Helm and the chart

  • Helm itself uses your kubeconfig. In CI, give the deploy identity a Role limited to one namespace, not cluster-admin. Helm 3 has no Tiller, so permissions are exactly yours.
  • The chart should create the narrowest RBAC it needs: a Role rather than a ClusterRole, specific verbs and resources, no wildcards (*).
  • Review before install. helm template | less and look for ClusterRole, ClusterRoleBinding, hostPath, privileged, and validatingwebhookconfigurations.

5. Scanning

Add automated checks to CI: helm template ... | kubeconform for schema, kube-linter, checkov or trivy config for misconfigurations, and image scanners (Trivy, Grype) for the images the chart references. Policy engines (Kyverno, OPA Gatekeeper) enforce the same rules at admission time, so an unsafe chart is rejected even if CI was bypassed.

helm get values and helm get manifest expose every secret value in a release. Restrict who may read Secrets in the release namespace, and avoid printing them in CI logs.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a .prov file contain?

    Provenance holds metadata and the SHA-256, signed with PGP, so tampering can be detected.
  2. 2. Where does Helm store release data by default?

    Each revision is a Secret, which is encoded but not encrypted.
  3. 3. Which is the safest way to give a chart a database password?

    Keeping the secret outside the chart values and release record avoids leaking it.
  4. 4. Why pin charts and images by digest?

    A digest identifies exactly one content, so a re-pushed tag cannot change what you deploy.

Summary

  • Sign charts (--sign, helm verify, or cosign for OCI) and pin by digest.
  • Values and release Secrets are readable: use existing Secrets or secret operators, never plain passwords in Git.
  • Ship secure defaults (non-root, no privilege escalation, resource limits) and narrow RBAC.
  • Scan templates and images in CI and enforce policy at admission.

Next: Helm in GitHub Actions