Compute instance uses the default service account with full access to all Cloud APIs Affecting Compute Engine service in Google


    Severity Framework
    Snyk CCSS
    Rule category
    IAM / Least Privilege

Is your enviroment affected by this misconfiguration?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-CC-00205
  • credit Snyk Research Team


The default Compute Engine service account "Editor" role is assigned with three possible scopes. Avoid allowing the scope for full access to all Cloud APIs, as this may enable users accessing the Compute Engine instance to perform cloud operations outside the scope of responsibility, or increase the potential impact of a compromised instance. Note that GKE-created instances should be exempted from this.

How to fix?

Set the service_account.scopes attribute to a scope that is not cloud-platform or

Example Configuration

resource "google_service_account" "test" {
  account_id   = "test-service-account"
  display_name = "Test Service Account"

resource "google_compute_instance" "test" {
  name         = "no-metadata-keys-set"
  machine_type = "e2-micro"
  zone         = "us-east1-b"

  service_account {
    email  =
    scopes = ["logging-write"]

  boot_disk {
    initialize_params {
      image = "debian-10-buster-v20221102"

  network_interface {
    network = "default"