> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/iam/appsec-gcp-45.md).

# Roles impersonate or manage Service Accounts used at organizational level misconfiguration detected

## Rule Details

|                        |                           |
| ---------------------- | ------------------------- |
| Cortex AppSec Rule ID  | APPSEC\_GCP\_45           |
| Category - Subcategory | IAM - Overly Permissive   |
| Provider               | GCP                       |
| Severity               | HIGH                      |
| Framework              | Terraform, Terraform Plan |

## Impact

The IAM role is an identity with specific permissions. An IAM role is similar to an IAM user: it has a Google identity with permission policies that determine what the identity can and cannot do in Google Cloud.

Certain IAM roles contain permissions that enable a user with the role to impersonate or manage service accounts in a GCP folder through IAM inheritance from a higher resource, i.e., folder binding.

We recommend you do not set IAM role bindings with known dangerous roles that enable impersonation at the organizational level.

The following roles enable identities to impersonate all service account identities within a project if the identity is granted the role at the project, folder, or organization level. The following list includes our *current* recommendations for dangerous roles, however, it is not exhaustive as permissions and roles change frequently.

*Primitive Roles*:

* roles/owner
* roles/editor

*Predefined Roles and Service Agent Roles*:

Service agent roles should not be used for any identities other than the Google managed service account they are associated with.

* roles/iam.serviceAccountUser
* roles/iam.serviceAccountTokenCreator
* roles/iam.serviceAccountKeyAdmin
* roles/iam.serviceAccountAdmin
* roles/iam.workloadIdentityUser
* roles/deploymentmanager.editor
* roles/cloudbuild.builds.editor
* roles/aiplatform.customCodeServiceAgent
* roles/aiplatform.extensionServiceAgent
* roles/aiplatform.serviceAgent
* roles/apigateway.serviceAgent
* roles/apigee.serviceAgent
* roles/appengine.serviceAgent
* roles/appengineflex.serviceAgent
* roles/bigquerycontinuousquery.serviceAgent
* roles/bigquerydatatransfer.serviceAgent
* roles/bigqueryspark.serviceAgent
* roles/cloudbuild.serviceAgent
* roles/cloudconfig.serviceAgent
* roles/clouddeploy.serviceAgent
* roles/cloudfunctions.serviceAgent
* roles/cloudscheduler.serviceAgent
* roles/cloudtasks.serviceAgent
* roles/composer.serviceAgent
* roles/compute.serviceAgent
* roles/connectors.serviceAgent
* roles/dataflow\.serviceAgent
* roles/dataproc.serviceAgent
* roles/eventarc.serviceAgent
* roles/integrations.serviceAgent
* roles/ml.serviceAgent
* roles/notebooks.serviceAgent
* roles/pubsub.serviceAgent
* roles/run.serviceAgent
* roles/serverless.serviceAgent
* roles/sourcerepo.serviceAgent
* roles/workflows.serviceAgent
* roles/iam.serviceAccountOpenIdTokenCreator
* roles/aiplatform.colabServiceAgent
* roles/backupdr.computeEngineOperator
* roles/backupdr.serviceAgent
* roles/batch.serviceAgent
* roles/clouddeploymentmanager.serviceAgent
* roles/cloudtpu.serviceAgent
* roles/compute.instanceGroupManagerServiceAgent
* roles/configdelivery.serviceAgent
* roles/container.serviceAgent
* roles/datapipelines.serviceAgent
* roles/dataplex.serviceAgent
* roles/dataprep.serviceAgent
* roles/dataproc.hubAgent
* roles/firebaseapphosting.serviceAgent
* roles/firebasemods.serviceAgent
* roles/gameservices.serviceAgent
* roles/genomics.serviceAgent
* roles/krmapihosting.anthosApiEndpointServiceAgent
* roles/krmapihosting.serviceAgent
* roles/lifesciences.serviceAgent
* roles/osconfig.serviceAgent
* roles/runapps.serviceAgent
* roles/securitycenter.securityResponseServiceAgent
* roles/workstations.serviceAgent
* roles/securesourcemanager.serviceAgent
* roles/assuredoss.admin
* roles/securitycenter.admin
* roles/vpcaccess.serviceAgent
* roles/cloudbuild.builds.builder
* roles/composer.worker
* roles/dataflow\.admin
* roles/dataflow\.developer
* roles/run.sourceDeveloper

## How to Fix

*Resource:* google\_organization\_iam\_member google\_organization\_iam\_binding

* *Argument:* role \[source,go]

***

resource "google\_organization\_iam\_member" "example" { org\_id = "your-org-id"

* role = member = "user:<test@example-project.iam.gserviceaccount.com>" }

***

resource "google\_project\_iam\_binding" "example" { org\_id = "your-org-id"

* role = members = \[ "user:<test@example-project.iam.gserviceaccount.com>", ] }

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/iam/appsec-gcp-45.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
