Impersonate only ACE extras#645
Open
ArnobKumarSaha wants to merge 1 commit into
Open
Conversation
DelegatingClient.Impersonate forwarded every extra key from the caller's identity. Impersonating an extra key requires an `impersonate` grant on userextras/<key>, so a caller carrying provider-injected extras -- Rancher's principalid/username, EKS' arn, the reserved authentication.kubernetes.io/* keys -- had the whole request denied during impersonation authorization. Keep only ace.appscode.com/* extras, which are the ones our components hold RBAC for and the only ones that carry meaning downstream. RBAC ignores extras, so dropping the rest changes no authorization decision on an ordinary cluster. Signed-off-by: Arnob Kumar Saha <arnob@appscode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DelegatingClient.Impersonateforwards every extra key from the caller's identity into the impersonation config (both the rest config and the impersonating round tripper).Kubernetes authorizes impersonated extras per key, as a subresource: impersonating extra key
krequiresimpersonateonuserextras/kinauthentication.k8s.io. Our components only hold that grant foruserextras/ace.appscode.com/org-id. So any caller arriving with provider-injected extras had the entire request denied in impersonation authorization (round 1), before the impersonated user's own RBAC was ever consulted.Real-world hit: a spoke cluster imported into ACE through Rancher. Rancher authenticates its own user and forwards
principalid,username,requesthost,requesttokenidas extras; none isace.appscode.com/org-id. Result:On Kubernetes 1.36 the same denial surfaces through the new constrained-impersonation path with a much more confusing message (
cannot impersonate-on:user-info:get resource "appreleases" ...). Granting the constrained verbs does not help: constrained impersonation additionally rejects extra keys that are not domain-prefixed, so bare keys likeprincipalidcan only ever go through the legacy path.Fix
Allowlist instead of pass-through: keep only
ace.appscode.com/*extras, drop the rest.Every platform invents its own extras — Rancher sends
principalid/username, EKS sendsarn/sessionName/principalId, OpenShift sendsscopes.authorization.openshift.io, and the apiserver itself addsauthentication.kubernetes.io/*. Chasing each of them with wider RBAC never converges; an allowlist is correct on any provider.Standard RBAC ignores extras entirely, so on an ordinary cluster this changes no authorization decision.
Compatibility note
This is a shared library, so the behavior change reaches every consumer of
Impersonate, not just the caller that hit the bug. A consumer running a custom authorization webhook that keys off provider extras would see different decisions, since those extras no longer reach the apiserver. I checkedkubeops.dev/ui-server; I have not audited the full consumer set — worth a second opinion from someone who knows whether any deployment relies on extras for authorization.Refs
staging/src/k8s.io/apiserver/pkg/endpoints/filters/impersonation/mode.go(authorizeExtra)