mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
To: yyxRoy <yyxroy22@gmail.com>
Cc: Florian Westphal <fw@strlen.de>,
	979093444@qq.com, coreteam@netfilter.org,
	 David Miller <davem@davemloft.net>,
	edumazet@google.com,  gregkh@linuxfoundation.org,
	kuba@kernel.org, linux-kernel@vger.kernel.org,
	 netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
	pabeni@redhat.com,  Pablo Neira Ayuso <pablo@netfilter.org>
Subject: Re: [PATCH] netfilter: conntrack: tcp: do not lower timeout to CLOSE for in-window RSTs
Date: Wed, 10 Jul 2024 15:49:24 +0200 (CEST)	[thread overview]
Message-ID: <7dd0aeaf-20cc-877c-e2d9-e0b40d40567d@blackhole.kfki.hu> (raw)
In-Reply-To: <20240710094554.483075-1-979093444@qq.com>

Hi,

On Wed, 10 Jul 2024, yyxRoy wrote:

> On Mon, 8 Jul 2024 at 22:12, Florian Westphal <fw@strlen.de> wrote:
>> We can track TTL/NH.
>> We can track TCP timestamps.
>>
>> But how would we use such extra information?
>> E.g. what I we observe:
>>
>> ACK, TTL 32
>> ACK, TTL 31
>> ACK, TTL 30
>> ACK, TTL 29
>>
>> ... will we just refuse to update TTL?
>> If we reduce it, any attacker can shrink it to needed low value
>> to prevent later RST from reaching end host.
>>
>> If we don't, connection could get stuck on legit route change?
>> What about malicious entities injecting FIN/SYN packets rather than RST?
>>
>> If we have last ts.echo from remote side, we can make it harder, but
>> what do if RST doesn't carry timestamp?
>>
>> Could be perfectly legal when machine lost state, e.g. power-cycled.
>> So we can't ignore such RSTs.
>
> I fully agree with your considerations. There are indeed some challenges 
> with the proposed methods of enhancing checks on RSTs of in-window 
> sequence numbers, TTL, and timestamps.

Your original suggestion was "Verify the sequence numbers of TCP packets 
strictly and do not change the timeout of the NAT mapping for an in-window 
RST packet." Please note, you should demonstrate that such a mitigation

- does not prevent (from conntrack point of view) currently
   handled/properly closed traffic to be handled with the mitigation as
   well
- the mitigation actually does not pose an easier exhaustion of the
   conntrack table, i.e. creating an easier DoS vulnerability against it.

> However, we now have known that conntrack may be vulnerable to attacks 
> and illegal state transitions when it receives in-window RSTs with 
> incorrect TTL or data packets + RSTs. Is it possible to find better 
> methods to mitigate these issues, as they may pose threats to Netfilter 
> users?

The attack requires exhaustive port scanning. That can be prevented with 
proper firewall rules.

> Note: We have also tested other connection tracking frameworks (such as 
> FreeBSD/OpenBSD PF). Also playing the roles as middleboxes, they only 
> change the state of the connection when they receive an RST with the 
> currently known precise sequence number, thus avoiding these attacks. 
> Could Netfilter adopt similar measures or else to further mitigate these 
> issues?

I find it really strange that those frameworks would match only the exact 
SEQ of the RST packets.

Best regards,
Jozsef
-- 
E-mail : kadlec@netfilter.org, kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu
Address: Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary

      reply	other threads:[~2024-07-10 13:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-05  4:00 yyxRoy
2024-07-05  9:43 ` Florian Westphal
2024-07-06 16:16   ` Jozsef Kadlecsik
2024-07-06 17:04     ` Florian Westphal
2024-07-08  8:59       ` yyxRoy
2024-07-08 14:12         ` Florian Westphal
2024-07-10  9:45           ` yyxRoy
2024-07-10 13:49             ` Jozsef Kadlecsik [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=7dd0aeaf-20cc-877c-e2d9-e0b40d40567d@blackhole.kfki.hu \
    --to=kadlec@blackhole.kfki.hu \
    --cc=979093444@qq.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=yyxroy22@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®