Ensure that the Service Account User and Service Account Token Creator roles are assigned to a user for a specific GCP service account rather than to a user at the GCP project level, in order to implement the principle of least privilege (POLP). The principle of least privilege (also known as the principle of minimal privilege) is the practice of providing every user the minimal amount of access required to perform its tasks. The Service Account User (iam.serviceAccountUser) role allows an IAM user to attach a service account to a long-running job service such as an App Engine App or Dataflow Job, whereas the Service Account Token Creator (iam.serviceAccountTokenCreator) role allows a user to directly impersonate the identity of a service account.
This rule resolution is part of the Conformity Security & Compliance tool for GCP.
To follow Google Cloud security best practices, Google Cloud Platform (GCP) IAM users should not have assigned the Service Account User or Service Account Token Creator roles at the GCP project level. Instead, these roles should be allocated to a user associated with a specific service account, providing that user access to the service account only.
Audit
To determine if there are IAM users/members associated with Service Account User and/or Service Account Token Creator roles at the GCP project level, perform the following actions:
Remediation / Resolution
To implement the principle of least privilege and secure the access to your GCP projects, revoke Service Account User and Service Account Token Creator roles applied at the project level from all IAM user/member accounts and assign these roles to specific service account(s) according to your business requirements.
Step A: To revoke the Service Account User and/or Service Account Token Creator roles applied at the GCP project level, perform the following actions:
Step B: To assign the Service Account User and/or Service Account Token Creator roles to a service account instead of a GCP project, perform the following actions:
References
- Google Cloud Platform (GCP) Documentation
- Cloud Identity and Access Management (IAM)
- Service accounts
- Granting, changing, and revoking access to resources
- Understanding roles
- Understanding service accounts
- Granting, changing, and revoking access to resources
- CIS Security Documentation
- Securing Google Cloud Computing Platform
- GCP Command Line Interface (CLI) Documentation
- gcloud projects list
- gcloud projects get-iam-policy
- gcloud projects set-iam-policy
- gcloud iam service-accounts get-iam-policy
- gcloud iam service-accounts set-iam-policy