Prevent path traversal in git resolver pathInRepo parameter

fix: prevent path traversal in git resolver pathInRepo parameter
Prevent path traversal in git resolver pathInRepo parameter3ca7bc-fix-prevent-path-traversal-in-git-resolver-cve-2026-33211fixprevent path traversal git resolver pathinrepo

Committed by vdemeester

commit message
fix: prevent path traversal in git resolver pathInRepo parameter

The git resolver's pathInRepo parameter was not validated for path
traversal, allowing a tenant to read arbitrary files from the resolver
pod's filesystem by supplying paths like '../../../../etc/passwd' or
'../../../../var/run/secrets/kubernetes.io/serviceaccount/token'.
 
The resolved file contents were then written into
resolutionrequest.status.data (base64-encoded), creating an
exfiltration channel. Since the resolver pod's ServiceAccount typically
has broad RBAC permissions (including read access to secrets), this
could lead to full privilege escalation.
 
The fix adds two layers of defense:
 
1. Validate pathInRepo in PopulateDefaultParams() to reject paths
   containing '..' components. Leading slashes are stripped for
   backwards compatibility (filepath.Join already handles them safely).
 
2. Switch getFileContent() to use 'git show HEAD:<path>' to read files
   from git's object store instead of os.ReadFile from the filesystem.
   Symlinks are resolved via filepath.EvalSymlinks before computing the
   relative path for git show, so in-repo symlinks work correctly while
   escape symlinks produce paths that git show rejects.
 
Unit and e2e regression tests are added for traversal patterns,
symlink escapes, and valid leading-slash paths.
 
The vulnerability was introduced in commit 318006c4e3a5 when the git
resolver switched from go-git's in-memory filesystem (memfs) to
shelling out to git and reading files with os.ReadFile(). All releases
from v1.0.0 through v1.10.0 are affected.
 
Fixes: GHSA-j5q5-j9gm-2w5c

Editor assessment

This commit patches CVE-2026-33211. The strength is the causal chain the body lays out: an unvalidated pathInRepo lets a tenant read resolver-pod files, those bytes land base64-encoded in resolutionrequest status as an exfiltration channel, and the resolver's broad service-account RBAC turns that into privilege escalation. The fix section is equally concrete - reject dot-dot components in PopulateDefaultParams, then stop reading the live filesystem and use git show against the object store with symlink resolution so escape symlinks fail. Regression coverage for traversal, symlink escapes and the tolerated leading-slash case is stated. The introducing commit, affected version window and advisory footer make this a model security message.

Browse categories

More fix examples · Back to search