You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tenants could have his own set of Namespaces to operate on but it should be prepared by higher-level roles, like platform admins: the declarations would be part of the platform space.
176
176
They would be responsible of tenants administration, and each change (e.g. new tenant Namespace) should be a request that would pass through approval.
@@ -311,7 +311,7 @@ To deepen on this please go to [#Insights](#insights).
311
311
312
312
### How to setup Tenants GitOps-ready
313
313
314
-
Given that [Capsule](github.com/projectcapsule/capsule) and [Capsule Proxy](github.com/clastix/capsule-proxy) are installed, and [Flux v2](https://github.com/fluxcd/flux2) configured with [multi-tenancy lockdown](https://fluxcd.io/docs/installation/#multi-tenancy-lockdown) features, of which the patch below:
314
+
Given that [Capsule](https://github.com/projectcapsule/capsule) and [Capsule Proxy](/docs/proxy) are installed, and [Flux v2](https://github.com/fluxcd/flux2) configured with [multi-tenancy lockdown](https://fluxcd.io/docs/installation/#multi-tenancy-lockdown) features, of which the patch below:
315
315
316
316
```yaml
317
317
apiVersion: kustomize.config.k8s.io/v1beta1
@@ -351,21 +351,26 @@ patches:
351
351
352
352
this is the required set of resources to setup a Tenant:
353
353
- `Namespace`: the Tenant GitOps Reconciler "home". This is not part of the Tenant to avoid a chicken & egg problem:
354
+
354
355
```yaml
355
356
apiVersion: v1
356
357
kind: Namespace
357
358
metadata:
358
359
name: my-tenant
359
360
```
361
+
360
362
- `ServiceAccount` of the Tenant GitOps Reconciler, in the above `Namespace`:
363
+
361
364
```yaml
362
365
apiVersion: v1
363
366
kind: ServiceAccount
364
367
metadata:
365
368
name: gitops-reconciler
366
369
namespace: my-tenant
367
370
```
371
+
368
372
- `Tenant` resource with the above Tenant GitOps Reconciler's SA as Tenant Owner, with:
373
+
369
374
- Additional binding to *cluster-admin* `ClusterRole` for the Tenant's `Namespace`s and `Namespace` of the Tenant GitOps Reconciler' `ServiceAccount`.
370
375
By default Capsule binds only `admin` ClusterRole, which has no privileges over Custom Resources, but *cluster-admin* has. This is needed to operate on Flux CRs:
371
376
```yaml
@@ -531,42 +536,40 @@ This is because we need to make tenant reconciliation requests through Capsule P
531
536
532
537
### Threats
533
538
534
-
##### Bypass unprivileged impersonation
539
+
#### Bypass unprivileged impersonation
535
540
536
541
The reason why we can't set impersonation to be optional is because, as each tenant is allowed to not specify neither the kubeconfig nor the impersonation SA for the Reconciliation resource, and because in any case that kubeconfig could contain whatever privileged credentials, Flux would otherwise use the privileged ServiceAccount, to reconcile tenant resources.
537
542
538
543
That way, a tenant would be capable of managing the GitOps way the cluster as he was a cluster admin.
539
544
540
545
Furthermore, let's see if there are other vulnerabilities we are able to protect from.
541
546
542
-
##### Impersonate privileged SA
547
+
#### Impersonate privileged SA
543
548
544
549
Then, what if a tenant tries to escalate by using one of the Flux controllers privileged `ServiceAccount`s?
545
550
546
551
As `spec.ServiceAccountName` for Reconciliation resource cannot cross-namespace reference Service Accounts, tenants are able to let Flux apply his own resources only with ServiceAccounts that reside in his own Namespaces. Which is, Namespace of the ServiceAccount and Namespace of the Reconciliation resource must match.
547
552
548
553
He could neither create the Reconciliation resource where a privileged ServiceAccount is present (like flux-system), as the Namespace has to be owned by the Tenant. Capsule would block those Reconciliation resource creation requests.
549
554
550
-
##### Create and impersonate privileged SA
555
+
#### Create and impersonate privileged SA
551
556
552
557
Then, what if a tenant tries to escalate by creating a privileged `ServiceAccount` inside on of his own `Namespace`s?
553
558
554
559
A tenant could create a `ServiceAccount` in an owned `Namespace`, but he can't neither bind at cluster-level nor at a non-owned Namespace-level a ClusterRole, as that wouldn't be permitted by Capsule admission controllers.
555
560
556
561
Now let's go on with the practical part.
557
562
558
-
##### Change ownership of privileged Namespaces (e.g. flux-system)
563
+
#### Change ownership of privileged Namespaces (e.g. flux-system)
559
564
560
565
He could try to use privileged `ServiceAccount` by changing ownership of a privileged Namespace so that he could create Reconciliation resource there and using the privileged SA.
561
566
This is not permitted as he can't patch Namespaces which have not been created by him. Capsule request validation would not pass.
562
567
563
-
For other protections against threats in this multi-tenancy scenario please see the Capsule [Multi-Tenancy Benchmark](/docs/general/mtb).
568
+
For other protections against threats in this multi-tenancy scenario please see the Capsule [Multi-Tenancy Benchmark](/docs/overview/benchmark/).
0 commit comments