#57655·rancher

[BUG] Every stored user attribute is sent with the user's requests and copied to downstream clusters

Author: pmatseykanetsCreated Sep 30, 2026Updated Sep 30, 2026
Labelskind/bugarea/authenticationteam/collieQA/SM

Problem

1. Requests carry every stored attribute as user extras

Rancher defines two user extras: principalid and username. It still sends every attribute stored for the user's provider with each request, not just those two.

These extras become Impersonate-Extra-* headers and show up in audit logs. On downstream clusters, the impersonator account may only impersonate the defined extras. So a request with any other extra should fail with 403 there. We haven't reproduced that yet.

Today only SCIM stores other attributes, externalid and email. SCIM PUT and PATCH write them back after a user logs in, so those users are affected now. An attribute added by some future feature would be sent the same way.

In code:

  • getUserExtraInfo in pkg/auth/requests/authenticate.go returns everything in ExtraByProvider for the token's provider. For local tokens it combines all providers.
  • authHeaderHandler in pkg/auth/requests/filter.go turns each extra into an impersonation header.
  • The impersonator role in pkg/impersonation allows only principalid, username, requesttokenid and requesthost.
  • providers.IsValidUserExtraAttribute already lists the defined extras. The same filter uses it to drop extra headers sent by clients.

2. Downstream clusters store every stored attribute

Rancher keeps a ClusterUserAttribute for each user who has a cluster auth token on a downstream cluster (Authorized Cluster Endpoint). It copies all of the user's stored attributes into it, and admins of that cluster can read it.

Nothing downstream reads these attributes. kube-api-auth doesn't, and neither does Rancher.

The clusterauthtoken controller copies ExtraByProvider when it updates the object. It also compares it to decide whether an update is needed.

Solution

Only principalid and username should leave the UserAttribute:

  • getUserExtraInfo keeps only those keys, for provider tokens and for local tokens.
  • The clusterauthtoken controller uses the same keys for the copy and for the comparison. Filtering only the copy would make every sync see a difference and update again.

A feature that later needs another extra in requests should add it to the defined extras and to the impersonator role at the same time.

Acceptance

A user with stored attributes beyond principalid and username gets request extras with only those two, for a provider token and for a local token. No other Impersonate-Extra-* header is sent, and the audit log doesn't record the other attributes.

The user's ClusterUserAttribute holds only principalid and username. An existing one with other keys is updated once to remove them. After that, a change to other keys alone doesn't update it.

Unit tests cover these cases.