Skip to content

Fix Helm values file path containment and symlink checks - #7684

Open
shellyco-code wants to merge 1 commit into
pipe-cd:masterfrom
shellyco-code:fix/helm-values-path-verification
Open

shellyco-code wants to merge 1 commit into
pipe-cd:masterfrom
shellyco-code:fix/helm-values-path-verification

Conversation

@shellyco-code

Copy link
Copy Markdown

What this PR does:

Fixes verifyHelmValueFilePath across pkg/app/pipedv1/plugin/kubernetes/provider/helm.go, pkg/app/pipedv1/plugin/kubernetes_multicluster/provider/helm.go, and pkg/app/piped/platformprovider/kubernetes/helm.go to:

  • Normalize appDir and valueFilePath with filepath.Abs and verify containment with filepath.Rel (isOutsideDir) rather than strings.HasPrefix, blocking uncleaned absolute paths (<appDir>/../../...) and sibling-directory prefix collisions (../<appDirName>-secrets/...).
  • Replace resolveSymlinkToAbsPath with resolveSymlinks (using filepath.EvalSymlinks, plus relative os.Readlink resolution against filepath.Dir(path) for dangling symlinks and ancestor symlink resolution), blocking symlinked subdirectories, chained symlinks, and subdirectory relative symlinks escaping appDir.
  • Add regression unit tests (TestVerifyHelmValueFilePath_TraversalAndSymlinks and sibling-prefix testcase) across all three helm_test.go files.

Why we need it:

The previous strings.HasPrefix and single-hop os.Lstat checks could be bypassed using <appDir>/../../..., sibling directories sharing appDir's name prefix, symlinked subdirectories, or chained symlinks, allowing a Helm values file outside appDir to pass verification.

Which issue(s) this PR fixes:

Fixes #7683

Does this PR introduce a user-facing change?:

  • How are users affected by this change: Helm valueFiles referencing 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 inside appDir and http/https URLs continue to work as before.
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Screenshots/Videos (for documentation or website changes):
N/A (no documentation or website changes)

Signed-off-by: shellyco-code <shellychahar57@gmail.com>
@shellyco-code
shellyco-code requested review from a team as code owners November 28, 2026 13:46
@shellyco-code
shellyco-code requested review from khanhtc1202, mohammedfirdouss and t-kikuc and a balanced review from Copilot November 28, 2026 13:46
@netlify

netlify Bot commented Nov 28, 2026

Copy link
Copy Markdown

👷 Deploy request for pipecd-site pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 0efeac4

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kubernetes: verifyHelmValueFilePath allows path traversal via sibling prefixes, uncleaned absolute paths, and symlinks

2 participants