Skip to content

Adjust deep SAR for SA#3867

Merged
kcp-ci-bot merged 1 commit intokcp-dev:mainfrom
mjudeikis:sar.sarring
Mar 2, 2026
Merged

Adjust deep SAR for SA#3867
kcp-ci-bot merged 1 commit intokcp-dev:mainfrom
mjudeikis:sar.sarring

Conversation

@mjudeikis
Copy link
Contributor

@mjudeikis mjudeikis commented Feb 27, 2026

Summary

fix: strip scopes from ServiceAccount tokens in maximal permission policy check

What Type of PR Is This?

/kind bug
Fix 403 Forbidden when ServiceAccount accesses claimed resources via APIExport virtual workspace
Strip scope-related Extra fields only for ServiceAccounts in maximal permission policy authorizer
Add e2e test to prevent regression

When an APIExport includes a permissionClaim on resources from another APIExport (e.g., tenancy.kcp.io/workspaces), and a consumer accepts that claim in an APIBinding, the provider's ServiceAccount receives a 403 Forbidden when accessing the claimed resources via the APIExport virtual workspace—even though it has proper apiexports/content RBAC.

Root Cause

ServiceAccount tokens are scoped to their originating workspace (e.g., cluster:root:org:provider). When accessing claimed resources, the maximal permission policy check runs in the workspace where the claimed APIExport lives (e.g., root for tenancy.kcp.io). The deep SubjectAccessReview fails because the SA token's scope doesn't include the target workspace.

Solution

Strip scope-related Extra fields (authentication.kcp.io/scopes and authentication.kcp.io/cluster-name) from ServiceAccounts only in prefixAttributes() before running the maximal permission policy check.

This is safe because:

  • BoundAPIAuthorizer already verified the request targets a valid bound resource
  • APIExportsContentAuthorizer already verified apiexports/content permission in the provider workspace
  • MaximalPermissionAuthorizer checks what the claimed APIExport allows—scope mismatch is a false negative here
  • Regular users are intentionally not affected—their scopes are preserved. This is the expected behavior since users may have scopes set via impersonation for security reasons.

Related Issue(s)

Fixes #3840

Release Notes

Strip scopes from ServiceAccount tokens in maximal permission policy check

@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 27, 2026
@mjudeikis
Copy link
Contributor Author

This is early, want to see how much of things breaks

@kcp-ci-bot kcp-ci-bot removed the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 27, 2026
@mjudeikis mjudeikis changed the title Adjust deep sar for SA Adjust deep SAR for SA Feb 27, 2026
@kcp-ci-bot kcp-ci-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 27, 2026
@mjudeikis
Copy link
Contributor Author

/retest

@kcp-ci-bot kcp-ci-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 2, 2026
@mjudeikis
Copy link
Contributor Author

/test all

Copy link
Member

@ntnn ntnn left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2026
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

DetailsGit tree hash: f16a182d2a34870ce542d2ca2f8acfa7626630fb

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ntnn

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:

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 2, 2026
@kcp-ci-bot kcp-ci-bot merged commit d5d4ce2 into kcp-dev:main Mar 2, 2026
14 checks passed
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. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: access denied for permissionClaim on tenancy.kcp.io resources

3 participants