Skip to content

test(authorization): prove the webhook cannot bypass the authz gates - #4530

Closed
GUOZIJAN wants to merge 1 commit into
kcp-dev:mainfrom
GUOZIJAN:test/4512_webhook-gates-e2e
Closed

GUOZIJAN wants to merge 1 commit into
kcp-dev:mainfrom
GUOZIJAN:test/4512_webhook-gates-e2e

Conversation

@GUOZIJAN

Copy link
Copy Markdown

Note

Drafted with an AI coding assistant (ZCode) and reviewed before submitting.

TL;DR

  • Adds the e2e coverage requested in Add e2e tests for webhook grants passing through authz gates #4512 for the gate group of the restructured authorization chain: with kcp running an authorization webhook that is evaluated first and allows everything, the gates still deny what they should.
  • Covers the three scenarios from the issue: the required-groups gate denies a cluster-admin user lacking the annotated group (the same user impersonating the group passes), the system CRD gate denies apiexports/status and apibindings/status updates (creating those resources is not gated), and a webhook Deny short-circuits requests the gates would have allowed.
  • Reuses the webhook and server setup helpers from the authorization order tests (RunWebhook, setupTest) and the required-groups fixture (framework.WithRequiredGroups).

What I verified

  • The test package cross-compiles (GOOS=linux go build); I could not run kcp e2e locally on Windows, so CI is the gate here.
  • The scenarios mirror the gate semantics in pkg/authorization/requiredgroups_authorizer.go and pkg/authorization/system_crd_authorizer.go.

Resolves: #4512

The restructured authorization chain splits the authorizers into bypass,
grant and gate groups, but the only e2e coverage for the gates was the
maximal permission policy webhook escalation test. Add an e2e test that
runs kcp with an authorization webhook evaluated before the RBAC chain,
and shows that with the webhook allowing everything:

- the required-groups gate still denies users outside the annotated
  groups, while the same user impersonating the required group passes,
- the system CRD gate still denies APIExport and APIBinding status
  updates, although creating those resources is not gated,
- a webhook Deny short-circuits requests the gates would have allowed.

The gates are exercised through the same logical-cluster requests the
chain guards, reusing the webhook and server setup helpers from the
authorization order tests.

Refs: kcp-dev#4512
Signed-off-by: GUOZIJAN <GUOZIJAN@users.noreply.github.com>
@kcp-ci-bot

Copy link
Copy Markdown
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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.

@kcp-ci-bot kcp-ci-bot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. dco-signoff: yes Indicates the PR's author has signed the DCO. labels Oct 30, 2026
@kcp-ci-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign gman0 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

@kcp-ci-bot kcp-ci-bot added do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 30, 2026
@kcp-ci-bot

Copy link
Copy Markdown
Contributor

Hi @GUOZIJAN. Thanks for your PR.

I'm waiting for a kcp-dev 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.

// The webhook is evaluated before the RBAC chain, so with the webhook
// allowing everything, the gates are the only remaining thing that can
// deny a request.
srv, kcpClusterClient, kubeClusterClient := setupTest(t, "Webhook,AlwaysAllowGroups,AlwaysAllowPaths,RBAC", webhookCAFile, webhookPort)

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.

I think after recent changes in authz changes this now need to change. See #4507

@mjudeikis

Copy link
Copy Markdown
Contributor

Once adjusted, please from draft. Moving to draft to keep track of ready to merge and not yet prs ;)
Thanks for this :)

@mjudeikis
mjudeikis marked this pull request as draft November 3, 2026 12:09
@kcp-ci-bot kcp-ci-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 3, 2026
@GUOZIJAN

GUOZIJAN commented Nov 4, 2026

Copy link
Copy Markdown
Author

Closing this — #4517 landed the same e2e coverage (required-groups gate, the system CRD gate on apiexports/apibindings status, and webhook Deny short-circuit) while this PR was in draft, and issue #4512 is now closed as completed. Thanks @souvik-biswas-dev for the thorough tests, and @mjudeikis for the quick turnaround on the review.

@GUOZIJAN GUOZIJAN closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add e2e tests for webhook grants passing through authz gates

3 participants