Security Groups with 0.0.0.0/0 CIDR Blocks
Security groups configured to allow inbound traffic from any IP address (0.0.0.0/0) on sensitive ports like SSH, RDP, or databases.
A high-severity security vulnerability where cloud security groups, network ACLs, and firewall rules are configured with overly broad permissions, allowing unrestricted or excessive network access to cloud resources. This includes rules that allow traffic from any source (0.0.0.0/0), open dangerous ports, permit protocols beyond requirements, or grant access to administrative interfaces from the internet.
# VULNERABLE: SSH accessible from internet
resource "aws_security_group" "web_sg" {
name = "web-security-group"
vpc_id = aws_vpc.main.id
# VULNERABLE: SSH from anywhere
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # DANGEROUS!
description = "SSH access"
}
# VULNERABLE: Database port exposed
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # DANGEROUS!
description = "PostgreSQL"
}
}# SECURE: Restricted access via security groups
resource "aws_security_group" "web_sg" {
name = "web-security-group"
vpc_id = aws_vpc.main.id
# SECURE: SSH only from bastion
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
security_groups = [aws_security_group.bastion_sg.id]
description = "SSH from bastion only"
}
# SECURE: Database access from app tier only
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
security_groups = [aws_security_group.app_sg.id]
description = "PostgreSQL from app tier only"
}
}The vulnerable configuration allows SSH and database access from any IP address (0.0.0.0/0), exposing critical services to the internet. The secure version restricts access using security group references, allowing SSH only from a bastion host and database access only from the application tier.
Security groups configured to allow inbound traffic from any IP address (0.0.0.0/0) on sensitive ports like SSH, RDP, or databases.
Sourcery automatically identifies overly permissive cloud security groups and firewall rules and many other security issues in your codebase.