openkruise / kruise-game

Game Servers Management on Kubernetes
https://openkruise.io/kruisegame/introduction
Apache License 2.0
411 stars 58 forks source link

Improper k8s permission configuration #133

Closed sparkEchooo closed 8 months ago

sparkEchooo commented 8 months ago

Summary

  The ack-kruise-game in ACK gave excessive authority when defining Service Account named "kruise-game-controller-manager". Besides, this Service Account is mounted in a pod named "kruise-game-controller-manager-675bb6974d-4m6d7", witch makes it possible for attackers to raise rights to administrators.  

Detailed Analysis

 Attacking Strategy

  If a malicious user controls a specific worker node which has the Pod mentioned above , or steals the Service Account token mentioned above. He/She can raise permissions to administrator level and control the whole cluster. For example,

Mitigation Discussion

 A few questions

chrisliu1995 commented 8 months ago

Actually, kruise-game & kruise controller manager indeed need create verb, whose permissions are already restrict. If you use multi-tenant Kubernetes clusters, it is necessary to consider cluster security. I recommend avoiding user YAML being deployed directly in the cluster. It is a better way that checking if those YAMLs use service accounts with high permissions before deployment.

chrisliu1995 commented 8 months ago

By the way, you can join the DingDing Group 44862615, to communicate with ours (including OKG maintainers, and Game Developers)

sparkEchooo commented 8 months ago

Hi @chrisliu1995 , Thank you for your reply!

Did Kruise need to create pods in another namespace? If not, maybe we could use rolebinding to further restrict this permission.

Thanks again.

chrisliu1995 commented 8 months ago

You know, kruise can not decide which namespace the user deploy applications in. If user deploy GameServerSet in x-namespace, kruise & kruise game controller manager have to create asts & pods in x-namespace. In fact, it is cluster-scope action.

sparkEchooo commented 8 months ago

Well, Thank you for your patient explanation!

sparkEchooo commented 7 months ago

I apologize for bothering you again, but I just wanted to confirm once more if kruise-game necessarily requires the update permission for the mutatingwebhookconfiguration resource. It seems that once the mutatingwebhookconfiguration resource is set up during the application installation, it typically does not need to be updated. :)