From: Florian Westphal <fw@strlen.de>
To: zhilin zou <zhilinz@nebusec.ai>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
Ren Wei <enjou1224z@gmail.com>,
netfilter-devel@vger.kernel.org, phil@nwl.cc,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
horms@kernel.org, zhaojignmin@hotmail.com, kaber@trash.net,
vega@nebusec.ai
Subject: Re: [PATCH nf 0/1] netfilter: h323: fix helper NAT mangling
Date: Wed, 29 Jul 2026 09:30:39 +0200 [thread overview]
Message-ID: <ammsH8vWEf8u2tuj@strlen.de> (raw)
In-Reply-To: <CANB6i5yBvEWuF36SQ0BH+1msCxhgsmT11zdd6Az7gt4oKQ6P-Q@mail.gmail.com>
zhilin zou <zhilinz@nebusec.ai> wrote:
> > > packet's current IPv4 protocol byte. A namespace-local packet modifier
> > > can rewrite that byte after conntrack has accepted the original layout
> > > and before helper processing at the confirm hook.
But it can mangle packet in other ways, no?
AFAICS this fix papers over the problem and only "fixes" this particular reproducer.
> > commit 54f34607d184c1cc056c59a5b3d86d96dd6a515c
> > Author: Florian Westphal <fw@strlen.de>
> > Date: Tue Jun 9 13:51:53 2026 +0200
> >
> > netfilter: nfnetlink_queue: restrict writes to network header
> >
> > commit df07998dfd40796a05fff7ffea2661ad65ed42a7
> > Author: Florian Westphal <fw@strlen.de>
> > Date: Tue Jun 9 13:51:54 2026 +0200
> >
> > netfilter: nftables: restrict linklayer and network header writes
> >
> > are you running a kernel with this patches?
Neither fixes are sufficient, afaics, as no tcp revalidation is done.
Ideally we could just remove nfqueue write support, but we can't.
> The issue still reproduces. The crash is:
>
> BUG: KASAN: out-of-bounds in mangle_contents+0x13a/0x680
>
> and the trace goes through:
>
> mangle_contents()
> __nf_nat_mangle_tcp_packet()
> set_addr()
> set_ras_addr()
> ras_help()
> nfqnl_recv_verdict()
>
> So these commits do not seem to block this NFQUEUE/H.323 NAT mangling path.
Why do you think your patches block this path?
Can't you make a valid TCP packet, then mangle it so that tcp options
will get you into end-of-buffer territory?
AFAICS you will need to ask your AI to extend the two commits, for nfqueue,
add nfqnl_validate_l4(), called from the tail of ip option validation, for
ipv6, called from ipv6 exthdr validation, with the last "next" header as
argument.
- Validate minimal size of base header
- validate length in case of IPPROTO_TCP (data_len >= sizeof(struct tcphdr)
and data_len >= __tcp_hdrlen())
- reject unknown headers
- reject if l4 proto is different from attached
nf_conn l4proto (if any).
For nft_payload.c: add nft_th_write_ok(), which
rejects writes to TCP th->doff.
nft_nh_write() rejects writes to nexthdr value, so "nf_conn l4 proto
changes underneath" should not be possible via nft_payload.
prev parent reply other threads:[~2026-07-29 7:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 17:58 [PATCH nf 0/1] netfilter: h323: fix helper NAT mangling Ren Wei
2026-07-27 17:58 ` [PATCH nf 1/1] netfilter: h323: keep NAT mangling aligned with parsed transport Ren Wei
2026-07-28 19:40 ` [PATCH nf 0/1] netfilter: h323: fix helper NAT mangling Pablo Neira Ayuso
2026-07-29 1:19 ` zhilin zou
2026-07-29 7:30 ` Florian Westphal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ammsH8vWEf8u2tuj@strlen.de \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=enjou1224z@gmail.com \
--cc=horms@kernel.org \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
--cc=vega@nebusec.ai \
--cc=zhaojignmin@hotmail.com \
--cc=zhilinz@nebusec.ai \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.