1.4 Ensure That There Are Only GCP-Managed Service Account Keys for Each Service Account

Information

User managed service accounts should not have user-managed keys.

Rationale:

Anyone who has access to the keys will be able to access resources through the service account. GCP-managed keys are used by Cloud Platform services such as App Engine and Compute Engine. These keys cannot be downloaded. Google will keep the keys and automatically rotate them on an approximately weekly basis. User-managed keys are created, downloadable, and managed by users. They expire 10 years from creation.

For user-managed keys, the user has to take ownership of key management activities which include:

Key storage

Key distribution

Key revocation

Key rotation

Protecting the keys from unauthorized users

Key recovery

Even with key owner precautions, keys can be easily leaked by common development malpractices like checking keys into the source code or leaving them in the Downloads directory, or accidentally leaving them on support blogs/channels.

It is recommended to prevent user-managed service account keys.

Impact:

Deleting user-managed Service Account Keys may break communication with the applications using the corresponding keys.

Solution

From Google Cloud Console

Go to the IAM page in the GCP Console using https://console.cloud.google.com/iam-admin/iam

In the left navigation pane, click Service accounts. All service accounts and their corresponding keys are listed.

Click the service account.

Click the edit and delete the keys.

From Google Cloud CLI
To delete a user managed Service Account Key,

gcloud iam service-accounts keys delete --iam-account=<user-managed-service-account-EMAIL> <KEY-ID>

Prevention:
You can disable service account key creation through the Disable service account key creation Organization policy by visiting https://console.cloud.google.com/iam-admin/orgpolicies/iam-disableServiceAccountKeyCreation. Learn more at: https://cloud.google.com/resource-manager/docs/organization-policy/restricting-service-accounts
In addition, if you do not need to have service accounts in your project, you can also prevent the creation of service accounts through the Disable service account creation Organization policy: https://console.cloud.google.com/iam-admin/orgpolicies/iam-disableServiceAccountCreation.

Default Value:

By default, there are no user-managed keys created for user-managed service accounts.

See Also

https://workbench.cisecurity.org/benchmarks/9562

Item Details

Category: IDENTIFICATION AND AUTHENTICATION

References: 800-53|IA-5

Plugin: GCP

Control ID: 8699e40e49dcc23d34c0e77fd399965b8df4569b618ce7233aea18383e252f2d