Skip to content

[release-v0.37.x] fix(plugins): reject relative plugin dirs to prevent cwd fallback (CWE-426) - #3226

Merged
tekton-robot merged 1 commit into
tektoncd:release-v0.37.xfrom
divyansh42:fix/SRVKP-13570-release-v0.37.x
Sep 10, 2026
Merged

[release-v0.37.x] fix(plugins): reject relative plugin dirs to prevent cwd fallback (CWE-426)#3226
tekton-robot merged 1 commit into
tektoncd:release-v0.37.xfrom
divyansh42:fix/SRVKP-13570-release-v0.37.x

Conversation

@divyansh42

Copy link
Copy Markdown
Member

Changes

Backport of #3199 to release-v0.37.x.

FindPlugin() silently discarded the error from getPluginDir(). In minimal environments (scratch/distroless containers, Kubernetes pods running as arbitrary UIDs), all home-dir resolution fallbacks can fail, leaving dir as an empty string. filepath.Join("", "tkn-<arg>") then produces a relative path that syscall.Exec resolves against cwd — a classic untrusted search path (CWE-426).

Additionally, TKN_PLUGINS_DIR, XDG_CONFIG_HOME, and homedir.Expand (when $HOME is 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

  • Includes tests (if functionality changed/added)
  • Run the code checkers with make check
  • Regenerate the manpages, docs and go formatting with make generated
  • Commit messages follow commit message best practices

Release Notes

Fix untrusted search path (CWE-426): plugin discovery no longer falls back to the current working directory when home-dir resolution fails or when TKN_PLUGINS_DIR/XDG_CONFIG_HOME is set to a relative path.

…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>
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 9, 2026
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 9, 2026
@divyansh42 divyansh42 changed the title fix(plugins): reject relative plugin dirs to prevent cwd fallback (CWE-426) [release-v0.37.x] fix(plugins): reject relative plugin dirs to prevent cwd fallback (CWE-426) Sep 9, 2026
@divyansh42

Copy link
Copy Markdown
Member Author

/retest

@pratap0007

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 10, 2026
@tekton-robot

Copy link
Copy Markdown
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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2026
@tekton-robot
tekton-robot merged commit 972e5ed into tektoncd:release-v0.37.x Sep 10, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants