Repository navigation
Fix Helm values file path containment and symlink checks - #7684
Open
shellyco-code wants to merge 1 commit into
Open
shellyco-code wants to merge 1 commit into
shellyco-code wants to merge 1 commit into
Conversation
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
shellyco-code
requested review from
khanhtc1202,
mohammedfirdouss and
t-kikuc
and
a balanced review from Copilot
November 28, 2026 13:46
👷 Deploy request for pipecd-site pending review.Visit the deploys page to approve it
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical symlink-handling flaws allow Helm to read files outside the application directory and dangling-link cycles to trigger unbounded recursion that can exhaust the process stack.
2 open issues
What changed in this PR
This PR hardens Helm values-file validation across PipeCD’s legacy and plugin-based Kubernetes providers, addressing the traversal and symlink bypasses reported in #7683.
Changes:
- Replaces string-prefix containment checks with absolute-path normalization and
filepath.Rel. - Expands symlink resolution to handle chains, symlinked ancestors, and dangling targets.
- Adds regression tests for traversal, sibling-prefix collisions, and symlink containment.
| File | Description |
|---|---|
pkg/app/pipedv1/plugin/kubernetes/provider/helm.go |
Updates Kubernetes plugin path validation and symlink resolution. |
pkg/app/pipedv1/plugin/kubernetes/provider/helm_test.go |
Adds traversal and symlink regression tests. |
pkg/app/pipedv1/plugin/kubernetes_multicluster/provider/helm.go |
Applies validation changes to the multicluster provider. |
pkg/app/pipedv1/plugin/kubernetes_multicluster/provider/helm_test.go |
Adds equivalent multicluster regression tests. |
pkg/app/piped/platformprovider/kubernetes/helm.go |
Applies validation changes to the legacy provider. |
pkg/app/piped/platformprovider/kubernetes/helm_test.go |
Adds equivalent legacy-provider regression tests. |
Review effort: Balanced
| if !isRooted { | ||
| valueFilePath = filepath.Join(absAppDir, valueFilePath) | ||
| } | ||
| absValueFilePath, err := filepath.Abs(valueFilePath) |
| } | ||
| target = filepath.Join(parent, target) | ||
| } | ||
| return resolveSymlinks(filepath.Clean(target)) |
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.

What this PR does:
Fixes
verifyHelmValueFilePathacrosspkg/app/pipedv1/plugin/kubernetes/provider/helm.go,pkg/app/pipedv1/plugin/kubernetes_multicluster/provider/helm.go, andpkg/app/piped/platformprovider/kubernetes/helm.goto:appDirandvalueFilePathwithfilepath.Absand verify containment withfilepath.Rel(isOutsideDir) rather thanstrings.HasPrefix, blocking uncleaned absolute paths (<appDir>/../../...) and sibling-directory prefix collisions (../<appDirName>-secrets/...).resolveSymlinkToAbsPathwithresolveSymlinks(usingfilepath.EvalSymlinks, plus relativeos.Readlinkresolution againstfilepath.Dir(path)for dangling symlinks and ancestor symlink resolution), blocking symlinked subdirectories, chained symlinks, and subdirectory relative symlinks escapingappDir.TestVerifyHelmValueFilePath_TraversalAndSymlinksand sibling-prefix testcase) across all threehelm_test.gofiles.Why we need it:
The previous
strings.HasPrefixand single-hopos.Lstatchecks could be bypassed using<appDir>/../../..., sibling directories sharingappDir's name prefix, symlinked subdirectories, or chained symlinks, allowing a Helm values file outsideappDirto pass verification.Which issue(s) this PR fixes:
Fixes #7683
Does this PR introduce a user-facing change?:
valueFilesreferencing paths outside the application directory via sibling-prefix paths, uncleaned absolute paths, or nested/chained symlinks are now properly rejected with an error. Valid paths and symlinks resolving insideappDirandhttp/httpsURLs continue to work as before.Screenshots/Videos (for documentation or website changes):
N/A (no documentation or website changes)