fix(ec2): validate explicit secondary private IPs (#8836)

* fix(ec2): validate explicit secondary private IPs
This commit is contained in:
XuX authored and GitHub committed 2026-11-18 08:49:18 -04:00
1 parent 4292bca198
commit da3429cc06
2 files changed
+23 -5

No files matched your search

@@ -16423,14 +16423,14 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
if (requestedIp != null) {
requireRequestedPrivateIpFree(region, subnetId, requestedIp);
}
// Secondaries are folded and checked before the primary is allocated, so a refused one
// leaves no lease behind on the VPC network. Their range is not checked, as before.
// Secondaries are folded and validated before the primary is allocated, so a refused one
// leaves no lease behind on the VPC network.
Set<String> secondaries = new LinkedHashSet<>();
for (String extra : privateIpAddresses == null ? List.<String>of() : privateIpAddresses) {
if (extra == null || extra.isBlank()) {
continue;
}
String ip = canonicalIpv4(extra).orElse(extra);
String ip = validateRequestedPrivateIp(extra, subnet, null, 1);
if (!ip.equals(requestedIp) && secondaries.add(ip)) {
requireRequestedPrivateIpFree(region, subnetId, ip);
}