Skip to content

Commit f9185f2

Browse files
fix(aws): fail instead of falling back to 0.0.0.0/0 for security group (#650)
When public IP auto-detection failed, SSH and K8s API ports were opened to the entire internet. Now fail with a clear error message asking the user to set the CIDR explicitly. Audit finding #34 (LOW). Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
1 parent 8230a25 commit f9185f2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pkg/provider/aws/create.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,14 @@ func (p *Provider) createSecurityGroup(cache *AWS) error {
352352
ipRanges := []types.IpRange{}
353353

354354
// First lookup for the IP address of the user
355-
cidr := "0.0.0.0/0"
356-
if publicIP, err := utils.GetIPAddress(); err == nil {
357-
cidr = publicIP
358-
p.log.Info("Using detected public IP for security group: %s", cidr)
359-
} else {
360-
p.log.Warning("Could not detect public IP, using 0.0.0.0/0: %v", err)
355+
publicIP, err := utils.GetIPAddress()
356+
if err != nil {
357+
return fmt.Errorf("could not detect public IP for security group (set ingressCidr explicitly): %w", err)
361358
}
359+
cidr := publicIP
360+
p.log.Info("Using detected public IP for security group: %s", cidr)
362361

363-
// Add the auto-detected IP or fallback to the map and list
362+
// Add the auto-detected IP to the map and list
364363
ipRangeMap[cidr] = true
365364
ipRanges = append(ipRanges, types.IpRange{
366365
CidrIp: &cidr,

0 commit comments

Comments
 (0)