Skip to content

Remove wildcard permissions from knative-serving-core ClusterRole#16601

Closed
wiz-abhi wants to merge 1 commit into
knative:mainfrom
wiz-abhi:fix-clusterrole-wildcards
Closed

Remove wildcard permissions from knative-serving-core ClusterRole#16601
wiz-abhi wants to merge 1 commit into
knative:mainfrom
wiz-abhi:fix-clusterrole-wildcards

Conversation

@wiz-abhi
Copy link
Copy Markdown

@wiz-abhi wiz-abhi commented May 14, 2026

Fixes #16599

Proposed Changes

  • Replace * wildcards in knative-serving-core ClusterRole with explicit resource lists for Knative-owned API groups
  • Expand resources for serving.knative.dev, autoscaling.internal.knative.dev, and networking.internal.knative.dev apiGroups to include all CRDs and their /status and /finalizers subresources
  • Preserve apiGroups: ["*"] / resources: ["*/scale"] rule to maintain multi-type workload scaling support added in use the /scale subresource to when updating replica count #16540

Release Note

NONE

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 14, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: wiz-abhi / name: Wiz Abhi (b320fb2)

@knative-prow knative-prow Bot requested review from dsimansk and skonto May 14, 2026 20:22
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 14, 2026

Welcome @wiz-abhi! It looks like this is your first PR to knative/serving 🎉

@knative-prow knative-prow Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 14, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 14, 2026

Hi @wiz-abhi. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 14, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wiz-abhi
Once this PR has been reviewed and has the lgtm label, please assign dprotaso for approval. For more information see the Code Review Process.

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

@wiz-abhi wiz-abhi force-pushed the fix-clusterrole-wildcards branch from 7c9763a to b320fb2 Compare May 14, 2026 20:40
Comment thread config/core/200-roles/clusterrole.yaml Outdated
- apiGroups: ["*"]
resources: ["*/scale"]
- apiGroups: ["apps"]
resources: ["deployments/scale"]
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.

We recently allowed scaling other resources besides deployments that expose the scale API, see #16540

Considering this and that the proposed change above only changes permissions for knative's own CRDs I personally don't see a benefit in this change and don't consider this a security improvement.

Will need to wait for feedback from a maintainer though.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the review — good catch on #16540. You're absolutely right that changing apiGroups: [""] / resources: ["/scale"] to deployments/scale would regress the multi-type workload scaling support added there. I'll revert that part.
For the Knative-owned API groups, my intent was least-privilege hardening (avoiding * to prevent automatic access to future CRDs/subresources in those groups), but I agree the immediate practical security gain may be limited.
I'd like maintainer guidance on policy here:

  1. Keep wildcard for Knative API groups (lower maintenance), or
  2. Use explicit resource lists for stricter RBAC posture (with ongoing maintenance cost).
    I'm happy to align either way and update/close this PR accordingly.

@wiz-abhi wiz-abhi force-pushed the fix-clusterrole-wildcards branch from b320fb2 to 7e80dfa Compare May 15, 2026 10:42
Replace '*' wildcards in resources for Knative-owned API groups with explicit
resource lists to follow the principle of least privilege.

Changes:
- Expand resources for serving.knative.dev, autoscaling.internal.knative.dev,
  and networking.internal.knative.dev apiGroups to list all CRDs explicitly
  including their /status and /finalizers subresources.
- Preserve apiGroups: ['*'] / resources: ['*/scale'] to maintain multi-type
  workload scaling support added in knative#16540.

Fixes knative#16599
@linkvt
Copy link
Copy Markdown
Member

linkvt commented May 18, 2026

/ok-to-test

@knative-prow knative-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 18, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.24%. Comparing base (29a43b6) to head (0642739).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16601      +/-   ##
==========================================
- Coverage   80.25%   80.24%   -0.02%     
==========================================
  Files         217      217              
  Lines       13568    13568              
==========================================
- Hits        10889    10887       -2     
- Misses       2315     2317       +2     
  Partials      364      364              

☔ View full report in Codecov by Sentry.
📢 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.

verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
- apiGroups: ["serving.knative.dev", "autoscaling.internal.knative.dev", "networking.internal.knative.dev"]
resources: ["*", "*/status", "*/finalizers"]
resources: ["configurations", "configurations/status", "configurations/finalizers", "revisions", "revisions/status", "revisions/finalizers", "routes", "routes/status", "routes/finalizers", "services", "services/status", "services/finalizers", "domainmappings", "domainmappings/status", "domainmappings/finalizers", "metrics", "metrics/status", "metrics/finalizers", "podautoscalers", "podautoscalers/status", "podautoscalers/finalizers", "certificates", "certificates/status", "certificates/finalizers", "ingresses", "ingresses/status", "ingresses/finalizers", "serverlessservices", "serverlessservices/status", "serverlessservices/finalizers", "clusterdomainclaims", "clusterdomainclaims/status", "clusterdomainclaims/finalizers"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the listing is not driven by generator, but rather maintained by hand or LLM tool. We should keep wildcard for our own custom resources.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the clarification @dsimansk — that makes total sense. The explicit list would indeed require ongoing manual maintenance as CRDs evolve, and the practical security gain for Knative-owned API groups is minimal.

I'll close this PR. Appreciate the feedback from both you and @linkvt!

@wiz-abhi wiz-abhi closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClusterRole shouldnt use * wildcards in apiGroups, resources, or verbs

3 participants