Control: Ensure that instances are not configured to use the default service account with full access to all Cloud APIs
Description
To support principle of least privileges and prevent potential privilege escalation it is recommended that instances are not assigned to default service account Compute Engine default service account with Scope Allow full access to all Cloud APIs.
Usage
Run the control in your terminal:
powerpipe control run gcp_compliance.control.compute_instance_with_no_default_service_account_with_full_access
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run gcp_compliance.control.compute_instance_with_no_default_service_account_with_full_access --share
SQL
This control uses a named query:
select self_link resource, case when name like 'gke-%' and labels ? 'goog-gke-node' then 'skip' when account ->> 'email' like '%-compute@developer.gserviceaccount.com' and account -> 'scopes' ? 'https://www.googleapis.com/auth/cloud-platform' then 'alarm' else 'ok' end as status, case when name like 'gke-%' and labels ? 'goog-gke-node' then title || ' created by GKE.' when account ->> 'email' like '%-compute@developer.gserviceaccount.com' and account -> 'scopes' ? 'https://www.googleapis.com/auth/cloud-platform' then title || ' configured with default service account with full access.' else title || ' not configured with default service account with full access.' end as reason , location as location, project as projectfrom gcp_compute_instance, jsonb_array_elements(service_accounts) account;