Re: [IPsec] [secdir] [Last-Call] Secdir last call review of draft-ietf-ipsecme-rfc8229bis-06

Valery Smyslov <svan@elvis.ru> Wed, 01 June 2022 16:54 UTC

Return-Path: <svan@elvis.ru>
X-Original-To: ipsec@ietfa.amsl.com
Delivered-To: ipsec@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 9EC24C14F741; Wed, 1 Jun 2022 09:54:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.107
X-Spam-Level:
X-Spam-Status: No, score=-2.107 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=elvis.ru
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zAUKgzB7GmjB; Wed, 1 Jun 2022 09:53:56 -0700 (PDT)
Received: from akmail.elvis.ru (akmail.elvis.ru [82.138.51.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id CE715C14F6EC; Wed, 1 Jun 2022 09:53:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=elvis.ru; s=mail; h=Content-Type:MIME-Version:Message-ID:Date:Subject:In-Reply-To: References:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=E1oOfzDRDlGoQ2CN5MaGdUv3k7mLjmsiTGI30G7FAEo=; b=J2TB5vse2SaMDqKVe3O2del70U 3GAIykqKcGKQlDVVYvSsk4CG84eV3TiMvo/62lhOcXrspruQgotYQ5pAWIJtkf9RazRJqLVVs/9AS f/Q7j8/jaoBKLDjQQIWz2Jpx9dcCmcg5B2ntlE4e52y8eGQpzMTHO0icXP2ERubvusP4=;
Received: from kmail.elvis.ru ([93.188.44.208]) by akmail.elvis.ru with esmtp (Exim 4.92) (envelope-from <svan@elvis.ru>) id 1nwRbT-00031I-07; Wed, 01 Jun 2022 19:53:51 +0300
Received: from mail16.office.elvis.ru ([10.111.1.29] helo=mail.office.elvis.ru) by kmail.elvis.ru with esmtp (Exim 4.92) (envelope-from <svan@elvis.ru>) id 1nwRbS-0000nu-O6; Wed, 01 Jun 2022 19:53:50 +0300
Received: from MAIL16.office.elvis.ru (10.111.1.29) by MAIL16.office.elvis.ru (10.111.1.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Wed, 1 Jun 2022 19:53:50 +0300
Received: from buildpc (10.111.10.33) by MAIL16.office.elvis.ru (10.111.1.29) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Wed, 1 Jun 2022 19:53:50 +0300
From: Valery Smyslov <svan@elvis.ru>
To: touch@strayalpha.com, 'Valery Smyslov' <svan@elvis.ru>
CC: draft-ietf-ipsecme-rfc8229bis.all@ietf.org, secdir@ietf.org, ipsec@ietf.org, last-call@ietf.org
References: <165377251630.6282.16767658545384357479@ietfa.amsl.com> <077301d8741b$c0fe9b40$42fbd1c0$@elvis.ru> <25237.6715.619617.181961@fireball.acr.fi> <08f501d874df$90e95750$b2bc05f0$@elvis.ru> <25238.13419.293263.562580@fireball.acr.fi> <0a1601d8750e$051083f0$0f318bd0$@elvis.ru> <25239.24036.317688.539399@fireball.acr.fi> <0b4301d875b9$ae525320$0af6f960$@elvis.ru> <C215CCAA-62D6-4C8D-88A1-248D17AB7E54@strayalpha.com>
In-Reply-To: <C215CCAA-62D6-4C8D-88A1-248D17AB7E54@strayalpha.com>
Date: Wed, 01 Jun 2022 19:53:52 +0300
Message-ID: <0ba801d875d8$2c7a7c00$856f7400$@elvis.ru>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_NextPart_000_0BA9_01D875F1.51C93AA0"
X-Mailer: Microsoft Outlook 14.0
Content-Language: ru
Thread-Index: AQKKl9px7X7eA1CQ6TUrJpeus4VMBQFqn8/DAb05IO0BpRHmcAMg7P2lAmkFNCsB/67htgKpxPc/AlUKDVWrS9IuwA==
X-CrossPremisesHeadersFilteredBySendConnector: MAIL16.office.elvis.ru
X-OrganizationHeadersPreserved: MAIL16.office.elvis.ru
X-KLMS-AntiSpam-Interceptor-Info: not scanned
X-KLMS-Rule-ID: 1
X-KLMS-Message-Action: clean
X-KLMS-AntiSpam-Status: not scanned, disabled by settings
X-KLMS-AntiPhishing: Clean, bases: 2022/06/01 15:34:00
X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2022/06/01 07:23:00 #19635587
X-KLMS-AntiVirus-Status: Clean, skipped
Archived-At: <https://mailarchive.ietf.org/arch/msg/ipsec/CnKxaE0VcmsIzekPah1pUn6ydh4>
Subject: Re: [IPsec] [secdir] [Last-Call] Secdir last call review of draft-ietf-ipsecme-rfc8229bis-06
X-BeenThere: ipsec@ietf.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Discussion of IPsec protocols <ipsec.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ipsec>, <mailto:ipsec-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/ipsec/>
List-Post: <mailto:ipsec@ietf.org>
List-Help: <mailto:ipsec-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ipsec>, <mailto:ipsec-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 01 Jun 2022 16:54:00 -0000

Hi Joe,

 

From: secdir [mailto:secdir-bounces@ietf.org] On Behalf Of touch@strayalpha.com
Sent: Wednesday, June 01, 2022 5:43 PM
To: Valery Smyslov
Cc: draft-ietf-ipsecme-rfc8229bis.all@ietf.org; secdir@ietf.org; ipsec@ietf.org; last-call@ietf.org
Subject: Re: [secdir] [Last-Call] [IPsec] Secdir last call review of draft-ietf-ipsecme-rfc8229bis-06

 

Hi, all,

 

Overall, it seems sufficient to:

 

- highlight how much more vulnerable this tunnel makes IPsec to DOS attacks

          i.e., that single packets can cause the entire connection to need to be reset

 

          Already in the draft.

 

- indicate that there IS a way to avoid that hit by re-syncing

          the sync requires a scan, but that in some cases such a scan can be more 

          efficient in than starting a new connection, although it does mean that such 

          an attack may be more likely moving forward (note: restarting a connection

          might provide useful information to an attacker, where continuing may hide

          the impact of such an attack too, so resync has cons and pros).

 

          I’ve added some text about the possibility of a resync. 

          About information for an attacker – if we talk about off-the-path attacker,

          then in general it is unaware of the results of its attack, it may 

          only guess them indirectly. And since resync will take some time and 

          thus introduce some delay, that may be visible to attacker, I’m not sure 

          which method is preferable in this context – everything depends on

          specific conditions for the attacker.

 

          You can also note that there are ways to mitigate the cost of resync when

          this implementation is tightly coupled with TCP, e.g., by ensuring every Nth

          IPsec packet starts at the beginning of a new TCP packet.

 

          Regards,

          Valery.

 

Joe

 

—

Dr. Joe Touch, temporal epistemologist

www.strayalpha.com





On Jun 1, 2022, at 6:15 AM, Valery Smyslov <svan@elvis.ru> wrote:

 

Hi Tero,




Thinking a bit more about the problem:
- IPsec stream consists mostly of random data (as result of
encryption) with uniform distribution
- if an attacker manages to overwrite a single Length field, then
the beginning of the next packet (including the next Length field)
will be this random data

So:
- with probability 1-1/2^32 all subsequent packets will be treated
as ESP packets, and not as IKE packets (the probability for
non-ESP marker to be non-zero)
- the "SPIs "of these "ESP" packets will be random, so unless the
receiver has very large number of active ESP SAs (say > 2^31),
these "SPIs" will be unknown to the receiver

So, it's enough to check whether the SPI of the received ESP packet is valid.
This is a simple check that will work in most cases. If an SPI is invalid,
the receiver should immediately reset TCP connection. I think that
receiving a single invalid SPI is enough reason to do this, since
this should never happen in normal conditions.


The draft already covers most of these cases in section 7.1:

                                If either the TCP Originator or TCP
  Responder detects corruption on a connection that was started with a
  valid stream prefix, it SHOULD close the TCP connection.  The
  connection can be determined to be corrupted if there are too many
  subsequent messages that cannot be parsed as valid IKE messages or
  ESP messages with known SPIs, or if the authentication check for an
  ESP message with a known SPI fails.  Implementations SHOULD NOT tear
  down a connection if only a single ESP message has an unknown SPI,
  since the SPI databases may be momentarily out of sync.

We might want to expand the "detects corruption" a bit more, i.e., add
explict sentence about length fields getting messed up and need for
resync causing this corruption.


I don't think this is needed. The corruption of Length field can only be determined
indirectly by receiving invalid SPIs or failures to validate ICV, which are already mentioned.




Also as was pointed out by you in the other parts of the thread, there
is a way to resync, by searching known spi + sequence number in window
from the stream (this gives us about 56 bits to check against). After
we find such candidate framing, we can check the length before, and
validate ICV. If ICV matches, we know this is valid packet, and we can
resync, of not, we can either search again, or simply close the TCP
stream.

On the other hand I do not think resync is needed in practice, but I
do not want to forbid by mandating that peer must tear down TCP
immediately when it receives unknown SPI, or has mismach between IKE
SA header length field and TCP stream length fields.

So I think we should add text explaining that implementation can try
to resync by by searching valid length + SPI + Sequence number + ICV
combination from the stream, or it can simply restart the TCP stream
(if it is TCP Originator, or it can close the TCP stream if it is TCP
Responder).

Then we can add text in security consideration section explaining this
bit more (you already had candidate text for that).


I still think that it's better to put the text about resync into the Security considerations.
I think this method is specific for Length corruption which most probably
will happen as a result of injection attack. So, the new para in the Security
considerations would look like:

  If an attacker successfully mounts an injection attack on a TCP
  connection encapsulating IPsec traffic, and a Length field in the TCP
  stream is changed as a result of this attack, then the receiver in
  most cases will not be able to correctly identify the boundaries of
  the following packets in the stream, because it will try to parse an
  arbitrary data (the result of encryption) as ESP (or IKE) header.
  This will fail and for this reason all the following packets will be
  dropped.  Eventually the situation should self-recover, but it may
  take several minutes and may result in IKE SA deletion and re-
  creation.  To speed up the recovery implementations are advised to
  follow recommendations in Section 6.1 and to reset TCP connection in
  case incoming packets contain an ESP SPI which doesn't correspond to
  any incoming ESP SA they have.  Once the TCP connection is reset it
  will be re-created by TCP Originator as described in Section 6.1.
  Alternatively, implementations MAY try to re-sync after they received
  unknown SPI by searching the TCP stream for a 64 bit binary vector
  consisting of a combination of some SPI they know (first 32 bits) and
  a valid (E)SN for this SPI (another 32 bits) and try to validate the
  ICV of a packet candidate taking the preceding 16 bits as a Length
  field.  They can also search for 4 bytes of zero (non-ESP marker)
  followed by 128 bits of IKE SPIs of IKE SA associated with this
  stream and try to validate ICV of this IKE message candidate taking
  the preceding 16 bits as a Length field.

Regards,
Valery.





--
kivinen@iki.fi


-- 
last-call mailing list
last-call@ietf.org
https://www.ietf.org/mailman/listinfo/last-call