Skip to content

incusd/firewall: Restrict wildcard proxy NAT to local addresses - #3824

Open
jochumdev wants to merge 1 commit into
lxc:mainfrom
jochumdev:fix/nat
Open

incusd/firewall: Restrict wildcard proxy NAT to local addresses#3824
jochumdev wants to merge 1 commit into
lxc:mainfrom
jochumdev:fix/nat

Conversation

@jochumdev

Copy link
Copy Markdown
Member

A proxy device with a wildcard listen address (0.0.0.0 or ::) generated DNAT rules with no destination match at all, in both the nat prerouting and nat output hooks, so every packet with a matching destination port was redirected to the instance regardless of where it was headed. With br_netfilter loaded, which proxy NAT requires, that included traffic between containers on the same bridge and outbound traffic from both instances and the host.

Match "fib daddr type local" instead, so a wildcard listen address means any of the host's own addresses rather than any address at all. The output hook also excludes the loopback prefix; prerouting needs no such exclusion, as the output hook initializes the conntrack DST binding first for loopback flows. Add a "meta nfproto" match too, as without a destination address nothing constrained the rules to the DNAT target's address family.

Fixes: dcf2c22 ("incusd/firewall: Allow wildcard listen address in proxy NAT")

@jochumdev
jochumdev requested a review from stgraber as a code owner August 12, 2026 08:57
A proxy device with a wildcard listen address (0.0.0.0 or ::) generated
DNAT rules with no destination match at all, in both the nat prerouting
and nat output hooks, so every packet with a matching destination port
was redirected to the instance regardless of where it was headed. With
br_netfilter loaded, which proxy NAT requires, that included traffic
between containers on the same bridge and outbound traffic from both
instances and the host.

Match "fib daddr type local" instead, so a wildcard listen address means
any of the host's own addresses rather than any address at all. The
output hook also excludes the loopback prefix; prerouting needs no such
exclusion, as the output hook initializes the conntrack DST binding
first for loopback flows. Add a "meta nfproto" match too, as without a
destination address nothing constrained the rules to the DNAT target's
address family.

Fixes: dcf2c22 ("incusd/firewall: Allow wildcard listen address in proxy NAT")

Signed-off-by: René Jochum <rene@jochum.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant