terraform.gcp.security.gcp-compute-firewall-unrestricted-ingress-21.gcp-compute-firewall-unrestricted-ingress-21
semgrep
Author
unknown
Download Count*
License
Ensure Google compute firewall ingress does not allow unrestricted FTP access
Run Locally
Run in CI
Defintion
rules:
- id: gcp-compute-firewall-unrestricted-ingress-21
patterns:
- pattern: resource
- pattern-either:
- pattern-inside: |
resource "google_compute_firewall" "..." {
...
allow {
protocol = "tcp"
ports = [21]
}
source_ranges = ["0.0.0.0/0"]
...
}
- pattern-inside: |
resource "google_compute_firewall" "..." {
...
allow {
protocol = "tcp"
ports = [..., "21", ...]
}
source_ranges = ["0.0.0.0/0"]
...
}
message: Ensure Google compute firewall ingress does not allow unrestricted FTP
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-21.tf
# ok: gcp-compute-firewall-unrestricted-ingress-21
resource "google_compute_firewall" "restricted" {
name = "example"
network = "google_compute_network.vpc.name"
allow {
protocol = "tcp"
ports = ["21"]
}
source_ranges = ["172.1.2.3/32"]
target_tags = ["ftp"]
}
# ok: gcp-compute-firewall-unrestricted-ingress-21
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 = ["ftp"]
}
# ok: gcp-compute-firewall-unrestricted-ingress-21
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 = ["ftp"]
}
# fail
# ruleid: gcp-compute-firewall-unrestricted-ingress-21
resource "google_compute_firewall" "allow_ftp_int" {
name = "example"
network = "google_compute_network.vpc.name"
allow {
protocol = "tcp"
ports = [21]
}
source_ranges = ["0.0.0.0/0"]
}
# fail
# ruleid: gcp-compute-firewall-unrestricted-ingress-21
resource "google_compute_firewall" "allow_multiple" {
name = "example"
network = "google_compute_network.vpc.name"
allow {
protocol = "tcp"
ports = ["1024-65535", "21"]
}
source_ranges = ["0.0.0.0/0"]
}
Short Link: https://sg.run/Bqox