Skip to content

Proposal: Authentication and Authorization support for Tiller #1918

Closed

Description

@tamalsaha

Goal

For Tiller to execute all of its API operations "as" the user. So that (a) Tiller is not a "superuser" and (b) users' own ids, etc. are attached to operations.

Architecture

The general idea is Helm cli will forward user’s auth info from kubeconfig to Tiller gRPC server via HTTP Header. Tiller gRPC server will call various Kubernetes authN/Z apis to perform authentication and authorization in an intercepter before applying mutation. The following diagram shows the flow:

tiller-auth-flow

Kube Client Authentication

The TokenReview api call will be made using default service account. This is required, since if RBAC authorization is enabled in the cluster, user may not have permission to perform TokenRview api.

All other kube api calls (including SubjectReview api) will be made using user’s auth info.

User info

  • Client Certs: If a client certificate is presented and verified, the common name of the subject is used as the user name for the request.
  • Basic Auth: Username found in the Authorization header.
  • Bearer Token: Tiller calls TokenReview api with the bearer token found in the authorization header. In response, Kube api server returns username and list of groups for the user associated with the token.

Anonymous requests

From Kubernetes docs, "When enabled, requests that are not rejected by other configured authentication methods are treated as anonymous requests, and given a username of system:anonymous and a group of system:unauthenticated." I propose that Tiller does not support anonymous requests.

Choice of Header Keys

The following keys (case-sensitive) will be used in golang context to forward auth info from kubeconfig to gRPC server:

  • authorization: This will be available as This is the standard authorization header to pass username:password or bearer token.
  • k8s-server: This is the server field in kubeconfig.
  • k8s-certificate-authority: This is the CA certificate used by kubernetes api server.
  • k8s-client-certificate: This is the user’s client certificate.
  • k8s-client-key: This is the user’s client key.

HTTP protocol itself has no limit on header length. So, forwarding the above fields should be ok.

Discovering Tiller Server

We would like to support running Tiller in Standalone mode or Hosted mode. In Standalone mode, Tiller manages the cluster it is running on. This is the current setup. In Hosted mode, Tiller will be run outside the cluster that it manages. To support auto discovery of Tiller server address, we propose the following change:

If tillerHost is empty, first search for a service named “{"app": "helm", "name": "tiller"}” in default tiller namespace (kube-system). If found, use the externalName in the service to connect to an externally Hosted Tiller server. If not found, then use the existing port forwarding mechanism to connect to cluster.

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "my-service",
        "namespace": "prod"
    },
    "spec": {
        "type": "ExternalName",
        "externalName": "my.tiller.example.com"
    }
}

Misc Considerations

JSON API

If users are interested in accessing the Tiller api from a web page, they have to run gRPC Gateway to provide a JSON api.

Release Authorization

An additional layer of authorization may be added to Tiller gRPC server using a Third Party Resource called Release. Cluster admins can configure RBAC authorization for the Release resource. Tiller api server will perform an extra SubjectReview call to check if the user has permission to release a chart:

{
  "apiVersion": "authorization.k8s.io/v1beta1",
  "kind": "SubjectAccessReview",
  "spec": {
    "resourceAttributes": {
      "namespace": "kittensandponies",
      "verb": "POST",
      "group": "helm.sh",
      "resource": "release"
    },
    "user": "jane",
    "group": [
      "group1",
      "group2"
    ]
  }
}

This can be added later, once the initial above proposal is implemented.

Storing Release Data

  • Standalone mode: Currently Tiller stores data in configmaps. I think we should store release data in a TPR to avoid confusion. The Release object used for authorization can also be used for storing release data. This is also inline with discussions on api extension.

  • Hosted mode: A Storage Driver can be implemented to store data in conventional databases like Postgres, etc. It should be very easy for implement this using existing Driver interface.

Both of these options can be implemented after the initial auth flow is implemented.

Third Party Controller

A TillerC TPR controller was designed, prototyped and ultimately abandoned because Kubernetes authZ process can’t extended to fit Tiller’s authorization requirements.

