[release-v0.37.x] fix(plugins): reject relative plugin dirs to prevent cwd fallback (CWE-426) - #3226
Merged
tekton-robot merged 1 commit intoSep 10, 2026
Conversation
…E-426)
FindPlugin() silently discarded the error from getPluginDir(), so when
$HOME was unresolvable in minimal environments (scratch containers, pods
running as arbitrary UIDs), filepath.Join("", "tkn-<arg>") produced a
relative path. syscall.Exec then resolved it against the current working
directory, allowing an attacker who controls cwd to execute an arbitrary
binary.
Additionally, TKN_PLUGINS_DIR and XDG_CONFIG_HOME were accepted even
when set to relative paths, and homedir.Expand accepted $HOME verbatim,
creating the same cwd-resolution risk. All three paths now validate that
the resolved plugin directory is absolute before use.
Fixes: SRVKP-13570
Signed-off-by: Divyanshu Agrawal <diagrawa@redhat.com>
Member
Author
|
/retest |
Contributor
|
/lgtm |
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pratap0007 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
tekton-robot
merged commit Sep 10, 2026
972e5ed
into
tektoncd:release-v0.37.x
18 of 20 checks passed
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.
Changes
Backport of #3199 to
release-v0.37.x.FindPlugin()silently discarded the error fromgetPluginDir(). In minimal environments (scratch/distroless containers, Kubernetes pods running as arbitrary UIDs), all home-dir resolution fallbacks can fail, leavingdiras an empty string.filepath.Join("", "tkn-<arg>")then produces a relative path thatsyscall.Execresolves against cwd — a classic untrusted search path (CWE-426).Additionally,
TKN_PLUGINS_DIR,XDG_CONFIG_HOME, andhomedir.Expand(when$HOMEis set to a relative value) could all yield relative paths without error.Fix:
getPluginDir()now validates that the resolved directory is absolute in all three code paths.FindPlugin()properly handles the error and skips the dir lookup instead of silently falling through.Fixes: SRVKP-13570
Submitter Checklist
make checkmake generatedRelease Notes