fix(rbac): harden ClusterRole to least-privilege - #391
Conversation
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>
|
/kind security |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #391 +/- ##
=======================================
Coverage ? 50.28%
=======================================
Files ? 19
Lines ? 2118
Branches ? 0
=======================================
Hits ? 1065
Misses ? 921
Partials ? 132
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cherry-pick release-v0.4.x |
|
✅ Cherry-pick to A new pull request has been created to cherry-pick this change to PR: #402 Please review and merge the cherry-pick PR. |
|
/cherry-pick release-v0.3.x |
|
✅ Cherry-pick to A new pull request has been created to cherry-pick this change to PR: #416 Please review and merge the cherry-pick PR. |
Changes
The ClusterRole
tekton-pruner-controller-cluster-accesscontainedKnative boilerplate RBAC rules that grant permissions the code never
uses. This tightens every rule to match actual runtime behavior:
get/list/watchonly. Thenamespaces/finalizersrule is removed — no code path referencesnamespace finalizers.
mutatingwebhookconfigurationsremovedentirely (no mutating webhook exists).
validatingwebhookconfigurationsscoped to
resourceNames: [validation.webhook.pruner.tekton.dev]with only
getandupdate(the two verbs used inpkg/webhook/configmapvalidation.go).get/list/watchremoved. The namespacedRole in
tekton-pipelinesalready grants secret access. The webhook'ssecret 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:
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes
/kind misc