Skip to content

Files

Latest commit

 

History

History
41 lines (30 loc) · 1.02 KB

google-iam-no-privileged-service-accounts.md

File metadata and controls

41 lines (30 loc) · 1.02 KB

Pattern: Privileged service account for Google IAM

Issue: -

Description

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.

Resolution: Limit service account access to minimal required set.

Examples

Example of incorrect code:

resource "google_service_account" "test" {
  account_id   = "account123"
  display_name = "account123"
}

resource "google_project_iam_member" "project" {
	project = "your-project-id"
	role    = "roles/owner"
	member  = "serviceAccount:${google_service_account.test.email}"
}

Example of correct code:

resource "google_service_account" "test" {
	account_id   = "account123"
	display_name = "account123"
}

resource "google_project_iam_member" "project" {
	project = "your-project-id"
	role    = "roles/logging.logWriter"
	member  = "serviceAccount:${google_service_account.test.email}"
}