Activity

  1. changed the title [-]Proposal: Authenticator and Authorization support for Tiller[/-] [+]Proposal: Authentication and Authorization support for Tiller[/+] on Feb 6, 2017
  2. technosophos commented on Feb 8, 2017

    @technosophos
    Member

    I very much like this proposal.

    I would imagine doing this as four separate PRs:

    • Adding the authentication mechanisms
    • Adding the SubjectReview
    • "Discovering Tiller Server" (could be done any time)
    • Adding the TPR for release (possibly delayed a bit)

    Okay, a few other comments:

    • For the "Discovering Tiller Server" feature, we could also look into storing config data in a flat file in $HELM_HOME, if that closer hits the intended use case.
    • I totally agree on disallowing anonymous requests
    • I would prefer delaying the Release TPR until TPR comes out of Beta (or at least until TPRs can actually be updated). The system keeps changing, and that would add a big backwards compatibility burden.
    • What are the backward compatibility issues that we might hit by introducing authentication?
  3. tamalsaha commented on Feb 9, 2017

    @tamalsaha
    ContributorAuthor

    For the "Discovering Tiller Server" feature, we could also look into storing config data in a flat file in $HELM_HOME, if that closer hits the intended use case.

    I think supporting it via a service in Kube will be better because, users don't need to worry about one more extra config.

    I would prefer delaying the Release TPR until TPR comes out of Beta (or at least until TPRs can actually be updated). The system keeps changing, and that would add a big backwards compatibility burden.

    I think there is a "security" benefit of using TPR. As things work today, it is possible for someone to overwrite coinfigmaps and then rollback to deploy a bad version. With TPR, cluster admins can restrict regular users from writing Tiller TPR but allow them to edit configmaps. But these can be done as step 2.

    What are the backward compatibility issues that we might hit by introducing authentication?
    I don't see how to pass the modified ctx to StreamHandler, which is used for ListRelease api.

    One thing, that is not discussed so far is how to store the user info. I was thinking about storing that as a Label in the configmap and them display it. This will also require adding username field to proto.

  4. technosophos commented on Feb 10, 2017

    @technosophos
    Member

    Just want to record that I have been getting a lot of supportive feedback in Slack and in other places about this particular feature as defined here. This is something a wide variety of users are asking for in the 2.3.0 release.

  5. added this to the 2.3.0 milestone on Feb 14, 2017
  6. technosophos commented on Feb 14, 2017

    @technosophos
    Member

    I've added this to the 2.3 milestone. @tamalsaha I am assuming this is a feature you are planning on leading.

  7. smarterclayton commented on Feb 15, 2017

    @smarterclayton

    Are you expecting tiller to have a different set of client certificates than the kubernetes master? Or the same?

    In this case tiller is acting as an authenticating proxy - would be good to make sure we have a checklist for the sorts of things that are "safe" and are audited. Such as never storing the token, never writing it to logs, etc. Some of the bearer tokens will be very powerful (cluster-admin or highly privileged users).

  8. smarterclayton commented on Feb 15, 2017

    @smarterclayton

    If you have the user's token, why do you need to do SubjectAccessReview for mutations? The Kube APIs will already do that.

    @liggitt re: use of impersonation or not.

  9. tamalsaha commented on Feb 15, 2017

    @tamalsaha
    ContributorAuthor

    Are you expecting tiller to have a different set of client certificates than the kubernetes master? Or the same?

    I am expecting them to be same.

    In this case tiller is acting as an authenticating proxy - would be good to make sure we have a checklist for the sorts of things that are "safe" and are audited. Such as never storing the token, never writing it to logs, etc. Some of the bearer tokens will be very powerful (cluster-admin or highly privileged users).

    Sounds great!

    If you have the user's token, why do you need to do SubjectAccessReview for mutations? The Kube APIs will already do that.

    Calling SubjectAccessReview before doing any mutation will avoid failing in the middle of a release. Also, if TPRs are used to store Release data (instead of configmaps), I think SubjectAccessReview will be needed to enforce authZ.

  10. technosophos commented on Feb 16, 2017

    @technosophos
    Member

    Assigned this to @tamalsaha as the feature owner.

  11. liggitt commented on Feb 17, 2017

    @liggitt

    Calling SubjectAccessReview before doing any mutation will avoid failing in the middle of a release

    Not necessarily, there are plenty of other reasons requests could fail. You need to handle partial success already.

  12. tamalsaha commented on Feb 17, 2017

    @tamalsaha
    ContributorAuthor

    Not necessarily, there are plenty of other reasons requests could fail. You need to handle partial success already.

    Yes. Even the diff computation can fail. Is there any technical reason to avoid SubjectReview calls if possible (say, too much traffic for apiserver, etc.)?

  13. liggitt commented on Feb 19, 2017

    @liggitt

    Basic Auth: Username found in the Authorization header.

    can't assume the login name is identical to the authenticated username. some auth systems allow multiple logins (bob, BOB, bob@domain) to map to a single username. Also, to impersonate, you need to obtain and impersonate all the user info: username, group membership, and "extra" data (could hold scope info, other info used by the authorizer, etc). I'm not sure how you plan to obtain that info from basic auth credentials.

    k8s-client-key: This is the user’s client key.

    is this proposing sending the content of the private key to the server so the server can replay as the user?

    One thing, that is not discussed so far is how to store the user info. I was thinking about storing that as a Label in the configmap and them display it.

    Is this referring to storing the resolved user information (username, groups, extra data, etc) or the user credentials themselves?

    User info (especially if used for replay) should only be stored in a way that guarantees its integrity. Some ways to do that are:

    1. not allow API write access to the fields storing the info, but make the server responsible for stomping the data based on the authenticated user (not possible to change the configmap REST handler to do that)
    2. include additional information that can be used to verify the integrity of the data (e.g. a peer HMAC in the configmap that can be verified using privately held keys)

    I think user info stored in mutable API fields is likely to be used without proper verification, allowing someone to modify it and perform escalation attacks.

    This will also require adding username field to proto.

    All aspects of the user info - username, groups, and "extra" fields (see the SubjectAccessReview API)

  14. 34 remaining items

  15. mumoshu commented on Jan 10, 2018

    @mumoshu
    Contributor

    @seh @technosophos Hi! Although it ended up as an unideal solution, please let me 👍 to the one involving impersonation, and highlight this part of the discussion:

    Tiller would take on the same authentication burden as the API server, including calling out to servers for Webhook token reviews and fetching fresh OIDC key sets.

    I'm not really clear about that but isn't it apiserver but not tiller who calls out to a webhook token authnz server for a token review?

    If that's the case, I suppose what Tiller would do given an user's brearer token is only to populate ImpersonateConfig which is then passed to kubernetes/client-go for impersonation?

    Anyway, the webook token review thing would be beneficial for me.

    The context is that I'm relying on heptio/authenticator which is a webhook token authentication server who validates a user-provided bearer-token with AWS IAM, so that any IAM user with an appropriate IAM role can authenticate against K8S API.

    If Tiller supported impersonation with an user-provided bearer token (perhaps via something like helm apply -f ... --token $mybearertoken?) while supporting Webhook token authn, we can completely freed from managing PKI for securing helm<->tiller communication. This is a huge win from a perspective of a cluster admin.

    Thanks!

    Edit 1: Sorry but I had misunderstood how impersonation in k8s works. For impersonation, we have to allow Tiller to impersonate any user/group/etc w/ RBAC. That would be too much permission plus it doesn't involve the user's bearer-token at all :) "Impersonation" in this case should be done by Tiller just replays an user-provided bearer token, instead of utilizing k8s's impersonation mechanism.

    Edit 2: RBAC does seem to allow restricting who can impersonate as who:

  16. whereisaaron commented on Jan 11, 2018

    @whereisaaron
    Contributor

    OT: Interesting @mumoshu! There are quite few moving parts to configuring heptio/authenticator, are you able to deploy it with just a kube-aws cluster.yaml? (If so I'd love to see an example!) Or do you need extra steps?

  17. mumoshu commented on Jan 15, 2018

    @mumoshu
    Contributor

    Hi @whereisaaron Yes, it is definitely possible. I'll share it once ready 👍

  18. mumoshu commented on Jan 15, 2018

    @mumoshu
    Contributor

    For anyone interested, I'm working on my POC to delegate authn/authz w/ k8s RBAC via tokens to kube-rbac-proxy.

    How it works

    • The modified version of helm assumes you to rely on a token saved in your kubeconfig to authenticate against k8s api. Then, helm with --experimenta-rbac-proxy reads the token from kubeconfig, passes it along with a tiller gRPC call(inside metadata i.e. http/2 request header).

    • kube-rbac-proxy calls SubjectAccessReviews K8S API to authn with the token, authz with the "resource attributes" specified to kube-rbac-proxy.

    • Once the authn/authz passes on kube-rbac-proxy, it modifies the original http/2 request to include x-forwarded-user and x-forwarded-groups to be used by tiller.

    • tiller with --experimental-rbac-proxy then trusts the forwarded header so that it allows the access to the requested tiller API.

    Note that you MUST protect your tiller container from anything other than accesses from the kube-rbac-proxy sidecar for now. kubectl-exec into the tiller should be prohibited, kubectl-port-forward to the tiller grpc port should be prohibited, etc.

    If I could manage to add tls support for the kube-rbac-proxy mode, perhaps all of the above operations but kubectl-exec could be permitted?

    I'm not really an expert in this area but am willing to learn. Please let me know anything you have in mind about this!

    Thanks.

  19. mumoshu commented on Jan 16, 2018

    @mumoshu
    Contributor

    I've put some time to investigate possibility to support impersonation for tiller via the x-forwarded-user and/or x-forwarded-groups.

    I had wanted tiller --experimental-impersonate-user --experimental-rbac-proxy to pass the value in x-forwarded-user to helm's local release module so that the release module could configure k8s api client to use an ImpersonateConfig which includes the passed username.

    This results in following changes to current code-base. Would it be an acceptable change to helm/tiller?

    • Add the flag to Tiller for enabling the impersonation feature.
    • Add fields for impersonation(user, groups) to Release
      • ReleaseServer receives parameters for a specific release via Release.
      • Unfortunately, it doesn't allow including arbitrary key-value pairs which may include the value of x-forwarded-(user|groups) so we need to add the fields to it.
    • Improve ReleaseServer to pass an one-time k8s client-go instance which has specific impersonation config
      • ReleaseServer as of today has a single env which contains a k8s api client used from everywhere in tiller.
      • We need a different, separate k8s api client with appropriate ImpersonateConfig per the authenticated user who requested the operation on a release

    TBD;

    • How should we support RemoteReleaseModules?
  20. fejta-bot commented on Feb 15, 2018

    @fejta-bot

    Stale issues rot after 30d of inactivity.
    Mark the issue as fresh with /remove-lifecycle rotten.
    Rotten issues close after an additional 30d of inactivity.

    If this issue is safe to close now please do so with /close.

    Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
    /lifecycle rotten
    /remove-lifecycle stale

  21. whereisaaron commented on Feb 17, 2018

    @whereisaaron
    Contributor

    /remove-lifecycle stale

    This is still an important feature that should be considered for 3.x if an implementation can be identified. It would be good to get feedback on @mumoshu's excellent work on this.

  22. whereisaaron commented on Feb 17, 2018

    @whereisaaron
    Contributor

    /remove-lifecycle rotten

  23. docwhat commented on Apr 4, 2018

    @docwhat

    Is there something I could do to make this happen?

  24. bacongobbler commented on Apr 4, 2018

    @bacongobbler
    Member

    @docwhat there has been discussion in the community around this topic, and the general consensus is to close this in favour of the Helm 3 proposal around its Security Considerations. We plan on moving Helm towards a client-only model, which means that a helm install acts on behalf of the user that invoked helm rather than having to impersonate the user when tiller is deploying the chart. This model is identical to kubectl's current security model so it makes for a better fit overall in the ecosystem. No extra work to provide user impersonation would be required.

    Given that the general consensus is to move forward with the proposal in https://github.com/kubernetes-helm/community, I feel this is safe to close out this one as superseded by the Helm 3 proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions