防止 GCP 中的 IAM 升级

Prevent IAM escalation in GCP

我想创建一个 GCP 项目并向团队授予特定 API 的访问权限。

但我希望他们是自治的:他们应该能够在我允许的范围内创建自己的服务帐户。

问题是,如果我给他们 IAM 编辑权限,他们可以授予自己项目中的任何其他权限。

Kubernetes 的 RBAC API 非常适合用户 who is able to modify the roles can't put more permission than the ones he has

那么是否可以让具有云 SQL 管理员角色的用户允许他向服务帐户授予类似的权限,同时阻止他授予云存储权限?

遗憾的是没有。无法阻止 "roles/permission escalation"。如果某人是 IAM 管理员,他可以分配她想要的角色,甚至可以分配给他自己和更高的角色,他们隐藏当前权限。

但是,您有政策允许您限制项目或组织的事情:允许 API、允许外部帐户、public IP...

I want to create a GCP project and to grant access on specific APIs / permissions to a team.

您可以为服务做到这一点,这是 Google IAM 存在的原因之一。您不能专门为 API 指定角色 - 您可以通过不授予启用服务的权限来阻止启用任何 API。您可以使用组织策略约束来防止为项目启用某些 API,但不能为个人启用。

But I want them to be autonomous : they should be able to create their own service accounts on the scopes I allow.

Google Cloud IAM 不支持此功能。如果您有权创建服务帐户 (roles/iam.serviceAccountAdmin),您也有权为该服务帐户分配角色。这是管理员级别的权限,应该只授予管理员而不是普通用户。谨慎管理此角色,因为管理员可以创建具有项目所有者角色的服务帐户。

So is it possible to have for example a user with the Cloud SQL admin role, to allow him to grant similar permissions to service accounts, but also to prevent him from granting Cloud Storage permissions ?

这是不支持的。要获得向服务帐户分配角色的权限,您必须是服务帐户管理员。

根据此处的文档,这似乎是可能的:

https://cloud.google.com/iam/docs/setting-limits-on-granting-roles

In large organizations, it can be helpful to let teams independently manage the Identity and Access Management (IAM) policies for their resources. However, letting a principal grant or revoke all IAM roles can greatly increase your security risk.

给定用例:

Consider a scenario where you want to let a user, Finn (finn@example.com), act as a limited IAM admin for your project. You want Finn to be able to grant and revoke only the Billing Account Administrator (roles/billing.admin) and Billing Account User (roles/billing.user) roles for your project.

我正在努力实现同样的目标。我希望 Terraform 服务帐户能够做它需要做的一切,除了允许用户将他们的角色提升到项目范围之外(即没有所有者级别的角色,只有资源级别的角色)。