Terraform opens a security group to 0.0.0.0/0
An aws_security_group (or equivalent) with an ingress block of cidr_blocks = ["0.0.0.0/0"] opens that port to the whole internet the moment it's applied. The same pattern exists for GCP source_ranges and Azure rules.
Why it matters
Infrastructure-as-code makes one risky line reproducible across every environment — the exposure lands everywhere the module is used.
Catching it at the pull request, before apply, is far cheaper than finding the open port in production.
How to check for it
- Scan .tf for ingress ... cidr_blocks with 0.0.0.0/0 (or ::/0) on admin/database ports.
- SkyShield's IaC checks flag this at the code level; tfsec/Checkov do too in CI.
How to fix it
- Parameterise the allowed CIDRs and default them to your known ranges; never hardcode 0.0.0.0/0 on sensitive ports.
- Add a policy check (OPA/Conftest or the scanner) to your pipeline so a world-open rule fails the build.
SkyShield checks this automatically
Connect your AWS, Cloudflare, GitHub, GitLab, Hetzner or DigitalOcean account read-only and SkyShield flags this across every account and region, with the fix in plain words — alongside the agent that watches your servers. Start free.
FAQ
- Is 0.0.0.0/0 ever fine in Terraform?
- Only for a genuinely public port (80/443) behind a load balancer. For SSH, RDP and databases, scope it to known sources.