GHSA-6r4j-4rjc-8vw5

Suggest an improvement
Source
https://github.com/advisories/GHSA-6r4j-4rjc-8vw5
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/08/GHSA-6r4j-4rjc-8vw5/GHSA-6r4j-4rjc-8vw5.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-6r4j-4rjc-8vw5
Aliases
Published
2024-08-12T18:22:06Z
Modified
2024-11-18T16:27:03Z
Severity
  • 8.1 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N CVSS Calculator
  • 9.3 (Critical) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N CVSS Calculator
Summary
RBAC Roles for `etcd` created by Kamaji are not disjunct
Details

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: https://github.com/clastix/kamaji/blob/8cdc6191242f80d120c46b166e2102d27568225a/internal/datastore/etcd.go#L19-L24

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

  1. Create two TCP in the same Namespace
  2. Scale Kamaji to zero to avoid reconciliations
  3. change the Kubernetes API Server --etcd-prefix flag value to point to the other TCP datastore key
  4. wait it for get it up and running
  5. 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).

Database specific
{
    "nvd_published_at": "2024-08-12T16:15:15Z",
    "cwe_ids": [
        "CWE-284"
    ],
    "severity": "CRITICAL",
    "github_reviewed": true,
    "github_reviewed_at": "2024-08-12T18:22:06Z"
}
References

Affected packages

Go / github.com/clastix/kamaji

Package

Name
github.com/clastix/kamaji
View open source insights on deps.dev
Purl
pkg:golang/github.com/clastix/kamaji

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Last affected
1.0.0