Description
Choose a database source CIDR from the addresses of approved applications and administrators. Even a short list of private addresses can include hosts that have no need to connect.
Potential impact
An unused address in an allowed range can later belong to an unrelated host. Broad exceptions also make it harder to identify which clients a change will affect.
Remediation
For current RDS instances, restrict the database port in a VPC security group. Use the application’s security group as a source where appropriate, or allow only the required client CIDRs. Record an owner and expiry for exceptions. Test a new connection from an approved client and from a source that should be blocked.
Examples
The examples compare historical aws_db_security_group settings. Terraform AWS provider 5.0 removed this resource.
Before
resource "aws_db_security_group" "db_sg" {
name = "rds_sg"
ingress {
cidr = "10.0.0.0/24"
}
}
10.0.0.0/24 includes 256 IPv4 addresses.
After
resource "aws_db_security_group" "db_sg" {
name = "rds_sg"
ingress {
cidr = "10.0.0.0/25"
}
}
10.0.0.0/25 still includes 128 addresses. Narrow it further if only a few clients need access.