VPC firewall: a firewall rule on a new VPC public IP before any PF/LB rule prevents the IP from being configured on the VR · Issue #14669 · apache/cloudstack · GitHub
With the Firewall service for VPC public IPs (#12706), a firewall rule can be created on a
public IP of a VPC before the IP has any port forwarding, load balancing or static NAT rule. In
that order the IP is never configured on the VPC virtual router:
IpAddressManagerImpl.applyRules resolves only the VPC for a VPC firewall rule
(networkId is null), skips the IP association and logs
Unable to resolve network for firewall rules (networkId=null, vpcId=...); skipping IP association.
The firewall rules are sent to the VR anyway and the FIREWALL_<ip> chain is created.
The first LB or PF rule on the IP is applied afterwards, but no IpAssocVpcCommand is sent
for it. The IP never appears in the ips data bag of the VR and is not added to the public
interface. Clients on the same public subnet get No route to host, others time out.
When the LB/PF rules are applied, the VR also deletes the previously added firewall rules
from FIREWALL_<ip> (Delete rule -D FIREWALL_<ip> ... in /var/log/cloud.log), so only the
final DROP remains. Re-applying the firewall rules restores them, but the IP is still not on
the VR. (On a correctly associated IP, re-applying PF rules during a CKS scale kept the
firewall rules.)
With the opposite order (LB/PF first, firewall rules afterwards) everything works: the LB/PF
apply sends IpAssocVpcCommand, the VR runs ip addr add dev eth1 <ip>/<mask>, and later
firewall rules take effect immediately. The skip in step 1 is harmless then, because the IP is
already associated.
Observed on 4.23.0.0 with a VPC offering that has the Firewall service (provider
VpcVirtualRouter), same VPC, same tier, same steps except for the order:
firewall rules before LB/PF
firewall rules after LB/PF
IpAssocVpcCommand in the job that applied LB/PF
0
8
IP on the VR public interface (ip addr)
no
yes (secondary eth1)
FIREWALL_<ip> after the LB/PF apply
rules deleted, only DROP
rules present
TCP from an allowed source
timeout / No route to host
open
In the "before" case the management server also logged
Merovingian2: Was unable to find lock for the key user_ip_address<id> while applying the LB
rule on that IP.
A side observation: after an IP with firewall rules is released, its FIREWALL_<ip> chain stays
on the VR (with RELATED/ESTABLISHED and DROP), and the PREROUTING -d <ip> -j FIREWALL_<ip>
jump stays as well. When the IP is acquired again in the same VPC the chain is reused.
versions
Apache CloudStack 4.23.0.0; IpAddressManagerImpl.applyRules is unchanged on main
(a7be64a)
KVM, advanced zone, VPC offering with the Firewall service (provider VpcVirtualRouter),
SystemVM template for 4.23 on the VR
The steps to reproduce the bug
In a VPC with the Firewall service, get a new public IP that is associated with the VPC and
with a tier but has no rules yet. We saw it with the IP that CKS acquires for a cluster
(associateIPToVpc + associateIPToGuestNetwork); a plain associateIpAddress vpcid=...
was not tested.
Create a firewall rule on that IP, for example TCP 22 from your address.
Create a port forwarding (or load balancing) rule on the same IP to a VM in the tier.
The port is not reachable. ip addr on the VR (or getDiagnosticsData files=ipaddr) does not
show the IP, and the job that applied the port forwarding rule sent no IpAssocVpcCommand.
Doing step 3 before step 2 works.
What to do about it?
When firewall rules are applied for a VPC public IP that is not yet associated with the VR,
associate it first, as applyRules does for network-scoped rules (resolve the network from
the IP's associated network or use the VPC-level IP association). The VR should not drop
firewall rules of an IP when PF/LB rules for that IP are applied. Released IPs should have their
firewall chain removed.
Found while fixing CKS for VPCs with the Firewall service (#14668), whose fix creates the
firewall rules after the LB/PF rules to avoid this.
Related, but a different problem in the same feature: #14068 (NPE when destroying a VPC tier
with the Firewall service, PR #14133).
This is the same problem as #14146, which I did not find before opening this issue. I have put
the root cause and a reproduction without CKS there; the fix is #14681. Please feel free to close
this issue as a duplicate of #14146.
One point of the description is not covered there: step 3, the firewall rules being removed from
FIREWALL_<ip> when the load balancing or port forwarding rules were applied. I saw that once, in
the order described above, and have not reproduced it since; it is not part of the fix.
threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.
What happened
The threat detection engine failed to produce results.
On a VPC with the Firewall service, a firewall rule created on a new public IP before any PF or LB rule prevents the IP from being configured on the VR. applyRules skips the IP association for VPC firewall rules, so no IpAssocVpcCommand is sent later when the PF or LB rule is applied. The VR also deletes the firewall rules from FIREWALL_<ip> at that point. Creating the PF or LB rule first avoids the problem. The reporter's table shows the difference on 4.23.0.0.
📊 Assessment
Dimension
Value
Reasoning
Type
type:bug
IP not configured on the VR and rules dropped, depending on rule order
Component
component:vpc, component:virtual-router
Association in IpAddressManagerImpl, rule handling on the VR
Severity
Severity:Major
Public IP unreachable with a valid firewall rule until a workaround is applied
Reproduction: in a VPC with the Firewall service, associate a new IP, add a firewall rule on it, then add a port forward on it. Check ip addr on the VR and /var/log/cloud.log.
The released-IP case (leftover FIREWALL_<ip> chain and PREROUTING jump) is a separate cleanup item; consider a separate issue.
Activity
adestis-mf commented on Nov 11, 2026
This is the same problem as #14146, which I did not find before opening this issue. I have put
the root cause and a reproduction without CKS there; the fix is #14681. Please feel free to close
this issue as a duplicate of #14146.
One point of the description is not covered there: step 3, the firewall rules being removed from
FIREWALL_<ip> when the load balancing or port forwarding rules were applied. I saw that once, in
the order described above, and have not reproduced it since; it is not part of the fix.
github-actions commented on Nov 11, 2026
Warning
threat detection engine error
What happenedThe threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.
The threat detection engine failed to produce results.
Review the workflow run logs for details.
🎯 Triage report
On a VPC with the Firewall service, a firewall rule created on a new public IP before any PF or LB rule prevents the IP from being configured on the VR. applyRules skips the IP association for VPC firewall rules, so no IpAssocVpcCommand is sent later when the PF or LB rule is applied. The VR also deletes the firewall rules from FIREWALL_<ip> at that point. Creating the PF or LB rule first avoids the problem. The reporter's table shows the difference on 4.23.0.0.
📊 Assessment
🔗 Similar issues
- CKS: cluster on a VPC tier fails when the VPC has the Firewall service (#12706) #14668 (related) — CKS on a VPC tier fails when the VPC has the Firewall service; the reporter found this while fixing it
- NPE when destroying a vpc network which is deployed with firewall service enabled in vpc offering. #14068 (related) — NPE when destroying a VPC tier with the Firewall service (fixed in PR network: handle missing network when releasing public IP #14133)
- UI: Firewall rule is lost when there is a PF rule created on a vpc network which has conserve mode on #14147 (related) — UI firewall rule lost when a PF rule is created on a conserve-mode VPC network
💡 Notes and suggestions- Reproduction: in a VPC with the Firewall service, associate a new IP, add a firewall rule on it, then add a port forward on it. Check ip addr on the VR and /var/log/cloud.log.
- The released-IP case (leftover FIREWALL_<ip> chain and PREROUTING jump) is a separate cleanup item; consider a separate issue.
Add this agentic workflow to your repoTo install this agentic workflow, run