Description
When a sensitive port allows every IPv4 source, identify the listening service and who needs public access. Limit internal and administrative services to their required ports and approved clients.
Potential impact
Where an internet path exists, external clients can attempt connections. Weak authentication or an unpatched service can put data and administrative functions at risk.
Remediation
Remove unnecessary public grants and document the services that must stay public. Check other rules, the connection path, service authentication and security updates. Test access from an approved and an unapproved source.
Examples
Both rules reference an existing security group. The excerpts use nic_type = "internet". For a VPC group, use intranet and verify public reachability separately.
Before
resource "alicloud_security_group_rule" "sensitive_port_open" {
type = "ingress"
ip_protocol = "tcp"
nic_type = "internet"
policy = "accept"
port_range = "19/20"
priority = 1
security_group_id = alicloud_security_group.default.id
cidr_ip = "0.0.0.0/0"
}
The first rule allows TCP 19–20 from 0.0.0.0/0.
After
resource "alicloud_security_group_rule" "sensitive_port_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 allows TCP 22 for SSH in place of TCP 19–20. Use it only if SSH is the intended service, and replace 10.159.6.18/32 with the source address on the actual management path.