SKY-D400 · Deployment and infrastructure
Terraform security group opens SSH or RDP to the whole internet
An AWS security group is a firewall for servers. SKY-D400 reports a Terraform security group rule that lets any address on the internet (0.0.0.0/0 or ::/0) reach the administrative ports 22 (SSH) or 3389 (Remote Desktop).
- Languages
- Terraform
- Quality gate
- counted toward the gate limits (full and diff scans). Reported under security (
danger). It counts towardmax_highandmax_security; the rule never reports CRITICAL. - Finding type
- review
- Catalog name
- Terraform AWS worldwide administrative ingress
Why it matters
Internet-wide scanners try passwords and known exploits on these ports within minutes of a server coming up. One weak password or unpatched SSH or RDP service then gives an attacker a shell inside your network.
What Skylos flags
variable "vpc_id" { type = string} resource "aws_security_group" "bastion" { name = "bastion" vpc_id = var.vpc_id ingress { description = "SSH" from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] }}What Skylos leaves alone
variable "vpc_id" { type = string} resource "aws_security_group" "bastion" { name = "bastion" vpc_id = var.vpc_id ingress { description = "SSH from the office VPN" from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["10.20.0.0/16"] }}Why Skylos leaves it alone
The same SSH rule, but the source is the private VPN range 10.20.0.0/16, not the whole internet. Skylos merges all source ranges of a rule and reports only when together they cover every IPv4 or every IPv6 address.
More languages
Terraform
Flagged
resource "aws_vpc_security_group_ingress_rule" "rdp" { security_group_id = aws_security_group.windows.id ip_protocol = "tcp" from_port = 3389 to_port = 3389 cidr_ipv6 = "::/0"}Not flagged
resource "aws_vpc_security_group_ingress_rule" "https" { security_group_id = aws_security_group.windows.id ip_protocol = "tcp" from_port = 443 to_port = 443 cidr_ipv6 = "::/0"}Why Skylos leaves it alone
Opening HTTPS (443) to everyone is normal for a public web server. Only ranges that include port 22 or 3389 (or every protocol, -1) count.
How Skylos decides
- Runs with
--danger(or-a). Reads.tfand.tf.jsonfiles, skipping.terraform,.git,node_modules,vendor,build,distand virtual-environment folders, and parses them as HCL without running Terraform or contacting AWS. - Resolves only literal values and
localvalues of the same module. Input variables, data sources, attributes of other resources and module outputs stay unknown, and an unknown value never produces a finding. - Skips a resource with
count = 0or an emptyfor_each, and needs the official AWS provider (hashicorp/aws, which anaws_resource uses unless another provider is configured). - Checks
ingressblocks ofaws_security_group,aws_security_group_rulewithtype = "ingress", andaws_vpc_security_group_ingress_rule. - A rule counts as administrative when its protocol is TCP (
tcpor6) and its port range includes 22 or 3389, or when the protocol is all (-1). UDP and ICMP rules are left alone. - Merges the rule's IPv4 and IPv6 source ranges and reports when they cover a whole address family, so
0.0.0.0/1plus128.0.0.0/1counts as the whole internet. Rules whose source is another security group or a prefix list are not reported. - Reports HIGH on the
resourceline, once per resource.
How to fix it
Allow SSH and RDP only from known ranges such as a VPN, or close the ports and use AWS Systems Manager Session Manager or EC2 Instance Connect instead.
variable "vpc_id" { type = string} resource "aws_security_group" "bastion" { name = "bastion" vpc_id = var.vpc_id ingress {Removed: description = "SSH"Added: description = "SSH from the office VPN" from_port = 22 to_port = 22 protocol = "tcp"Removed: cidr_blocks = ["0.0.0.0/0"]Added: cidr_blocks = ["10.20.0.0/16"] }}When it can be wrong
- Values that come from variables, modules or other resources are not checked, because Skylos does not run Terraform:
cidr_blocks = var.admin_cidrsis not reported even when its default is0.0.0.0/0. - It judges the declaration only. It does not know what is deployed, and other settings (account defaults, security groups, routing) can make the real exposure smaller or larger.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Terraform rules read no inline marker:
# skylos: ignore[SKY-D400]on the resource line does not hide the finding.[tool.skylos] ignore = ["SKY-D400"]turns the rule off for the project.A baseline (
skylos baseline ., then--baseline) accepts the declarations that exist today and reports new ones.