Description
In a VPC security group attached to RDS, 0.0.0.0/0 allows every IPv4 source and ::/0 every IPv6 source on the specified port. Check whether that port is the database’s listening port.
Potential impact
If the database is publicly reachable and its port is open, unapproved clients can try to sign in, including with stolen credentials. Database permissions determine what an authenticated caller can do.
Remediation
- Allow the database port only from approved application security groups or client CIDRs. Check all groups attached to the deployed instance.
- Review
PubliclyAccessible, subnets and routes together. If moving to private access, test the private path before disabling public access. Verify that approved clients connect and other sources are blocked.
Examples
Both excerpts keep PubliclyAccessible: true on the same DBInstance and omit deployment properties such as the database engine. TCP 80 is illustrative.
Example using the full IPv4 range
Resources:
DBEC2SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Open database for access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
DBInstance:
Type: AWS::RDS::DBInstance
Properties:
PubliclyAccessible: true
VPCSecurityGroups:
- !GetAtt DBEC2SecurityGroup.GroupId
Example using a narrower CIDR
Resources:
DBEC2SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Open database for access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 1.2.3.4/24
DBInstance:
Type: AWS::RDS::DBInstance
Properties:
PubliclyAccessible: true
VPCSecurityGroups:
- !GetAtt DBEC2SecurityGroup.GroupId
The source narrows from every IPv4 address to 1.2.3.4/24, which covers the entire 1.2.3.0/24 network. Replace it with the actual client range.