Skip to content

fix(pod): scope entrypoint cache by namespace and service account - #10685

Open
pujitha24 wants to merge 1 commit into
tektoncd:mainfrom
pujitha24:auto/issue-10633
Open

fix(pod): scope entrypoint cache by namespace and service account#10685
pujitha24 wants to merge 1 commit into
tektoncd:mainfrom
pujitha24:auto/issue-10633

Conversation

@pujitha24

Copy link
Copy Markdown

Changes

The entrypointCache in pkg/pod/entrypoint_lookup_impl.go is a global LRU
cache keyed only by image digest. Once an image's Entrypoint/Cmd is resolved
and cached using one namespace's pull credentials, any TaskRun in a
different namespace that references the same digest is served the cached
result without re-authenticating to the registry. A tenant that knows the
digest of another tenant's private image can learn its Entrypoint/Cmd this
way, without ever having pull credentials for that image. Only
Entrypoint/Cmd metadata is exposed; image layers, env vars, and filesystem
content are not affected.

This scopes the cache key to the namespace and service account name used to
resolve the image, in addition to the digest, so a cache entry is only
served to lookups made with the same credential context. This matches the
fix proposed in the linked issue. The trade-off is a lower cache hit rate in
single-tenant deployments (the same image may be resolved once per
namespace instead of once globally), which is acceptable given the small
cache size (1024 entries) and the correctness improvement.

Validation

  • go build ./...
  • go test ./pkg/pod/...
  • Added TestGetImageCacheScopedByNamespace, which populates the cache via
    an authenticated lookup in one namespace, then performs a lookup for the
    same digest from a second namespace with no pull credentials. Confirmed
    this test fails on the pre-fix code (the second lookup succeeds by
    reusing the first namespace's cached result) and passes after the fix
    (the second lookup fails with an authentication error, since it no
    longer hits the cache).
  • golangci-lint run ./pkg/pod/...: no new findings in the changed files.
  • go vet ./pkg/pod/... and gofmt -l on the changed files: clean.

Note: this repo's PR CI is gated behind Prow (ok-to-test) for
non-collaborators — happy to address anything it surfaces once triggered.

Fixes #10633

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Fix a bug where the entrypoint lookup cache could leak an image's Entrypoint/Cmd across namespaces: results cached using one namespace's pull credentials are no longer served to a different namespace/service account looking up the same image digest.

Motivation:
The entrypointCache in pkg/pod/entrypoint_lookup_impl.go is a global
LRU cache keyed only by image digest. Once an image's Entrypoint/Cmd
is resolved and cached using one namespace's pull credentials, any
TaskRun in a different namespace that references the same digest is
served the cached result without re-authenticating to the registry.
A tenant that knows the digest of another tenant's private image can
learn its Entrypoint/Cmd this way, without ever having pull
credentials for that image. Only Entrypoint/Cmd metadata is exposed;
image layers, env vars, and filesystem content are not affected.

Approach:
Scope the cache key to the namespace and service account name used to
resolve the image, in addition to the digest, so a cache entry is only
served to lookups made with the same credential context. This matches
the fix proposed in the issue. The trade-off is a lower cache hit rate
in single-tenant deployments (the same image may be resolved once per
namespace instead of once globally), which is acceptable given the
small cache size (1024 entries) and the correctness improvement.

Validation:
- go build ./...
- go test ./pkg/pod/...
- Added TestGetImageCacheScopedByNamespace, which populates the cache
  via an authenticated lookup in one namespace, then performs a lookup
  for the same digest from a second namespace with no pull
  credentials. Confirmed this test fails on the pre-fix code (the
  second lookup succeeds by reusing the first namespace's cached
  result) and passes after the fix (the second lookup fails with an
  authentication error, since it no longer hits the cache).
- golangci-lint run ./pkg/pod/...: no new findings in the changed
  files (pre-existing goconst/contextcheck findings in unrelated files
  in the package are untouched by this change).
- go vet ./pkg/pod/... and gofmt -l on the changed files: clean.

Report: tektoncd#10633
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5 (via Claude Code)
@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 1, 2026
@tekton-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign pritidesai after the PR has been reviewed.
You can assign the PR to them by writing /assign @pritidesai in a comment when ready.

The full list of commands accepted by this bot can be found 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Scope entrypointCache by namespace and service account to prevent cross-tenant metadata leaks

2 participants