Description
Identify the service listening on each internet-facing port with its owner. Record the required protocol and clients, and remove the rule when that use ends.
Potential impact
A public address and route can make even a temporary service reachable when it starts on an allowed port.
Remediation
Set the source and ports for the service, review other rules and their priority, and verify that approved clients can connect while other sources are blocked.
Examples
Both excerpts specify nic_type = "internet" on an existing group. For VPC groups use intranet. Check addressing, routes and rules to determine actual internet reachability.
Before
resource "alicloud_security_group_rule" "unknown_ports_open" {
type = "ingress"
ip_protocol = "tcp"
nic_type = "internet"
policy = "accept"
port_range = "54/60"
priority = 1
security_group_id = alicloud_security_group.default.id
cidr_ip = "0.0.0.0/0"
}
The first rule allows TCP 54–60 from every IPv4 source.
After
resource "alicloud_security_group_rule" "unknown_ports_open" {
type = "ingress"
ip_protocol = "tcp"
nic_type = "internet"
policy = "accept"
port_range = "22/22"
priority = 1
security_group_id = alicloud_security_group.default.id
cidr_ip = "10.159.6.18/32"
}
The second replaces that range with TCP 22 for SSH and permits only 10.159.6.18/32. Use it only if SSH administration is the required service, and supply the approved source address seen on the management path.