Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extend profile AuthorizationPolicy for KServe models #6627

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

surajkota
Copy link
Contributor

@surajkota surajkota commented Aug 25, 2022

Workaround for: kubeflow/dashboard#13, kserve/kserve#1558

KServe integration with profiles is not complete. Users can create an inferenceservice but cannot use them(i.e. get prediction requests served) from inside or outside the cluster without doing one of the following(according to kserve/kserve#1558):

  • User either needs to disable istio injection
  • or apply an Authorization policy with the paths in this PR.

This PR automates the generation of the required authorization policy in profile namespace but this also means that a user can get data from these paths from other user namespaces.

@kimwnasptd @yuzisun Question: Can we add these paths to profile's authorization policy and call out the limitation with multi user isolation in docs until kserve/kserve#1371 is resolved? Note: profile namespaces already allow querying /healthz, /metrics and /wait-for-drain paths.
Current multi user isolation limitations are listed here: https://www.kubeflow.org/docs/components/pipelines/overview/multi-user/#current-limitations

Testing:

  1. Created an isvc https://github.com/kserve/kserve/blob/release-0.7/docs/samples/v1beta1/sklearn/v2/sklearn.yaml in a profile namespace (kserve-profile)
  2. Tried sending request from inside and outside the cluster as a user who owns the profile(kserve-profile) - Succeeded
  3. Tried sending request from inside and outside the cluster as a user of a different profile - Also, Succeeded

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AlexandreBrown
Once this PR has been reviewed and has the lgtm label, please assign elikatsis for approval by writing /assign @elikatsis in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

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

@juliusvonkohout
Copy link
Member

You should rather work on the proper upstream issue to solve this once and for all. I prefer security by default such that the user has to explictly disable the security. Also hardening via #6013 is worth a look

There are three possibilities until the upstream stuff is properly fixed

  1. Add an authorization policy to your own namespace. We can do this with a kyverno policy or wait for the pull request to be merged. Please note that with sidecar.istio.io/inject: "true" you have to be on a pod that has istio enabled - for example a jupyterlab inside your namespace - to access the prediction service.
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: allow-in-cluster-kserve
spec:
  rules:
    - to:
        - operation:
            paths:
              - /v1/models/*
              - /v2/models/*
  1. Disable the istio sidecar in your yaml that is responsible for authentication and live with the security implications
  2. Use a path based virtual service with dex and full authentication

All three of them can be implemented with simple kyverno clusterpolicies if you want to have them by default. So i favor not merging this and putting more pressure on upstream.

@@ -442,6 +442,9 @@ func (r *ProfileReconciler) getAuthorizationPolicy(profileIns *profilev1.Profile
"/healthz",
"/metrics",
"/wait-for-drain",
"/ready",
"/v1/models/*",
Copy link
Member

@yuzisun yuzisun Nov 25, 2022

Choose a reason for hiding this comment

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

@surajkota allowing paths does not lock down the traffic from other namespaces. I think we still want the changes in https://github.com/kubeflow/kubeflow/pull/6013/files for only allowing requests from knative-serving namespace and in addition we need to lock down the original namespace of the request, unfortunately I couldn't find a header to check the original namespace when the requests are proxyed by activator.

Choose a reason for hiding this comment

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

Maybe we should rely on kubeflow-userid header?

@yuzisun
Copy link
Member

yuzisun commented Feb 4, 2023

@surajkota What's the plan for this PR?

@thesuperzapper
Copy link
Member

We need to update/replace this PR with one that has a dynamic principal (so we don't assume the ServiceAccount or Namespace of the KServe), for example, this PR did it for Notebooks/Pipelines: #7310

NOTE: this version of the PR does not actually restrict by source principal (but it should), see the original one for more context: #6013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants