GCP - Container Privesc
컨테이너
container.clusters.get
container.clusters.get
이 권한은 Kubernetes 클러스터의 자격 증명을 수집하는 데 사용할 수 있습니다. 다음과 같은 방법으로 사용할 수 있습니다:
추가 권한이 없으면 자격 증명은 매우 기본적입니다. 일부 리소스를 열거할 수만 있습니다. 그러나 이는 환경에서 잘못된 구성을 찾는 데 유용합니다.
참고로 쿠버네티스 클러스터는 비공개로 구성될 수 있으며, 이는 인터넷에서 Kube-API 서버에 대한 액세스를 금지합니다.
이 권한이 없으면 여전히 클러스터에 액세스할 수 있지만, 클러스터 정보를 포함한 자체 kubectl 구성 파일을 생성해야 합니다. 새로 생성된 파일은 다음과 같습니다:
container.roles.escalate
| container.clusterRoles.escalate
container.roles.escalate
| container.clusterRoles.escalate
기본적으로 Kubernetes는 주체가 가지고 있는 권한보다 더 많은 권한을 가진 Roles와 ClusterRoles을 생성하거나 업데이트하는 것을 방지합니다. 그러나 이러한 권한을 가진 GCP 주체는 Kubernetes의 이러한 동작에 대한 보호를 우회하여 더 많은 권한을 가진 Roles/ClusterRoles을 생성/업데이트할 수 있습니다.
이러한 권한을 수행하기 위해서는 container.roles.create
및/또는 container.roles.update
또는 container.clusterRoles.create
및/또는 **container.clusterRoles.update
**도 필요합니다.
container.roles.bind
| container.clusterRoles.bind
container.roles.bind
| container.clusterRoles.bind
기본적으로 Kubernetes는 주체가 가지고 있는 권한보다 더 많은 권한을 가진 RoleBindings와 ClusterRoleBindings을 생성하거나 업데이트하는 것을 방지합니다. 그러나 이러한 권한을 가진 GCP 주체는 Kubernetes의 이러한 동작에 대한 보호를 우회하여 더 많은 권한을 가진 RoleBindings/ClusterRoleBindings을 생성/업데이트할 수 있습니다.
이러한 권한을 수행하기 위해서는 container.roleBindings.create
및/또는 container.roleBindings.update
또는 container.clusterRoleBindings.create
및/또는 **container.clusterRoleBindings.update
**도 필요합니다.
container.cronJobs.create
| container.cronJobs.update
| container.daemonSets.create
| container.daemonSets.update
| container.deployments.create
| container.deployments.update
| container.jobs.create
| container.jobs.update
| container.pods.create
| container.pods.update
| container.replicaSets.create
| container.replicaSets.update
| container.replicationControllers.create
| container.replicationControllers.update
| container.scheduledJobs.create
| container.scheduledJobs.update
| container.statefulSets.create
| container.statefulSets.update
container.cronJobs.create
| container.cronJobs.update
| container.daemonSets.create
| container.daemonSets.update
| container.deployments.create
| container.deployments.update
| container.jobs.create
| container.jobs.update
| container.pods.create
| container.pods.update
| container.replicaSets.create
| container.replicaSets.update
| container.replicationControllers.create
| container.replicationControllers.update
| container.scheduledJobs.create
| container.scheduledJobs.update
| container.statefulSets.create
| container.statefulSets.update
이러한 권한을 사용하면 리소스를 생성하거나 업데이트할 수 있으며, pod를 정의할 수 있습니다. pod를 정의하면 연결될 SA와 실행될 이미지를 지정할 수 있으므로, SA의 토큰을 서버로 유출시키는 이미지를 실행하여 모든 서비스 계정으로 승격할 수 있습니다. 자세한 정보는 다음을 참조하십시오:
GCP 환경에서는 메타데이터 서비스에서 노드풀 GCP SA를 가져올 수 있으며, 이를 통해 GCP에서 권한을 승격할 수 있습니다(기본적으로 compute SA가 사용됩니다).
container.secrets.get
| container.secrets.list
container.secrets.get
| container.secrets.list
이러한 권한을 사용하면 이 페이지에서 설명한대로 Kubernetes의 모든 SA의 토큰을 읽을 수 있으므로, 승격할 수 있습니다.
container.pods.exec
container.pods.exec
이 권한을 사용하면 pod에 실행할 수 있으며, 이를 통해 K8s 내에서 권한을 승격할 수 있는 모든 Kubernetes SA에 액세스할 수 있습니다. 또한 NodePool의 GCP 서비스 계정을 훔칠 수 있어 GCP에서 권한을 승격할 수 있습니다.
container.pods.portForward
container.pods.portForward
이 권한을 사용하면 이 페이지에서 설명한대로 pod에서 실행 중인 로컬 서비스에 액세스할 수 있으며, 이를 통해 Kubernetes(및 GCP)에서 권한을 승격할 수 있습니다.
container.serviceAccounts.createToken
container.serviceAccounts.createToken
이 권한의 이름으로 보아 K8s 서비스 계정의 토큰을 생성할 수 있을 것으로 보입니다. 따라서 Kubernetes 내의 모든 SA로 권한 상승이 가능합니다. 그러나 해당 API 엔드포인트를 찾지 못했으므로 찾으면 알려주세요.
container.mutatingWebhookConfigurations.create
| container.mutatingWebhookConfigurations.update
container.mutatingWebhookConfigurations.create
| container.mutatingWebhookConfigurations.update
이러한 권한은 Kubernetes에서 권한 상승이 가능할 수 있지만, 더 자주 클러스터에 영속성을 유지하기 위해 악용될 수 있습니다. 자세한 정보는 이 링크를 따르세요.
最終更新