Repository navigation
fix(diff): stop leaking secretref+ values into diff output - #2844
Merged
yxxhero merged 2 commits intoOct 24, 2026
Merged
Conversation
sergioperezcheco
requested review from
aditmeno,
itscaro,
mumoshu,
xiaomudk,
yxxhero and
zhaque44
as code owners
October 23, 2026 01:10
yxxhero
reviewed
Oct 23, 2026
yxxhero
left a comment
Member
There was a problem hiding this comment.
Reviewed — thanks for tackling #2738. The restructure of the two Eval sites (values files and inline values) is correct: I verified plain ref+:// entries still resolve while secretref+... entries stay unresolved in diff output unless --show-secrets is passed.
However, I found a third leak path the patch didn't cover: --set / --set-string (and set.values) entries go through setFlags/setStringFlags, which used the regular vals runtime unconditionally — so secretref+... set values were still expanded to plaintext on the diff command line and output, bypassing excludeSecrets entirely.
I've pushed b25d23f to this branch:
- consolidates the evaluator choice into
valsEvaluator(excludeSecrets bool)(replacingvalsRuntimeWithoutSecrets), - threads
excludeSecretsthroughnamespaceAndValuesFlags→setFlags/setStringFlags, so--set,--set-string, andset.valuesstay unresolved while diffing without--show-secrets, - the chartify path (
PrepareChartify) explicitly evaluates withfalsesince chart rendering needs resolved values, - adds
TestSetFlags_SecretExclusioncovering both modes for--setand--set-string(unresolvedsecretref+echo://...vs resolved plaintext, plainref+always resolved), - documents the diff semantics in
docs/remote-secrets.md, including the caveat that helm-diff now compares the literalsecretref+...string against what's in the cluster (which may report changes for charts that render the referenced secret into non-Secret manifests) and that--show-secretsrestores the previous resolving behavior for debugging.
CI on the new commit is running (lint and DCO already green).
`helmfile diff` resolves vals `secretref+...` entries to their plaintext secret values while writing temporary values files, so secrets leak into the diff output. The --show-secrets flag only controls the flag passed to the helm-diff plugin and never reached the values-file rendering pipeline. - add plugins.ValsInstanceExcludeSecret(): a cached vals evaluator created with vals' ExcludeSecret option, which expands plain `ref+...` entries but leaves `secretref+...` entries unresolved - wire it through StateCreator into HelmState - thread showSecrets from prepareDiffReleases into the values generation pipeline (flagsForDiff -> namespaceAndValuesFlags -> generateValuesFiles -> prepareReleaseValuesEntries / renderValuesFileToBytesWithData) and use the exclude-secret evaluator at both vals.Eval call sites when diffing without --show-secrets - --show-secrets keeps the previous plaintext behavior; template, upgrade, lint and chartify paths are unchanged Fixes helmfile#2738 Signed-off-by: B Candidate <[email protected]>
…de-secret runtime - Wire App.valsExcludeSecretRuntime into the desiredStateLoader constructed in loadDesiredStateFromYamlWithBaseDir: the field was never set in the production loader, so the whole exclude-secret diff fix was a no-op in the built binary. - Also exclude secretref+ resolution from --set/--set-string values while diffing without --show-secrets, closing the same leak via helm-diff command line arguments; template/upgrade/chartify keep full resolution. - Add TestSetFlags_SecretExclusion covering both flag generators. - Document the new --show-secrets diff semantics in docs/remote-secrets.md. Signed-off-by: yxxhero <[email protected]>
yxxhero
force-pushed
the
fix/issue-2738-secretref-diff-leak
branch
from
October 23, 2026 13:15
b25d23f to
ca3de32
Compare
yxxhero
approved these changes
Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2738
Problem
helmfile diffresolves allvalsreferences before writing temporary values files, so values declared withsecretref+...are expanded to their plaintext secret values and shown directly in the diff output.--show-secretsonly controls the flag passed to thehelm-diffplugin — it has no effect on the file-based values that helmfile itself renders, so there is no way to diff a release without exposing secrets.Root cause
Two independent
Evalsites resolve refs into temporary values files:prepareReleaseValuesEntriesunconditionally evaluates the release's inline values viast.valsRuntime.EvalrenderValuesFileToBytesWithDataevaluates a whole values file after template rendering (theref+regexp matches thesecretref+prefix as a substring, so file-based values are always fully resolved)Fix
Add a second cached
valsevaluator built with vals'ExcludeSecretoption (vals ≥ v0.38): under that evaluatorsecretref+...entries are left unresolved while plainref+...entries still expand. The diff path threads this through the existing option pipeline:DiffOpts.ExcludeSecretsis set to!showSecretsinprepareDiffReleasesflagsForDiffpasses it downnamespaceAndValuesFlags → generateValuesFiles → generateVanillaValuesFilesso bothEvalsites use the exclude-secret evaluatorWriteReleasesValues) keepsfalse, so rendered values are unchanged there--show-secretscontinues to work as before: with the flag set, secrets are resolved and shown.Testing
Evalsites and the generated temporary values files: with exclusion on,secretref+...stays literal (whileref+...still expands); with exclusion off, secrets resolve as beforego build ./...,go veton the touched packages,gofmtcleango test -p=1 ./pkg/state/ ./pkg/plugins/ ./pkg/app/pass, including the new tests under-raceOne note for reviewers: an end-to-end diff against a live cluster isn't part of the automated tests (needs a real backend), so the tests exercise the rendering pipeline up to the temporary values files.