Skip to content

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 #14669

Closed as duplicate

Description

@adestis-mf

problem

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:

  1. 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.
  2. 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.
  3. 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

  1. 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.
  2. Create a firewall rule on that IP, for example TCP 22 from your address.
  3. Create a port forwarding (or load balancing) rule on the same IP to a VM in the tier.
  4. 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).

Activity

  1. added this to the 24.0 milestone on Nov 11, 2026
  2. adestis-mf commented on Nov 11, 2026

    @adestis-mf
    Author

    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.

  3. github-actions commented on Nov 11, 2026

    @github-actions

    Warning

    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.

    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

    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
    Labels type:bug, component:vpc, component:virtual-router, Severity:Major
    Coding agent Needs more info Association logic for VPC IPs and VR chain cleanup both need maintainer review

    🔗 Similar issues

    💡 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.

    Generated by Daily Issue Triage · copilot · haiku55 · ~6 AIC · ⊞ 3.8K · ◷

    Add this agentic workflow to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/daily-issue-triage.md@139fa09ef17cde4135e696ff8e7af09bc5ddfa6e
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions