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

Make principals dynamic in Profiles Controller #7310

Conversation

kimwnasptd
Copy link
Member

This is a follow-up to address #7032 (comment)

This PR will make all principals in Profile Controller configurable, so they should be changed from any distribution that deploys the components in different namespaces.

/cc @thesuperzapper

@kimwnasptd kimwnasptd force-pushed the feature-kimwnasptd-dynamic-sa-profiles branch from dd33303 to 332626c Compare October 3, 2023 16:44
@thesuperzapper
Copy link
Member

@kimwnasptd we also need to add a new principal KFP_UI_PRINCIPAL (or PIPELINE_UI_PRINCIPAL) with the default value of cluster.local/ns/kubeflow/sa/ml-pipeline-ui

This is required for the ml-pipeline-ui in the kubeflow namespace to redirect the user's queries to ml-pipeline-ui-artifact in the profile namespaces.

@thesuperzapper
Copy link
Member

thesuperzapper commented Oct 3, 2023

You also need to do the KFAM ones (with all the same changes):

func getAuthorizationPolicy(binding *Binding, userIdHeader string, userIdPrefix string) istioSecurity.AuthorizationPolicy {
return istioSecurity.AuthorizationPolicy{
Rules: []*istioSecurity.Rule{
{
When: []*istioSecurity.Condition{
{
Key: fmt.Sprintf("request.headers[%v]", userIdHeader),
Values: []string{
userIdPrefix + binding.User.Name,
},
},
},
From: []*istioSecurity.Rule_From{{
Source: &istioSecurity.Source{
Principals: []string{
"cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account",
},
},
}},
},
},
}
}

As these were changed in #7032 also.

@thesuperzapper
Copy link
Member

Also, let's include the default env-var configs of the environment variables in the manifests (to help distros see this change):

We can add them to this ConfigMap, as it sets the environment for profile-controller AND kfam:

configMapGenerator:
- literals:
- ADMIN=
- WORKLOAD_IDENTITY=
- USERID_HEADER="kubeflow-userid"
- USERID_PREFIX=

@kimwnasptd
Copy link
Member Author

@kimwnasptd we also need to add a new principal KFP_UI_PRINCIPAL (or PIPELINE_UI_PRINCIPAL) with the default value of cluster.local/ns/kubeflow/sa/ml-pipeline-ui

This is required for the ml-pipeline-ui in the kubeflow namespace to redirect the user's queries to ml-pipeline-ui-artifact in the profile namespaces.

@thesuperzapper could you add some more context for this?

@kimwnasptd
Copy link
Member Author

kimwnasptd commented Oct 9, 2023

You also need to do the KFAM ones (with all the same changes):

