Tencent Cloud security-group rule allows all traffic from every address

Restrict inbound rules to required sources, protocols and ports.

Description

In a Tencent Cloud security group, an ACCEPT rule from 0.0.0.0/0 covers all IPv4 sources. The equivalent for IPv6 is ::/0. Even a public service needs only its own protocols and ports.

Potential impact

An external client may reach a management or internal service if the resource is routable and the service is listening.

Remediation

Check cidr_block and ipv6_cidr_block separately alongside protocol, ports and rule priority. Limit administrative access to approved paths. Test permitted and denied connections to the associated resource with its host firewall in place.

Examples

Define the referenced tencentcloud_security_group.sg separately. Manage its rules through this rule set alone and retain the other rules the group needs.

Before

hcl
resource "tencentcloud_security_group_rule_set" "base" {
  security_group_id = tencentcloud_security_group.sg.id

  ingress {
    action     = "ACCEPT"
    cidr_block = "0.0.0.0/0"
    protocol   = "ALL"
    port       = "ALL"
  }
}

The first rule accepts every protocol and port from all IPv4 sources.

After

hcl
resource "tencentcloud_security_group_rule_set" "base" {
  security_group_id = tencentcloud_security_group.sg.id

  ingress {
    action      = "ACCEPT"
    cidr_block  = "10.0.0.0/22"
    protocol    = "TCP"
    port        = "80-90"
    description = "Allow internal application traffic"
  }
}

The second accepts TCP 80–90 from 10.0.0.0/22. Adjust both ranges to the clients and ports that actually need access.

References