Summary
Using an "open at the top" range definition in RBAC for etcd roles leads to some TCPs API servers being able to read, write and delete the data of other control planes.
Details
The problematic code is this:
|
const ( |
|
// rangeEnd is the key following the last key of the range. |
|
// If rangeEnd is ‘\0’, the range is all keys greater than or equal to the key argument |
|
// source: https://etcd.io/docs/v3.5/learning/api/ |
|
rangeEnd = "\\0" |
|
) |
The range created by this RBAC setup code looks like this:
etcdctl role get example
Role example
KV Read:
[/example/, \0)
KV Write:
[/example/, \0)
The range end \0
means "everything that comes after" in etcd, so potentially all the key prefixes of controlplanes with a name that comes after "example" when sorting lexically (e.g. example1
, examplf
, all the way to zzzzzzz
if you will).
PoC
- Create two TCP in the same Namespace
- Scale Kamaji to zero to avoid reconciliations
- change the Kubernetes API Server
--etcd-prefix
flag value to point to the other TCP datastore key
- wait it for get it up and running
- use
kubectl
and will notice you're reading and writing data of another Tenant
Impact
Full control over other TCPs data, if you are able to obtain the name of other TCPs that use the same datastore and are able to obtain the user certificates used by your control plane (or you are able to configure the kube-apiserver Deployment, as shown in the PoC).
Summary
Using an "open at the top" range definition in RBAC for etcd roles leads to some TCPs API servers being able to read, write and delete the data of other control planes.
Details
The problematic code is this:
kamaji/internal/datastore/etcd.go
Lines 19 to 24 in 8cdc619
The range created by this RBAC setup code looks like this:
The range end
\0
means "everything that comes after" in etcd, so potentially all the key prefixes of controlplanes with a name that comes after "example" when sorting lexically (e.g.example1
,examplf
, all the way tozzzzzzz
if you will).PoC
--etcd-prefix
flag value to point to the other TCP datastore keykubectl
and will notice you're reading and writing data of another TenantImpact
Full control over other TCPs data, if you are able to obtain the name of other TCPs that use the same datastore and are able to obtain the user certificates used by your control plane (or you are able to configure the kube-apiserver Deployment, as shown in the PoC).