Skip to content

fix(rbac): harden ClusterRole to least-privilege - #391

Merged
tekton-robot merged 1 commit into
tektoncd:mainfrom
infernus01:fix/harden-clusterrole-rbac
Aug 21, 2026
Merged

fix(rbac): harden ClusterRole to least-privilege#391
tekton-robot merged 1 commit into
tektoncd:mainfrom
infernus01:fix/harden-clusterrole-rbac

Conversation

@infernus01

@infernus01 infernus01 commented Aug 19, 2026

Copy link
Copy Markdown
Member

Changes

The ClusterRole tekton-pruner-controller-cluster-access contained
Knative boilerplate RBAC rules that grant permissions the code never
uses. This tightens every rule to match actual runtime behavior:

  • Namespaces: full CRUD → get/list/watch only. The
    namespaces/finalizers rule is removed — no code path references
    namespace finalizers.
  • Webhook configurations: mutatingwebhookconfigurations removed
    entirely (no mutating webhook exists). validatingwebhookconfigurations
    scoped to resourceNames: [validation.webhook.pruner.tekton.dev]
    with only get and update (the two verbs used in
    pkg/webhook/configmapvalidation.go).
  • Secrets: cluster-wide get/list/watch removed. The namespaced
    Role in tekton-pipelines already grants secret access. The webhook's
    secret informer import is switched from the cluster-scoped factory
    (knative.dev/pkg/client/injection/kube/informers/core/v1/secret)
    to the namespace-scoped factory
    (knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret),
    which is the same one the certificate controller already uses.

Why

A compromised pruner pod could use these unused permissions to delete
arbitrary namespaces, read secrets from any namespace, or register
malicious mutating webhooks. These are hardening issues — not directly
exploitable without prior pod compromise — but reducing the blast
radius is standard least-privilege hygiene.

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

NONE

/kind misc

  Remove unused Knative boilerplate RBAC that granted permissions the
  controller and webhook never exercise, reducing post-compromise blast
  radius.

  - Namespace: reduce from full CRUD to get/list/watch; remove
    namespaces/finalizers (never referenced in code)
  - Webhook configs: remove mutatingwebhookconfigurations entirely
    (no mutating webhook exists); scope validatingwebhookconfigurations
    to resourceNames + get/update only
  - Secrets: remove cluster-wide get/list/watch (namespaced Role in
    tekton-pipelines already covers it); switch webhook secret informer
    from cluster-scoped to namespace-scoped import

Signed-off-by: Shubham Bhardwaj <shubbhar@redhat.com>
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 19, 2026
@infernus01

Copy link
Copy Markdown
Member Author

/kind security

@tekton-robot tekton-robot added the kind/security Categorizes issue or PR as related to a security issue label Aug 19, 2026
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@a94b31c). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #391   +/-   ##
=======================================
  Coverage        ?   50.28%           
=======================================
  Files           ?       19           
  Lines           ?     2118           
  Branches        ?        0           
=======================================
  Hits            ?     1065           
  Misses          ?      921           
  Partials        ?      132           
Flag Coverage Δ
unit-tests 50.28% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anithapriyanatarajan

Copy link
Copy Markdown
Contributor

/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 19, 2026

@vdemeester vdemeester left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

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

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: anithapriyanatarajan, vdemeester

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:
  • OWNERS [anithapriyanatarajan,vdemeester]

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 merged commit ed6a2c6 into tektoncd:main Aug 21, 2026
22 of 24 checks passed
@infernus01

Copy link
Copy Markdown
Member Author

/cherry-pick release-v0.4.x

@tekton-robot

Copy link
Copy Markdown

Cherry-pick to release-v0.4.x successful!

A new pull request has been created to cherry-pick this change to release-v0.4.x.

PR: #402

Please review and merge the cherry-pick PR.

@infernus01

Copy link
Copy Markdown
Member Author

/cherry-pick release-v0.3.x

@tekton-robot

Copy link
Copy Markdown

Cherry-pick to release-v0.3.x successful!

A new pull request has been created to cherry-pick this change to release-v0.3.x.

PR: #416

Please review and merge the cherry-pick PR.

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. kind/security Categorizes issue or PR as related to a security issue lgtm Indicates that a PR is ready to be merged. 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.

4 participants