terraform.gcp.security.gcp-compute-firewall-unrestricted-ingress-80.gcp-compute-firewall-unrestricted-ingress-80
semgrep
Author
unknown
Download Count*
License
Ensure Google compute firewall ingress does not allow unrestricted HTTP access
Run Locally
Run in CI
Defintion
rules:
- id: gcp-compute-firewall-unrestricted-ingress-80
patterns:
- pattern: resource
- pattern-either:
- pattern-inside: |
resource "google_compute_firewall" "..." {
...
allow {
protocol = "tcp"
ports = [80]
}
source_ranges = ["0.0.0.0/0"]
...
}
- pattern-inside: |
resource "google_compute_firewall" "..." {
...
allow {
protocol = "tcp"
ports = [..., "80", ...]
}
source_ranges = ["0.0.0.0/0"]
...
}
message: Ensure Google compute firewall ingress does not allow unrestricted HTTP
access
metadata:
owasp:
- A05:2017 - Broken Access Control
- A01:2021 - Broken Access Control
cwe:
- "CWE-284: Improper Access Control"
category: security
technology:
- terraform
- gcp
references:
- https://docs.bridgecrew.io/docs/google-cloud-policy-index
subcategory:
- audit
likelihood: LOW
impact: LOW
confidence: LOW
license: Commons Clause License Condition v1.0[LGPL-2.1-only]
vulnerability_class:
- Improper Authorization
languages:
- hcl
severity: WARNING
Examples
gcp-compute-firewall-unrestricted-ingress-80.tf
# ok: gcp-compute-firewall-unrestricted-ingress-80
resource "google_compute_firewall" "restricted" {
name = "example"
network = "google_compute_network.vpc.name"
allow {
protocol = "tcp"
ports = ["80"]
}
source_ranges = ["172.1.2.3/32"]
target_tags = ["http"]
}
# ok: gcp-compute-firewall-unrestricted-ingress-80
resource "google_compute_firewall" "allow_different_int" {
name = "example"
network = "google_compute_network.vpc.name"
allow {
protocol = "tcp"
ports = [4624]
}
source_ranges = ["172.1.2.3/32"]
target_tags = ["http"]
}
# ok: gcp-compute-firewall-unrestricted-ingress-80
resource "google_compute_firewall" "allow_null" {
name = "example"
network = "google_compute_network.vpc.name"
allow {
protocol = "tcp"
ports = null
}
source_ranges = ["172.1.2.3/32"]
target_tags = ["http"]
}
# fail
# ruleid: gcp-compute-firewall-unrestricted-ingress-80
resource "google_compute_firewall" "allow_http_int" {
name = "example"
network = "google_compute_network.vpc.name"
allow {
protocol = "tcp"
ports = [80]
}
source_ranges = ["0.0.0.0/0"]
}
# fail
# ruleid: gcp-compute-firewall-unrestricted-ingress-80
resource "google_compute_firewall" "allow_multiple" {
name = "example"
network = "google_compute_network.vpc.name"
allow {
protocol = "tcp"
ports = ["1024-65535", "80"]
}
source_ranges = ["0.0.0.0/0"]
}
Short Link: https://sg.run/K1rL