> 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/public-exposure/appsec2-gcp-6.md).

# GCP KMS crypto key is anonymously accessible misconfiguration detected in code

## Rule Details

|                        |                                            |
| ---------------------- | ------------------------------------------ |
| Cortex AppSec Rule ID  | APPSEC2\_GCP\_6                            |
| Category - Subcategory | Public Exposure - Encryption And Protocols |
| Provider               | GCP                                        |
| Severity               | MEDIUM                                     |
| Framework              | Terraform, Terraform Plan                  |
| Mapped CSPM/KSPM Rule  | 4b718a26-51ce-47d3-bb0a-1ba56d4a528f       |

## Impact

It is recommended that the IAM policy on Cloud KMS cryptokeys should restrict anonymous and/or public access. Granting permissions to allUsers or allAuthenticatedUsers allows anyone to access the dataset. Such access might not be desirable if sensitive data is stored at the location. In this case, ensure that anonymous and/or public access to a Cloud KMS cryptokey is not allowed.

## How to Fix

*Resource:* google\_kms\_crypto\_key

* *Arguments:* google\_kms\_crypto\_key\_iam\_member / google\_kms\_crypto\_key\_iam\_binding \[source,go]

***

{ "resource "google\_kms\_key\_ring" "keyring" { name = "keyring-example" location = "global" }

resource "google\_kms\_crypto\_key" "bad\_key" { name = "crypto-key-example" key\_ring = google\_kms\_key\_ring.keyring.id rotation\_period = "100000s" lifecycle { prevent\_destroy = true }

}

resource "google\_kms\_crypto\_key\_iam\_member" "bad\_member\_1" { crypto\_key\_id = google\_kms\_crypto\_key.bad\_key.id role = "roles/cloudkms.cryptoKeyEncrypter"

* member = "allUsers" }

resource "google\_kms\_crypto\_key\_iam\_member" "bad\_member\_2" { crypto\_key\_id = google\_kms\_crypto\_key.bad\_key.id role = "roles/cloudkms.cryptoKeyEncrypter"

* member = "allAuthenticatedUsers" }

resource "google\_kms\_crypto\_key\_iam\_binding" "bad\_binding\_1" { crypto\_key\_id = google\_kms\_crypto\_key.bad\_key.id role = "roles/cloudkms.cryptoKeyEncrypter"

* members = \[
* "allUsers",
* ] }

resource "google\_kms\_crypto\_key\_iam\_binding" "bad\_binding\_2" { crypto\_key\_id = google\_kms\_crypto\_key.bad\_key.id role = "roles/cloudkms.cryptoKeyEncrypter"

* members = \[
* "allAuthenticatedUsers",
* ] }

resource "google\_kms\_crypto\_key" "good\_key" { name = "crypto-key-example" key\_ring = google\_kms\_key\_ring.keyring.id rotation\_period = "100000s" lifecycle { prevent\_destroy = true }

}

resource "google\_kms\_crypto\_key\_iam\_member" "good\_member" { crypto\_key\_id = google\_kms\_crypto\_key.good\_key.id role = "roles/cloudkms.cryptoKeyEncrypter"

* member = "user:<jane@example.com>" }

resource "google\_kms\_crypto\_key\_iam\_binding" "good\_binding" { crypto\_key\_id = google\_kms\_crypto\_key.good\_key.id role = "roles/cloudkms.cryptoKeyEncrypter"

* members = \[
* "user:<jane@example.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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/public-exposure/appsec2-gcp-6.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
