-
Notifications
You must be signed in to change notification settings - Fork 332
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
User's RBAC violations during volume provisioning #213
Comments
Hi @venkatsc, StorageClass is a cluster-level resource and is meant to be created and managed by a cluster admin, not by a particular user/namespace. So the provision secret referenced in the StorageClass is designed to be used cluster-wide. That being said, I think the kubernets-csi documentation could be more clear in this regard. cc @saad-ali As a workaround, you can restrict a StorageClass to specific namespaces by setting StorageClass quota. For other CSI secrets, we do support secret namespace templating using the pvc.namespace (and other parameters), but not for provisioning. From discussing with @liggitt, the main reasoning was that during volume delete, we would not have the PVC object anymore so we could not resolve the template at that time. But for storage systems where secrets are not needed for volume delete, we could potentially relax the templating rules and allow pvc.namespace on create. If this is something that your storage system can support, then we can consider adding this as a new feature. |
@msau42 Thanks for looking into it. The issue is more of namespace violation of secrets due to CSI external provisioner having different RBAC rules (kind of superuser privileges for accessing secrets and storage classes). This issue is prevented only if the user cannot create PVC which IMO severely amputees the usability. As explained in the Scenario 2, a user without access to StorageClass can access the storage class by simply knowing the StorageClass name, exploiting the privileges of the service account used to deploy CSI-external provisioner. Let us say, CSI external provisioner is deployed with the service account
The issue is due to that brief service account switching from Step 2 to Step 3 of the volume provisioning without real user's RBAC capability check. As can be seen, this permission escalation should be part of all the external plugins that deploy their own RBACs (as these override users RBAC rules). IMO, these can be fixed by associating user information with resource and validating capabilities as explained in the Kubernetes impersonation API. On PVC not being available during delete, Can owner references be used to prevent deletion before volume deletion completion in the storage vendor system? |
Hi @venkatsc, I think there's some confusion around the scope of the provisioning secrets specified in a StorageClass. Per-user provisioning secrets are currently not supported by the StorageClass API unless you pair it with StorageClass quota restricting that specific StorageClass to a particular namespace. Secrets used by the provisioner are intended to be created by the cluster administrator with cluster-wide scope, in namespaces that may be independent from a user's namespace. We can look into supporting per-user namespace provision secrets, but it would have the limitation that it could not be used for volume deletion. Regarding volume deletion, the deletion of the PVC object is what triggers the volume deletion call to be made for the PV. |
Hi @msau42 "We can look into supporting per-user namespace provision secrets, but it would have the limitation that it could not be used for volume deletion." -- that would be great. |
The documentation here talks about pvc namespace templating for ControllerPublish and NodePublish secrets. Similarly, we could investigate doing something similar for Provision secrets (with some limitations) |
Thank you @msau42 for pointing me to the relevant documentation. I will raise a new feature request for per-user provisioning secrets. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Per PVC secret templating was added in #274 |
@msau42: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
…tion-removal Removed dependency on node annotation in favor of CSINode resource
/kind bug
What happened?
Configure two users -
UserA
andUserB
service accounts restricting both to their own namespaces and additional ClusterRole with access to StorageClasses, PersistentVoluems.Scenario 1
UserA
's secret (stored in their namespace) with any CSI external provisioner plugin (tested with Quobyte CSI plugin).UserB
's namespace usingUserA
's storageclass (PVC should trigger dynamic provisioning).UserB
is able to accessUserA
's secret and can create volume.Scenario 2
ClusterRole
RBAC ofUserB
that gives access to PV and StorageClassUserB
's namespace usingUserA
's storageclass (PVC should trigger dynamic provisioning).UserB
is able to accessUserA
's secret and can create volume.Expected:
UserB
should not be able create volumes asUser A
Note on mounting:
UserB
may not be able to mount the volume given there is authentication during the mounting phase (as this part of CSI code is inside kubernetes and RBAC prevents the reading ofUserA
's secret byUserB
). But the issue of volume creation byUserB
usingUserA
's secret is a deviation from the expected behaviour of RBAC.Why it happened?
CSI provisioner is deployed with a service account that can access all the secrets and storage classes. When a PVC is created in the Kubernetes by
UserB
, the RBAC only checked whether this can create PVC but neither access to the StorageClass nor the Secrets included in the StorageClass referred by PVC.When CSI Provisioner started provisioning volume outside of Kubernetes for the triggered PVC, it does not have any user information and used its own service account with elevated privileges to get the secret of
UserA
.Possible fixes:
An admission plugin that verifies access to StorageClass and access to CSI secrets during PVC creation time. But it is not sufficient for RBAC revocation, as there is no check after once PVC is created.
Use impersonation API and from CSI and check if the current user can access resources before accessing it with CSI's service account. But, currently, Kubernetes resources does not contain any user information once they are admitted.
The text was updated successfully, but these errors were encountered: