> 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-18.md).

# Google Cloud Platform network is not ensured to define a firewall misconfiguration detected in code

## Rule Details

|                        |                                    |
| ---------------------- | ---------------------------------- |
| Cortex AppSec Rule ID  | APPSEC2\_GCP\_18                   |
| Category - Subcategory | Public Exposure - Ingress Controls |
| Provider               | GCP                                |
| Severity               | MEDIUM                             |
| Framework              | Terraform, Terraform Plan          |

## Impact

This rule is verifying that a Google Cloud Platform (GCP) network has a defined firewall and is not using the default firewall settings. By using the default firewall settings, a network may expose vulnerabilities or unnecessary access points, thereby increasing the risk of unauthorized access and potential data breaches. Therefore, it is essential to define a custom firewall rule that aligns with the specific security needs of the network.

## How to Fix

*Resource:* google\_compute\_network, google\_compute\_firewall

To fix this issue, you need to create a new firewall in the GCP network and make sure it does not use the default firewall. You can do this by defining it in your Terraform scripts.

## \[source,go]

resource "google\_compute\_firewall" "default" { name = "test-firewall" network = google\_compute\_network.default.self\_link

allow { protocol = "icmp" } allow { protocol = "tcp" ports = \["80", "443"] } }

## resource "google\_compute\_network" "default" { name = "test-network" auto\_create\_subnetworks = "false" }

This Terraform code creates custom network and firewall which does not rely on default firewall. The firewall rule `test-firewall` is associated with the custom network `test-network`, thus the GCP network no longer uses the default firewall. It has specific rules which only allows traffic on ICMP protocol and TCP ports 80 and 443, reducing the attack surface.


---

# 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-18.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.