@thesuperzapper why (I'm having the KFP change in mind)? Isn't the Create function of KFAM used when we want to create "bindings" for a new contributor in the namespace? In this case we only care about allowing requests from IGW to the Pods of the namespace that have that user header.

The other rules (like allowing requests from the the Notebook controller) should already exist from the AuthorizationPolicy created by the Profile Controller.

ACK on making the principal configurable in KFAM for the Istio ingressgateway though. Having in mind above the rest of the changes, in case you meant we would need to bring more changes in KFAM

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
@kimwnasptd kimwnasptd force-pushed the feature-kimwnasptd-dynamic-sa-profiles branch from 332626c to 9790f97 Compare October 9, 2023 16:20
@google-oss-prow google-oss-prow bot added size/M and removed size/S labels Oct 9, 2023
@thesuperzapper
Copy link
Member

You also need to do the KFAM ones (with all the same changes):

@thesuperzapper why (I'm having the KFP change in mind)? Isn't the Create function of KFAM used when we want to create "bindings" for a new contributor in the namespace? In this case we only care about allowing requests from IGW to the Pods of the namespace that have that user header.

The other rules (like allowing requests from the the Notebook controller) should already exist from the AuthorizationPolicy created by the Profile Controller.

ACK on making the principal configurable in KFAM for the Istio ingressgateway though. Having in mind above the rest of the changes, in case you meant we would need to bring more changes in KFAM

@kimwnasptd I was referring to the KFP principal I raised in #7310 (comment), which needs to be created for BOTH non-owners (created by KFAM) and the owners (created by profile controller).

This is required for KFP to work correctly (specifically for the "view output artifacts" feature of the pipeline's UI).

This is because, internally, the ml-pipeline-ui pods (in the kubeflow namespace) proxy the user "artifact view" requests to the ml-pipeline-ui-artifact pods (in each profile namespace), directly using the Service/ml-pipeline-ui-artifact (not via the istio gateway).

This is what allows each namespace to have different levels of access to the S3 bucket (and probably a few other things I am missing too).

@kimwnasptd
Copy link
Member Author

Thanks for the explanation! I'll modify the code and try to play around with this to make sure I'm fully in sync.

In the mean time though, @zijianjoy could you give us your feedback as well? The context is:

  1. We had made it more strict, in AuthorizationPolicy of each Profile, to allow requests only from Istio's ingressgateway to user namespace
  2. Looks like there's a communication from KFP UI pod to the proxy pods in each user namespace

Is there something else we need to consider here? Also if you'd have any pointers for this architecture they would be more than welcome 😄

@kimwnasptd
Copy link
Member Author

So indeed, after playing around with the latest 1.8 RC I'm getting 403 errors in the Input/Output tabs of a KFP Run when it

  1. tries to preview the contents of the artifacts
  2. download the artifacts

After applying the following AuthorizationPolicy, in the user namespace, it worked

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: kfp
spec:
  rules:
  - from:
    - source:
        principals:
        - cluster.local/ns/kubeflow/sa/ml-pipeline-ui

But this actually raises a question. Should the profile controller be responsible for this or the existing kfp-profiles-controller (Metacontroller) that already creates the AuthorizationPolicy for the visualization server?
https://github.com/kubeflow/pipelines/blob/master/manifests/kustomize/base/installs/multi-user/pipelines-profile-controller/sync.py#L226-L246

cc @zijianjoy

@thesuperzapper
Copy link
Member

thesuperzapper commented Oct 9, 2023

@kimwnasptd my thoughts are that I don't any straightforward way to use the kubeflow-pipelines-profile-controller to do this because only KFAM knows when its API to "add/remove" collaborators is called.

And for the profile owner bindings, we already the profile-controller creating the Notebooks UI AuthorizaitonPolicy (for the last activity field), so I don't see a harm with adding a pipeline-specific one either.

Finally, I want to reduce the size of the kubeflow-pipelines-profile-controller, not increase it.


Also, the policy needs to require the kubeflow-userid header to be set, which to ensure only users with access are allowed to "proxy" their requests into another namespace.

So we can just put it under the existing rule we are generating to give the user access from the gateway.

For example:

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: user-user1-example-com-clusterrole-edit
  namespace: PROFILE_NAME
  annotations:
    role: edit
    user: "user1@example.com"
spec:                                                                                                                                                                      
  rules:                                                                                                                                                                   
  - from:                                                                                                                                                                  
    - source:                                                                                                                                                              
        principals:                                                                                                                                                        
        - cluster.local/ns/deploykf-istio-gateway/sa/deploykf-gateway                                                                                                      
        - cluster.local/ns/kubeflow/sa/ml-pipeline-ui                                                                                                                      
    when:                                                                                                                                                                  
    - key: request.headers[kubeflow-userid]                                                                                                                                
      values:                                                                                                                                                              
      - user1@example.com

Where:

  • kubeflow-userid is set to the value of USERID_HEADER env-var
  • user2@example.com is set to the users email
  • cluster.local/ns/kubeflow/sa/ml-pipeline-ui is set to the value of PIPELINE_UI_PRINCIPAL env-var
  • cluster.local/ns/deploykf-istio-gateway/sa/deploykf-gateway is set to the value of ISTIO_INGRESS_GATEWAY_PRINCIPAL env-var

@kimwnasptd
Copy link
Member Author

kimwnasptd commented Oct 10, 2023

Finally, I want to reduce the size of the kubeflow-pipelines-profile-controller, not increase it.

@thesuperzapper this is not on you but on the owners of the component to decide 😄

Are you sure the above AuthorizationPolicy you posted is working for you? I applied it but unless I remove the when part it still doesn't work and returns RBAC: access denied errors

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: user-user1-example-com-clusterrole-edit
  namespace: PROFILE_NAME
  annotations:
    role: edit
    user: "user1@example.com"
spec:                                                                                                                                                                      
  rules:                                                                                                                                                                   
  - from:                                                                                                                                                                  
    - source:                                                                                                                                                              
        principals:                                                                                                                                                        
        - cluster.local/ns/deploykf-istio-gateway/sa/deploykf-gateway                                                                                                      
        - cluster.local/ns/kubeflow/sa/ml-pipeline-ui                                                                                                                      
    when:                                                                                                                                                                  
    - key: request.headers[kubeflow-userid]                                                                                                                                
      values:                                                                                                                                                              
      - user1@example.com

If that's the case this is actually yet one more argument that this should be in the pipelines-profiles-controller. Let me also actually do a cc @chensun as well

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
@thesuperzapper
Copy link
Member

@kimwnasptd lol, I made a typo on the ingress gateway principal, it should be cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account.

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: user-user1-example-com-clusterrole-edit
  namespace: PROFILE_NAME
  annotations:
    role: edit
    user: "user1@example.com"
spec:                                                                                                                                                                      
  rules:                                                                                                                                                                   
  - from:                                                                                                                                                                  
    - source:                                                                                                                                                              
        principals:                                                                                                                                                        
        - cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account                                                                                                
        - cluster.local/ns/kubeflow/sa/ml-pipeline-ui                                                                                                                      
    when:                                                                                                                                                                  
    - key: request.headers[kubeflow-userid]                                                                                                                                
      values:                                                                                                                                                              
      - user1@example.com

@thesuperzapper
Copy link
Member

@kimwnasptd Also, regarding getting rid of the pipelines profile controlle

We had lots of discussions about it in the past, because that python script is very messy and brittle.

Personally, I think we can just extend the main profile controller with a new cluster resource that defines resources which should be created in each namespace.

There could two modes for this cluster resource:

  1. resources which should have a single instance per profile
  2. resources which should have one instance, per member, of each profile

I think the key features would be:

  • a label selector to choose which profiles get the resources
  • the template inside the cluster resource should support stuff like {{ profile.name }}, and {{ member.email }}

We might also need to start defining the members in the profile itself, rather than based on magically named RoleBindings (so we actually know who's meant to be a member, and what level of access they should have).

@kimwnasptd
Copy link
Member Author

kimwnasptd commented Oct 11, 2023

@kimwnasptd lol, I made a typo on the ingress gateway principal, it should be cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account.

@thesuperzapper the issue is not in the Istio IGW principal but on the rule for KFP. As I mentioned, in my vanilla installation:

FAILS: Still getting RBAC from Istio

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: user-user1-example-com-clusterrole-edit
spec:                                                                                                                                                                      
  rules:                                                                                                                                                                   
  - from:                                                                                                                                                                  
    - source:                                                                                                                                                              
        principals:                                                                                                                                                                                                                                                 
        - cluster.local/ns/kubeflow/sa/ml-pipeline-ui                                                                                                                      
    when:                                                                                                                                                                  
    - key: request.headers[kubeflow-userid]                                                                                                                                
      values:                                                                                                                                                              
      - user1@example.com                                                                      

SUCCEEDS

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: user-user1-example-com-clusterrole-edit
spec:                                                                                                                                                                      
  rules:                                                                                                                                                                   
  - from:                                                                                                                                                                  
    - source:                                                                                                                                                              
        principals:                                                                                                                                                                                                                                                      
        - cluster.local/ns/kubeflow/sa/ml-pipeline-ui                                                                                                                      

The PR currently has the above change that allows all requests from the ml-pipeline-ui so let's move on with this. This was either way the functionality in 1.7. We don't have to implement a new feature now while delaying the release.

The PR currently has the changes that I tested in my cluster and get KFP UI to talk to the per-profile Pods

Copy link
Member

@thesuperzapper thesuperzapper left a comment

Choose a reason for hiding this comment

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

@kimwnasptd its important for security that the kfp-ui is not able to proxy arbitrary requests (without userid-header), so let's just extend the from principals as I have proposed here.

NOTE: we don't even need to add a new rule this way, just extend the "from" principal list of the exiting one which has the "when" condition for the userid header.

Comment on lines 456 to 466
{
From: []*istioSecurity.Rule_From{
{
// KFP UI needs to talk to ml-pipeline-ui-artifact pods
// in each profile namespace
Source: &istioSecurity.Source{
Principals: []string{kfpUIPrincipal},
},
},
},
},
Copy link
Member

Choose a reason for hiding this comment

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

This rule should also include the "when" condition, to prevent the pipeline UI from being able to proxy traffic without a userid-header.

Option 1

The best option is to simply add another "from" principal in the first rule, and remove this rule.

			{
				When: []*istioSecurity.Condition{
					{
						Key: fmt.Sprintf("request.headers[%v]", r.UserIdHeader),
						Values: []string{
							r.UserIdPrefix + profileIns.Spec.Owner.Name,
						},
					},
				},
				From: []*istioSecurity.Rule_From{{
					Source: &istioSecurity.Source{
						Principals: []string{
							// end-users access via the ingress gateway
							istioIGWPrincipal,
							// kfp proxies user requests to artifact pods in profile namespaces
							kfpUIPrincipal,
						},
					},
				}},
			},

Option 2

We could keep it as a separate rule, and add the "when" condition, but this is is less efficient for Envoy, and needless because it has the same effect.

			{
				// kfp proxies user requests to artifact pods in profile namespaces
				When: []*istioSecurity.Condition{
					{
						Key: fmt.Sprintf("request.headers[%v]", r.UserIdHeader),
						Values: []string{
							r.UserIdPrefix + profileIns.Spec.Owner.Name,
						},
					},
				},
				From: []*istioSecurity.Rule_From{
					{
						Source: &istioSecurity.Source{
							Principals: []string{kfpUIPrincipal},
						},
					},
				},
			},

Principals: []string{
"cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account",
},
Principals: []string{istioIGWPrincipal},
Copy link
Member

Choose a reason for hiding this comment

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

You also need to add the kfpUIPrincipal here to allow the KFP UI to proxy requests for non-owners.

So if we define kfpUIPrincipal like in the profile controller, you can simply extend this list:

				From: []*istioSecurity.Rule_From{{
					Source: &istioSecurity.Source{
						Principals: []string{
							// end-users access via the ingress gateway
							istioIGWPrincipal,
							// kfp proxies user requests to artifact pods in profile namespaces
							kfpUIPrincipal,
						},
					},
				}},

@thesuperzapper
Copy link
Member

thesuperzapper commented Oct 11, 2023

@kimwnasptd the problem you were likley having was that KFAM does NOT reconcile its AuthorizationPolicies or RoleBindings for profile members, it only does it when the member is first added.

This is actually something we need to address before 1.8!

We either need to tell users to remove and re-add ALL members of profiles for this fix to take effect (even the initial one which prevents impersonation by restricting the source to the ingress gateway), or add a reconciliation loop to the profile controller (or possibly KFAM) for the AuthorizationPolicies.


The only "source of truth" around who should be a member of a profile, is the presence of RoleBinding in the profile namespaces like user-user1-example-com-clusterrole-view.

To identify the RoleBindings that actually correspond to members of profiles, we can look for roles that have a name starting with user-, and have a roleRef with one of the Kubeflow ClusterRoles.

"kubeflow-admin": "admin",
"kubeflow-edit": "edit",
"kubeflow-view": "view",

KFAM already does something similar with its "read bindings" API call, which is used by the dashboard (but not for reconciliation):

func (c *KfamV1Alpha1Client) ReadBinding(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
const action = "read"
queries, err := url.ParseQuery(r.URL.RawQuery)
if err != nil {
IncRequestErrorCounter(err.Error(), "", action, r.URL.Path,
SEVERITY_MAJOR)
w.WriteHeader(http.StatusForbidden)
writeResponse(w, []byte(err.Error()))
return
}
namespaces := []string{}
// by default scan all namespaces created by profile CR
if queries.Get("namespace") == "" {
profList, err := c.profileClient.List(metav1.ListOptions{})
if err != nil {
w.WriteHeader(http.StatusForbidden)
writeResponse(w, []byte(err.Error()))
}
for _, profile := range profList.Items {
namespaces = append(namespaces, profile.Name)
}
} else {
namespaces = append(namespaces, queries.Get("namespace"))
}
bindingList, err := c.bindingClient.List(queries.Get("user"), namespaces, queries.Get("role"))
if err != nil {
IncRequestErrorCounter(err.Error(), "", action, r.URL.Path,
SEVERITY_MAJOR)
w.WriteHeader(http.StatusUnauthorized)
writeResponse(w, []byte(err.Error()))
return
}
result, err := json.Marshal(*bindingList)
if err != nil {
IncRequestErrorCounter(err.Error(), "", action, r.URL.Path,
SEVERITY_MAJOR)
w.WriteHeader(http.StatusInternalServerError)
return
}
IncRequestCounter("", "", action, r.URL.Path)
if writeResponse(w, result) {
w.WriteHeader(http.StatusOK)
} else {
w.WriteHeader(http.StatusInternalServerError)
}
}

@kimwnasptd
Copy link
Member Author

kimwnasptd commented Oct 11, 2023

@thesuperzapper can you confirm that you have applied the following AuthorizationPolicy, in your user's profile namespace, and you don't get RBAC: access denied when trying to download the artifact of a pipeline step from the UI (even for the owner of the profile)?

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: user-user1-example-com-clusterrole-edit
spec:                                                                                                                                                                      
  rules:                                                                                                                                                                   
  - from:                                                                                                                                                                  
    - source:                                                                                                                                                              
        principals:                                                                                                                                                                                                                                                 
        - cluster.local/ns/kubeflow/sa/ml-pipeline-ui                                                                                                                      
    when:                                                                                                                                                                  
    - key: request.headers[kubeflow-userid]                                                                                                                                
      values:                                                                                                                                                              
      - user1@example.com                                                                      

Because for me even when I manually apply such a policy in the user namespace I'm still getting RBAC errors of Istio. If you don't get errors then I'd suggest you to sent a PR for this, since I don't want to send a PR for something that I can't get make it work.

And I focus this PR just on the initial scope of configuring the existing principals for the IGW and Notebook Controller, which was broken in #7032. KFP is completely orthogonal

@thesuperzapper
Copy link
Member

@kimwnasptd I can confirm with the manifests from 1.8.0-rc.1 that I get no RBAC errors on the KFP artifacts, if the following changes are made to these AuthorizationPolicies.

Note I am using two dex static-password users:

  • user@example.com: the owner of profile named kubeflow-user-example-com
  • user1@example.com: a member of profile named kubeflow-user-example-com

AuthorizationPolicy for Owner

NOTE 1: to manually apply this, you need to scale the Deployment/profiles-deployment to 0 replicas, as changes will be immediately reverted otherwise.

NOTE 2: You scale to 0 AFTER you are already on the correct pipelines page, because the profile controller being down breaks the ability to navigate on the central dashboard.

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  annotations:
    role: admin
    user: user@example.com
  name: ns-owner-access-istio
  namespace: kubeflow-user-example-com
spec:
  rules:
    - from:
        - source:
            principals:
              - cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account
              ## \/ added this part \/ ##
              - cluster.local/ns/kubeflow/sa/ml-pipeline-ui
      when:
        - key: request.headers[kubeflow-userid]
          values:
            - user@example.com
    - when:
        - key: source.namespace
          values:
            - kubeflow-user-example-com
    - to:
        - operation:
            paths:
              - /healthz
              - /metrics
              - /wait-for-drain
    - from:
        - source:
            principals:
              - cluster.local/ns/kubeflow/sa/notebook-controller-service-account
      to:
        - operation:
            methods:
              - GET
            paths:
              - '*/api/kernels'

AuthorizationPolicy for Member

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  annotations:
    role: edit
    user: user1@example.com
  name: user-user1-example-com-clusterrole-edit
  namespace: kubeflow-user-example-com
spec:
  rules:
    - from:
        - source:
            principals:
              - cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account
              ## \/ added this part \/ ##
              - cluster.local/ns/kubeflow/sa/ml-pipeline-ui
      when:
        - key: request.headers[kubeflow-userid]
          values:
            - user1@example.com

@kimwnasptd
Copy link
Member Author

omg, I found the problem with my testing. The file I was locally applying had requests.headers and not request.headers... It works indeed as expected with this.

Sending the patch

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
@kimwnasptd
Copy link
Member Author

@thesuperzapper I sent the fix. I confirm it works with the Profile controller as well. Apologies for this back and forth, caused by me using different yaml locally from the one above.

Once the tests pass we should be good to merge

@thesuperzapper
Copy link
Member

@kimwnasptd We MUST make another PR before releasing 1.8, because right now the security fix that was intended by #7032, will not be applied to existing profile members, only new ones.

This is because as I was saying in #7310 (comment), while the profile controller will reconcile changes, KFAM will NOT, so all of our updates will only apply to NEW members of profiles.

This means we need to add a reconciliation loop to the resources created by KFAM.

Proposal for Reconciliation of Bindings

After thinking about it, the easiest way to do this is to move the reconciliation to the profile controller.

This is actually easier than it sounds:

  1. We can make KFAM only responsible for creating/deleting the RoleBindings and not any other resources:
    • This means removing the other parts of its "create role binding" function that create AuthorizationPolicies
    • This also allows us to keep KFAM, so nothing else breaks (like central-dashboard)
  2. We can extend the profile-controller's reconciliation loop:
    • It can look for RoleBindings in profile namespaces that start with the name user- and have appropriate annotations.
    • If it finds one, it can create the AuthorizationPolicies for that user, with an ownerReference pointing to the RoleBinding (so if KFAM deletes it, the binding gets cleaned up automatically).

This way the presence of a RoleBinding in a profile namespace "tells" the profile-controller what it needs to create:

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  annotations:
    role: edit
    user: user1@example.com
  name: user-user1-example-com-clusterrole-edit
  namespace: kubeflow-user-example-com
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kubeflow-edit
subjects:
  - apiGroup: rbac.authorization.k8s.io
    kind: User
    name: user1@example.com

As you can see, all the info the profile-controller needs is found in the user and role annotations.

Finally, we should allow seamless "adoption" of old AuthorizationPolicies by the profile-controller, so users don't need to do anything when upgrading to 1.8.

@kimwnasptd
Copy link
Member Author

/hold

@thesuperzapper tbh I don't feel comfortable with either of those. They both seem like too big of changes to introduce in the last minute, when the release is already hugely delayed.

My proposal is what I had initially described:

  1. Allow all requests that come from KFP UI's ServiceAccount to user namespace (in AP created for "owner")
  2. This won't require any changes in KFAM

For the KFP functionality it feels like we are trying to patch a security whole the KFP folks didn't think e2e. And all of this in the last minute with adding huge changes while delaying the release. I don't have the cycles to either create the follow up PR, not to properly review it.

So I suggest we keep the work of fixing KFP issues as a next effort either in a KF patch release or in 1.8

@thesuperzapper
Copy link
Member

@kimwnasptd This PR is correct as it is, I think we should merge it.

The issue I am raising in #7310 (comment) is not really related to KFP or this PR.

It's that even though we have updated KFAM to create secure AuthorizationPolicies (which ensure traffic is only coming from the gateway), any existing AuthorizationPolicies won't be updated.

So we either need to tell users to remove and re-add every member of each profile (so KFAM makes the new AuthorizationPolicies), or do the small change I am proposing to move the management of AuthorizationPolicies to the profile-controller.

I really don't think it's as complex as you are thinking, it's a small amount of code being removed from KFAM, and a small amount of code being added to the profile-controller.

@thesuperzapper
Copy link
Member

@kimwnasptd and I had a long discussion, and we think this is safe to merge for now, and rather than doing what I proposed in #7310 (comment), we will tell users who are upgrading, that to get the security benefits of #7032, they must EITHER:

  • patch the existing AuthorizationPolicies for colaborators in each profile to have the new "from principal" which only allows traffic from the istio-gateway and ml-pipeline-ui
  • remove and re-add every profile collaborator using the central-dashboard UI

/lgtm
/approve

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: thesuperzapper

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

The pull request process is described 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

@kimwnasptd
Copy link
Member Author

/hold cancel

@google-oss-prow google-oss-prow bot merged commit 51becc7 into kubeflow:master Oct 12, 2023
6 checks passed
DnPlas pushed a commit to DnPlas/kubeflow that referenced this pull request Oct 13, 2023
* Make principals dynamic in Profiles Controller

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>

* review: Use dynamic principal of IGW in KFAM

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>

* review: Add env vars to manifests

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>

* review: Add pipelines-ui principal

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>

* Update golang to 1.19 for unit tests to succeed

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>

* review: Include KFP UI principle in profiles/kfam

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>

---------

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
google-oss-prow bot pushed a commit that referenced this pull request Oct 13, 2023
* Make principals dynamic in Profiles Controller



* review: Use dynamic principal of IGW in KFAM



* review: Add env vars to manifests



* review: Add pipelines-ui principal



* Update golang to 1.19 for unit tests to succeed



* review: Include KFP UI principle in profiles/kfam



---------

Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
Co-authored-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
@kimwnasptd kimwnasptd deleted the feature-kimwnasptd-dynamic-sa-profiles branch October 13, 2023 11:27
@kimwnasptd kimwnasptd mentioned this pull request Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants