-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security] A potential risk of kubecost makes a worker node get the token of any Service Account #9
Comments
@sparkEchooo could you share the exact command you used to install kubecost? I don't see any "kubecost-1-deployer" service accounts in the base helm chart. |
Hi @AjayTripathy, thanks for your reply! Install KubecostI install kubecost from the marketplace of Google GKE. PodsAnd this is the result of command ClusterRoleBinding & ClusterRoleThis is the ClusterRoleBinding and the ClusterRole related to the service account "kubecost-1-deployer-sa". DiscussionIf Kubecost don't defines the service account named "kubecost-1-deployer-sa", it may be defined by GKE. I will report this to Google. However, the high authority of "kubecost-1-cost-analyzer-serviceaccount-name-dff5" and "kubecost-1-cost-analyzer-prometheus-serviceaccounts-server-name-e82d" defined by Kubecost is still worth noting. Thanks again. |
I believe that pod is defined by GKE. You can quickly verify that with a helm install
and diffing the created service accounts. |
This issue is related to the Kubecost listing on GCP Marketplace hence transferred to its parent repo. The configuration is found here which is specific to the Marketplace listing and, as pointed out earlier, not part of the main chart. This may have been a requirement for the deployment to succeed in GCP because it's the only place where the differences appear. |
whoops. sorry for the accidental close. I think this is appropriately filed now but there's not much we can do on our side. |
Dear kubecost maintainers, I kindly request that you issue a relevant security advisory to alert and assist those who, like us, have installed and are using Kubecost on GKE with the default settings. This is a real issue, and we believe there are many others who may encounter this potential security problem without being aware of it beforehand. If possible, please express gratitude for our report in the advisory. Thank you for your understanding and cooperation. Regards, |
Hi @sparkEchooo as noted this is not related to kubecost and is a function of the GCP marketplace. |
Is there a place to file this against GCP marketplace or a related repo? |
@alexkubecost is there someone on the GCP Marketplace team we could share this with? |
@chipzoller actually, do you know how to quickly test whether that's actually a requirement on the marketplace? |
Hi there, |
Thank you @sparkEchooo we will look at updating this in https://github.com/kubecost/gcp-marketplace/blob/main/kubecost/schema.yaml#L84-L158 |
cc @cliffcolvin let's file a ticket for internal tracking |
Kubecost Helm Chart Version
1.107
Kubernetes Version
s
Kubernetes Platform
GKE
Description
Summary
The Kubecost in GKE gave excessive authority when defining Service Account named "kubecost-1-cost-analyzer-serviceaccount-name-dff5" "kubecost-1-cost-analyzer-prometheus-serviceaccounts-server-name-e82d" and "kubecost-1-deployer-kvsqj". Besides, these Service Accounts are mounted into pod, witch makes it possible for attackers to raise rights to administrators.
Detailed Analysis
I deployed Kubecost in the marketplace of Google's GKE cluster by default.
The clusterrole named "default:kubecost-1:cost-analyzer.serviceAccount.name-r0" defines the "*" verb of "pods, deployments, replicationcontrollers and nodes". And this clusterrole is bound to the Service Account named "kubecost-1-cost-analyzer-serviceaccount-name-dff5". The Service Account is mounted into the pod named "kubecost-1-cost-analyzer-789fc48778-xgpkg".
The clusterrole named "default:kubecost-1:cost-analyzer.prometheus.serviceAccounts.server.name-r0" defines the "*" verb of "pods, jobs, deployments, statefulsets, replicationcontrollers and nodes". And this clusterrole is bound to the Service Account named "kubecost-1-cost-analyzer-prometheus-serviceaccounts-server-name-e82d". The Service Account is mounted into the pod named "kubecost-1-prometheus-server-6f9d5c9989-l972j".
The clusterrole named "default:kubecost-1:deployerServiceAccount-r0" defines the "*" verb of "clusterroles and clusterrolebindings". And this clusterrole is bound to the Service Account named "kubecost-1-deployer-sa". The Service Account is mounted into the pod named "kubecost-1-deployer-kvsqj".
Attacking Strategy
If a malicious user controls a specific worker node which has the pod mentioned above, or steals one of the SA token mentioned above.He/She can raise permissions to administrator level and control the whole cluster.
For example,
With the "*" verb of "clusterroles and clusterrolebindings", attacker can elevate privileges by creating a clusterrolebinding resource and binding cluster-admin to their own Service Account.
With the "*" verb of "pods, jobs, deployments, statefulsets, replicationcontrollers", attacker can elevate privileges by creating a pod to mount and steal any Service Account he/she want.
With the "*" verb of nodes, attacker can hijack other components and steal token by adding a "NoExecute" taint to other nodes.
Mitigation Discussion
A few questions
Reporter list
Looking forward to your reply. Regards Xingyu Liu
Steps to reproduce
kubectl get sa
to get the list of service accounts.kubectl get rolebinding,clusterrolebinding --all-namespaces -o jsonpath='{range .items[?(@.subjects[0].name=="SERVICE_ACCOUNT_NAME")]}[{.roleRef.kind},{.roleRef.name}]{end}'
to get the clusterrole related to the service account, and view the permission definition.Expected behavior
This is a configuration error.
The Service Accounts mentioned above are given excessive authority, witch makes it possible for attackers to raise rights to administrators.
Impact
No response
Screenshots
No response
Logs
No response
Slack discussion
No response
Troubleshooting
The text was updated successfully, but these errors were encountered: