Awesome Reviewers

Reviewer · Security

Restrict network ingress scope

When defining security groups or firewall rules in infrastructure code, always apply least-privilege principles to ingress access. Never hardcode ports open for every target; instead expose a configurable ingress variable (e.g., `ports_ingress`) so each module/service only opens the specific ports it actually needs. Avoid broad or "allow-all" CIDR ranges:...

Instruction

When defining security groups or firewall rules in infrastructure code, always apply least-privilege principles to ingress access. Never hardcode ports open for every target; instead expose a configurable ingress variable (e.g., ports_ingress) so each module/service only opens the specific ports it actually needs. Avoid broad or “allow-all” CIDR ranges: do not default to 0.0.0.0 or similar wide-open sources for administrative access like SSH, and double-check CIDR construction so a bug doesn’t accidentally negate the restriction (e.g., appending /0 to an IP turns it into “any address”, defeating the purpose of the allow-list).

Bad:

cidr_blocks = flatten([
  formatlist("%s/32", var.ssh_allow_ips),
  formatlist("%s/0", var.ssh_allow_ips) # exposes to the entire internet
])
...
variables {
  ssh_allow_ips = ["0.0.0.0"] # opens SSH to everyone
}

Good:

# Only allow SSH from already-trusted internal subnets/runners; no public allow-list needed
cidr_blocks = flatten([
  formatlist("%s/32", data.enos_environment.localhost.public_ipv4_addresses),
  join(",", data.aws_vpc.vpc.cidr_block_associations.*.cidr_block),
])

# Use a dedicated variable to scope exactly which ports are opened per module,
# instead of always opening ports like 389 for every target.
variable "ports_ingress" {
  type    = list(object({ port = number, protocol = string, description = string }))
  default = []
}

Before merging any change that touches security groups or ingress rules, verify: (1) only required ports are opened, (2) no CIDR range unintentionally grants broader access than intended, and (3) sensitive access (SSH, management ports) relies on existing trusted network boundaries rather than new public allow-lists.</description> </invoke>