> 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 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/public-exposure/appsec2-gcp-18.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.
