Description
Ask the owner of the service listening on TCP 5001 who needs to reach it. The port number does not identify the application or its intended audience.
Potential impact
A rule left behind by a temporary service can expose a different service that later uses the same port.
Remediation
Remove unnecessary public grants. For those you retain, record the required clients, protocol, ports, reason and review date. Check IPv4 and IPv6 permissions across attached groups and test access from an approved client and another source.
Examples
Identify the target VPC and group attachments. To narrow only ingress on the existing allow-custom-port group, keep its group-level description. Changing that field makes Terraform replace the group.
Before
resource "aws_security_group" "custom_service" {
name = "allow-custom-port"
description = "Unknown port exposed"
ingress {
from_port = 5001
to_port = 5001
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
The first rule allows TCP 5001 from all IPv4 sources.
After
resource "aws_security_group" "custom_service" {
name = "allow-custom-port"
description = "Unknown port restricted"
ingress {
from_port = 5001
to_port = 5001
protocol = "tcp"
cidr_blocks = ["10.20.0.0/24"]
}
}
The second keeps the port and allows 10.20.0.0/24. Supply the range the approved clients actually use.