Incident Response in GCP: Out of Scope – Ouf of Mind
嗯,用户让我用中文总结一篇文章,控制在100字以内,而且不需要特定的开头。首先,我得仔细阅读文章内容,理解主要观点。 文章主要讲的是GCP(Google Cloud Platform)中的服务账户和访问范围的问题。特别是默认服务账户权限过大,而访问范围设置不当可能带来的安全风险。作者提到很多安全审计工具忽略了访问范围的检查,导致潜在的安全漏洞被忽视。 接下来,我需要提取关键点:服务账户、默认权限、访问范围的作用、审计工具的不足、手动检查方法以及建议的最佳实践。然后把这些信息浓缩成一段简短的文字。 要注意用词简洁,确保在100字以内。同时,避免使用复杂的术语,让总结易于理解。 最后,检查是否涵盖了所有重要信息,并且没有遗漏关键点。确保语言流畅自然。 </think> 文章讨论了Google Cloud Platform(GCP)中服务账户和访问范围的安全问题。默认服务账户拥有过高的权限,而访问范围设置不当可能导致严重安全风险。许多安全审计工具未能检测到这些配置问题。建议限制默认服务账户权限、使用最小权限的服务账户,并避免非标准访问范围配置以提高安全性。 2026-1-27 13:43:40 Author: insinuator.net(查看原文) 阅读量:9 收藏

We are regularly offering a GCP Incident Response and Analysis training. In this training, we analyze resources in GCP cloud together with our trainees that were successfully compromised by attackers, e.g., GCE instances and Cloud Build projects. Therefore, we need tooling that quickly detects misconfiguration of resources that helped the attacker during the compromise. During the analysis of different tools and different kinds of misconfiguration we realized that GCE instance access scopes are a blind spot of many (in fact all that we tested) security audit tools. In this blog post, we want to elaborate on the problems that arise from this behavior.

First, let’s look at what Service Accounts are and how they are restricted by access scopes.

Service Accounts and Default Service Accounts

Service Accounts are IAM principals (user accounts) that can be used by resources (e.g., GCE instances) to access other resources (e.g., container registries) with the permissions that were granted to the Service Account.

When creating a GCE instance we can define the Service Account that the GCE instance should use during its lifetime (see screenshot below).

Security configuration tab of the GCE instance creation dialog in GCP
Security configuration tab of the GCE instance creation dialog in GCP.

As we can see in the screenshot, the Compute Engine default service account is preselected in the web interface (but we can change it to some other Service Account or even no Service Account). This Service Account is automatically generated when creating a GCP project. If GCP organization policies do not restrict the permissions of the Compute Engine default service account, the default role of this Service Account is Editor (see screenshot below).

Screenshot of the IAM overview of the Default Service Account
Screenshot of the IAM overview of the Default Service Account.

As the IAM overview already indicates, the Editor role grants the principal a wide range of permissions, e.g., to create, delete, or change configuration and resources in the whole project.

This seems bad: All instances run with a Default Service Account that grants excessive permissions to all kinds of resources in the project! What if an instance gets pwnd?

That’s why access scopes exist:

Access Scopes

Because misconfigured Service Accounts and the Default Service Account may have excessive permissions that would allow attackers to immediately compromise the whole GCP project after compromising just a single GCE instance, there is another safeguard, so-called access scopes. Even if the Service Account is allowed to access, e.g., container registries, it cannot access them if the access scopes do not allow it.

The screenshot above shows that by default a standard set of access scopes is used. According to the GCP documentation this is:

  • Read-only access to Cloud Storage.
  • Write access to write Compute Engine logs.
  • Write access to publish metric data to your Google Cloud projects.
  • Read-only access to Service Management features required for Google Cloud Endpoints.
  • Read or write access to Service Control features required for Google Cloud Endpoints.
  • Write access to Cloud Trace allows an application running on a VM to write trace data to a project.

But – as we can see in the screenshot – there are options to configure access scopes differently. This allows us to grant the GCE instance access to many resources (if the Service Account has the according permissions). The following screenshot shows what kind of scopes we can configure.

Access scope customization during GCE instance creation
Access scope customization during GCE instance creation.

A dangerous change would be here to set the “Compute Engine” option to “Read Write”. The effect would be – since the Default Service Account has Editor permissions – that the GCE instance can change firewall policies or spawn completely unrestricted GCE instances.

Auditing Access Scopes

We see that a simple change in the configuration can have severe side effects – it would be a shame if audit tools would miss such a misconfiguration.

However, our experience is that tools, such as steampipe/powerpipe, gcp_scanner, and others do not check or report a dangerous use of insecure access scopes together with excessive permissions of Service Accounts. A security audit based just on the output of such tools is incomplete and may give a false sense of security.

If you want to manually check the access scopes of an instance that you have access to, you can use this simple command to query them:

curl "http://metadata.google.internal/computeMetadata/v1/?recursive=true" -H "Metadata-Flavor: Google" | jq ".instance.serviceAccounts"

For an instance that uses the default access scopes, you will see an output that contains these lines:

"scopes": [
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring.write",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append"
]

Another output with wider, insecure settings looks as follows. Here, we gave full access to Compute Engine and full access to Storage:

"scopes": [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring.write",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append"
]

A third, very insecure output looks like below. Here, we chose the Allow full access to all Cloud APIs option at instance creation:

"scopes": [
"https://www.googleapis.com/auth/cloud-platform"
]

Conclusion

From our perspective, there are two things to learn from this:

  1. Do not rely solely on audit tools – they miss edge cases.
  2. Security baselines and best practices exist for a reason:
    1. Do not use the Default Service Account or restrict its permissions
    2. Better: Use Service Accounts for each resource with a minimal set of permissions or no Service Account at all
    3. Look for non-standard scopes and try to avoid them

If you want to learn more about GCP security, join us in our next GCP Incident Response and Analysis training that we offer publicly on April 22nd-23rd, 2026 via our training partner HM Trainings solutions.

Cheers,
Florian


文章来源: https://insinuator.net/2026/01/incident-response-in-gcp-out-of-scope-ouf-of-mind/
如有侵权请联系:admin#unsafe.sh