CVE-2026-143263: netfilter: nat: zero newrange before filling it in
In the Linux kernel, the following vulnerability has been resolved:
netfilter: nat: zero newrange before filling it in
nfnatmasqueradeipv4(), nfnatmasqueradeipv6(), netmaptg4() and netmaptg6() each build a stack-local struct nfnatrange2 from the caller-supplied range, inheriting range->flags unmodified. Two of them only memset() the minaddr/maxaddr members, the other two don't memset() anything at all, so newrange.baseproto is left as stack garbage.
If the inherited flags include NFNATRANGEPROTOOFFSET, nfnatl4protouniquetuple() reads range->baseproto.all to compute the NAT port offset. Neither the NETMAP nor the MASQUERADE targets mask the flags field in their checkentry callback, so this uninitialized stack value can end up feeding the NAT port selection.
The per-member memset()s are not enough: they have to enumerate every field that must be cleared, and baseproto was missed when NFNATRANGEPROTOOFFSET/baseproto was added to the struct. memset() the whole struct instead, so every member is covered regardless of which ones get explicitly assigned afterwards.
There are other places that miss this, but those hardcode .flags so nat core won't read from the uninitialized fields.
C99 initializers would be preferrable, but this is a more intrusive change. Lets followup in nf-next and convert others as well.
This is an LLM finding.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.10.276 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.15.227 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.120 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.66 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.7 - Compensating control
Zero the entire stack-local newrange struct before filling it in, rather than clearing only selected members.
Event History
Frequently Asked Questions
Which NAT configurations can reach the uninitialized value?
The affected paths are the IPv4 and IPv6 MASQUERADE and NETMAP targets when the inherited range flags include NF_NAT_RANGE_PROTO_OFFSET. Their checkentry callbacks do not mask that flag.
What is the practical effect when the condition is met?
NAT port selection can consume the uninitialized base_proto value from a stack-local nf_nat_range2 structure when computing the port offset. This can cause NAT behavior to depend on stack garbage rather than an initialized protocol range value.
What should be done if this is identified in a deployed kernel?
Apply a kernel update containing the referenced stable fixes. The fix zeroes the complete nf_nat_range2 structure before explicitly filling its fields, ensuring base_proto cannot retain uninitialized stack data.