Implement fine-grained RBAC permssions to update/delete application resources #17991
Labels
component:api
API bugs and enhancements
component:rbac
Issues related to Openshift and Racher
enhancement
New feature or request
Summary
The goal of this proposal is to allow fine-grained permission in the RBAC configuration for update and delete operations. It modifies the policy permission pattern based on Casbin to support subresource on a native delete and update operations.
Motivation
Developers with low knowledge of Kubernetes use Argo CD UI to interact with their applications. When developers need to operate their application, they sometimes have to modify or delete resources. In an ideal life, all changes would go through git, but sometimes a change needs to be made quickly to mitigate an issue.
Pod needs to be delete
A developer might need to delete a pod in ArgoCD UI to fix their application, which would be non-impactful because it would be immediately replaced by ReplicaSet or other mechanisms.
However, that user may not need to delete the Deployment resource or ReplicaSet, which would be Impactful due to application downtime.
To prevent any knid of errors and aim for the principle of least privilege, the user should only have permission to delete Pods in their Applciation as defined by the RBAC.
Patching manifest of specific resources
A developer might need to patch a manifest in ArgoCD UI to fix their application. However, that user may not need to update all the resources of their applications.
To prevent any kind of errors and aim for the principle of least privilege, the user should only have permission to update predefined manifest as defined by the RBAC.
Proposal
Terminology
Based on ArgoCD RBAC Documentation, we define a permission as
p, <role/user/group>, <resource>, <action>, <appproject>/<object>
.Current State
Deleting an application's resource today
The permission necessary to delete a resource of an application is
p, <role/user/group>, applications, delete, <appproject>/<app-name>, allow
. This policy also give the user permission to delete the / Application.Options
A) Add to the existing
applications
resource (preferred)Pattern:
p, <role/user/group>, applications, delete/<group>/<kind>/<ns>/<name>, <appproject>/<app-name>, allow
Application resources are part of the application API. So it is reasonable to use
applications
as the<resource>
. When we want to delete the sub-resource, it can be argued that the<action>
we are doing isdelete/<group>/<kind>/<ns>/<name>
.B) Create a new
resources
resourcePattern:
p, <role/user/group>, resources, delete<group>/<kind>/<ns>/<name>, <appproject>/<app-name>, allow
Even if resources are part of the Application API details today, this can be considered as an implementation detail and does not need to be reflected in the policy. However, to keep backward compatibility, it may be unclear to the user that there are two existing
<resource>
that can be configured to allow deleting application resources.C) Use a more specific
<object>
Pattern:
p, <role/user/group>, applications, delete, <appproject>/<app-name>/<group>/<kind>/<ns>/<name>, allow
The truth about this option is that the documentation is lying. When ArgoCD is configured in namespaced mode, the
<object>
is actually converted to<app-ns>/<app-name>
. This creates a problem that could cause privilege escalation based on misconfiguration.Supposing I want to allow
developers
to delete any resource in thebar
namespace for appfoo
in theargocd
namespace, I would define the policy asp, developers, applications, delete, my-project/foo/bar/*
Unfortunately, we are now accidentally granting the
developers
access to delete any resources in any app namedbar
in thefoo
namespace.For this reason, the
<object>
should not be extended to include a sub-resource.Backward compatibility
The current DeleteResource API checks if user has the capabilities to
applications, delete, <appproject>/<app-name>
. If the user is allowed, it will delete the subresource with the k8s API. If it is not allowed, it will return a permission denied request.With the new policy, the DeleteResource API would do the following
applications, delete, <appproject>/<app-name>
applications, delete/<group>/<kind>/<ns>/<name>, <appproject>/<app-name>
3. True: The user can delete the resource
4. False: The user cannot delete the resource
The first validation would be the same as the current one. It validates if the user has permissions to the application
Security concerns
It should not be possible to infer if the Application exists or not by calling the API and looking at 1) the status code and B) the duration of the API call.
applications, delete, <appproject>/<app-name>
applications, delete/<group>/<kind>/<ns>/<name>, <appproject>/<app-name>
, even if app doesn`t existDecision
Implementation of Option A.
Multiple proposals, discussions, opinions and suggestions have been brought up in other issues over the last months, and years. However, the no implementation were released to solve the issue.
Sometimes, we have to commit to something, even if it is not the ideal solution. I think the solution above is a good compromise for the user experience, security, migration impact and development time.
Long-term Alternatives
Project role impersonation of a Kubernetes service account is a viable alternative to this proposal, but requires a lot more changes to Argo. There seem to be a shift to go towards this solution in the long term. #9095
However, adding to the ArgoCD ARBAC does not increase or reduce the amount of work that will be required to support impersonation in the future.
Other alternatives
Allowing delete through actions could have been an Options, but it seemed like this option would require additional changes to the UI to give the same experience as the built-in option, and it would create 2 possible ways to delete a resource which could have been confusing to the users of ArgoCD UI or API without additional changes.
The text was updated successfully, but these errors were encountered: