Skip to content

User's RBAC violations during volume provisioning #213

@venkatsc

Description

@venkatsc

/kind bug
What happened?

Configure two users - UserA and UserB service accounts restricting both to their own namespaces and additional ClusterRole with access to StorageClasses, PersistentVoluems.

Scenario 1

  1. Create StorageClass with UserA's secret (stored in their namespace) with any CSI external provisioner plugin (tested with Quobyte CSI plugin).
  2. Create PVC in UserB's namespace using UserA's storageclass (PVC should trigger dynamic provisioning).
  3. UserB is able to access UserA's secret and can create volume.

Scenario 2

  1. Remove ClusterRole RBAC of UserB that gives access to PV and StorageClass
  2. Create PVC in UserB's namespace using UserA's storageclass (PVC should trigger dynamic provisioning).
  3. UserB is able to access UserA's secret and can create volume.

Expected:
UserB should not be able create volumes as User 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 of UserA's secret by UserB). But the issue of volume creation by UserB using UserA'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:

  1. 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.

  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions