HIGH
Source
Trivy
ID
AVD-GCP-0007

Service accounts should not have roles assigned with excessive privileges

Service accounts should have a minimal set of permissions assigned in order to do their job. They should never have excessive access as if compromised, an attacker can escalate privileges and take over the entire account.

Impact

Cloud account takeover if a resource using a service account is compromised

Follow the appropriate remediation steps below to resolve the issue.

Limit service account access to minimal required set

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 resource "google_service_account" "test" {
 	account_id   = "account123"
 	display_name = "account123"
    email        = "jim@tfsec.dev"
 }
 
 resource "google_project_iam_member" "project" {
 	project = "your-project-id"
 	role    = "roles/logging.logWriter"
 	member  = "serviceAccount:${google_service_account.test.email}"
 }