Re: [IPsec] TCP Encapsulation draft

"Valery Smyslov" <svanru@gmail.com> Tue, 15 December 2015 08:16 UTC

Return-Path: <svanru@gmail.com>
X-Original-To: ipsec@ietfa.amsl.com
Delivered-To: ipsec@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 7EC0E1A1A66 for <ipsec@ietfa.amsl.com>; Tue, 15 Dec 2015 00:16:09 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.791
X-Spam-Level:
X-Spam-Status: No, score=-0.791 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_SORBS_WEB=0.77, SPF_PASS=-0.001, STOX_REPLY_TYPE=0.439] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UyuZRDXJeua2 for <ipsec@ietfa.amsl.com>; Tue, 15 Dec 2015 00:16:07 -0800 (PST)
Received: from mail-lb0-x235.google.com (mail-lb0-x235.google.com [IPv6:2a00:1450:4010:c04::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id A02BF1A1A6F for <ipsec@ietf.org>; Tue, 15 Dec 2015 00:16:06 -0800 (PST)
Received: by mail-lb0-x235.google.com with SMTP id u9so772321lbp.2 for <ipsec@ietf.org>; Tue, 15 Dec 2015 00:16:06 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:references:subject:date:mime-version :content-type:content-transfer-encoding; bh=rMw4XFELqqZVtra6dl8l1j0Bf8EtXxCYtiHsVJEd0Z4=; b=IF+LGDNrCbsxoK/ISeAxBjAGzMqlFO1yx02+YutEsz87h1iWz4g9TemAd2trFw/p2D AatT4lZNWb6pIYDCJJ7S2qmyYOzhQrXfJhYfLV/ApWUcMeTpn+ZuvYmlBlRftKqXC9yU 5aoK/lf1UfGf7qumeWKgvzbxDrfb5OhLq6EV1OKqkZFSMpMRrzZtEf/i4pXzeLuo/WH2 q/yme7h7xUM7cK5HjxE69M6Sv5Mzj3YTNR0JqnxEYCbfMXMRgFdUdSK5easkclVucbwh 4s2zN7MnOZT9bvoaiAvVHp7jRCPhMZlCyyi62frGxua14VbKV8rrJbQO3jssi0uV4YR0 60Kg==
X-Received: by 10.112.141.131 with SMTP id ro3mr15643121lbb.106.1450167364848; Tue, 15 Dec 2015 00:16:04 -0800 (PST)
Received: from buildpc ([82.138.51.4]) by smtp.gmail.com with ESMTPSA id m189sm28346lfm.21.2015.12.15.00.16.03 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Dec 2015 00:16:04 -0800 (PST)
Message-ID: <E1A813151CBC4F7B914EFC4C164632DB@buildpc>
From: Valery Smyslov <svanru@gmail.com>
To: Tommy Pauly <tpauly@apple.com>
References: <C755729F-2011-4AAE-9EDD-2C53168AD06B@ericsson.com> <5666AD1B.6000105@gmail.com> <18BF5929-6C8C-41A5-A3BC-764D3F56B2F3@apple.com> <566746C9.1020202@gmail.com> <0929AB361BDD4969BFBECB1DCF365433@buildpc> <C7C9FE0C-6CE5-49E8-8B98-F3EAD4583DE3@apple.com>
Date: Tue, 15 Dec 2015 11:16:18 +0300
MIME-Version: 1.0
Content-Type: text/plain; format="flowed"; charset="UTF-8"; reply-type="original"
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157
Archived-At: <http://mailarchive.ietf.org/arch/msg/ipsec/x2j-50O0AtALit3sOKPF1P3llfU>
Cc: ipsec@ietf.org, Samy Touati <samy.touati@ericsson.com>
Subject: Re: [IPsec] TCP Encapsulation draft
X-BeenThere: ipsec@ietf.org
X-Mailman-Version: 2.1.15
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: Tue, 15 Dec 2015 08:16:09 -0000

Hi Tommy,

thank you for the answers. See my comments inline.

> The idea of using TCP as the fallback from UDP is exactly what the entire draft is about.
> The preconfiguration is not whether to always use TCP, but whether to use TCP once
> UDP fails, and upon which port. Since the entire idea of using TCP is predicated on the
> idea that UDP was already blocked on a previous attempt, this must be preconfigured.
>
> TCP is only used when UDP fails:
> "If both of the other two methods are not
>         available or appropriate, both IKEv2 negotiation packets as
>         well as ESP packets can be sent over a single TCP connection to
>         the peer."
>
> As it says in the configuration section, UDP is the preferred transport:
>
> "Since TCP encapsulation of IKEv2 and IPSec packets adds overhead and
>   has potential performance trade-offs compared to direct or UDP-
>   encapsulated tunnels (as described in Performance Considerations, Section 7),
> implementations SHOULD prefer IKEv2 negotiation over UDP.”
>
> We can make it more explicit that UDP should be tried first, but that is certainly the intent.

Yes, please. The current text is not very explicit about that, at least in me reading.

>>       Those implementations that support TCP encapsulation MUST still support
>>       traditional transport, defined in [RFC7296] for IKE and in [RFC4303] and
>>       [RFC3948] for ESP.
>
> Sure, although I think clarifying (1) that UDP is always tried first should cover this as well.

Agree.

>>      Although a TCP stream may be able to send very long messages,
>>      implementations SHOULD limit message lengths to typical UDP datagram
>>      ESP payload lengths.
>>   I wonder what is a "typical UDP datagram ESP payload lengths"?
>>   How implementation could limit upper-level's message length?
>
> Based on discussion on the list, we decided not to specify a specific value. The point is to not send very
> large messages in the TCP stream, since they will often be sent back into a traditional unix
> networking kernel once decrypted. The message length can be simply limited by setting the
> MTU to a normal value on the virtual interface being used for the VPN.

I think it would be benefitical for implemeters if you clarify this giving them some
concrete guidelines.

>>      An unexpected FIN or a RST on the TCP connection may indicate either
>>      a loss of connectivity, an attack, or some other error. ... The original
>>      initiator (that is, the endpoint that initiated the TCP connection
>>      and sent the first IKE_SA_INIT message) is responsible for re-
>>      establishing the TCP connection if it is torn down for any unexpected
>>      reason.
>>   I think this is not enough. Consider the situation when attacker manages to
>>   send RST to only one peer, say it be the original responder. In this case
>>   the states of the peers become de-syncronized: while the original responder
>>   tearns down its TCP session, the original initiator thinks it is up.
>>   If the original responder has some data to be sent while the original    initiator has no such data, then we have 
>> some kind of deadlock.
>>   It seems that the original initiator must send keepalive messages
>>   with a pretty high frequency whenever it becomes idle.
>
> RST attacks are inherent to TCP. What do you propose on top of this? I don’t think we want
> to recommend for more frequent keepalives, necessarily. Note that any time the client will
> try to send any traffic (this is any ESP traffic, so it will probably be fairly quickly),
> the connection will get a RST if the server thinks the port is no longer open.

The situation described above is quite real. Suppose the client is downloading a large file
from the server. In this case the server always has data to be sent, while the client
only responses with ACKs. If the client receives no new data it just waits. Of course
if it has something to send, the TCP connection will be restored. That's why
it is probably worth to send liveness check messages from the initiator to the responder
if there is no incoming traffic for some period of time (say 10-20 seconds)
and the endpoint has no data to send to the peer.

Note, that it is a bit different from how liveness check messages are supposed
to be used in IKEv2, where liveness check should be done if there is no incoming
traffic for some period of time AND if the endpoint is about to send new data to the peer.

>> 7. I think it's worth to clarify that with TCP encapsulation the IKE SA
>>   establishment starts using port 4500 from the very beginning,    so no port switching from 500 to 4500 takes place.
>
> It’s not necessarily port 4500 at all! In fact, it will likely not be. But that is true that port switching does not 
> take place. We can add a line to re-iterate that.

Oh, I see that the port is not necessary 4500. However I think
the clarification that no port switching takes place would be useful.

>>   Conclusion: among the listed only the IKE check liveness messages
>>   are relevant to TCP encapsulation. But their usage in this case    should be clarified (see my comment #5).
>
> I disagree that the other keep alive types are not relevant. This section is simply a list
> of "mechanisms [that] may be employed” for keepalives, and it is useful for an implementer
> to know which keep alive mechanisms may be taking place on their connection.

>From my naive :-) literal reading the section lists the keepalive methods that are available
for the implementation to choose from:

   It is up to the implementation to decide which keepalives are
   appropriate for TCP-encapsulated connections.

So, I read that as the implementations should be aware of all these methods and
use an appropriate one. But this reading differs from your clarification below:

> It is very important
> that TCP encapsulation can be implemented as a layer transparent to existing TCP, TLS, and ESP
> implementations. By default, these layers may have keepalives of their own.

I agree that layer separation is important, so the only available keepalives
for the IPsec layer are NAT keepalives and liveness check messages.
The other methods are irrelevant here. An implementation can be aware
of their an existance, but usually cannot control them. I think it must be clarified.

> The ESP implementation
> in a kernel may not know that the traffic will be sent over a TCP flow, and if MOBIKE is being used,
> it may switch between UDP and TCP on different networks. Therefore, we should not recommend
> that NAT keepalives be disabled.

Well, I think that IPsec level must always know what encapsulation is currently
active and use NAT keepalives only when UDP encapsulation takes place.
For example, it doesn't send NAT keepalives if "direct" encapsulation is used.

In any case, if for the purposes of simplicity the draft allowed an implementation
to send NAT keepalives in case of TCP encapsulation, then their layout and
processing should have been described (a la Sections 3.1 and 3.2).
And in this case the text from Section 3:

   In order to encapsulate IKEv2 and ESP messages within a stream (which
   may be raw TCP, or TLS over TCP), a 32-bit length field precedes
   every message.  If the first 32-bits of the message are zeros (a Non-
   ESP Marker), then the contents comprise an IKEv2 message.  Otherwise,
   the contents comprise an ESP message.

is not correct, since NAT keepalives are neigther IKE nor ESP messages.

> We can remove the spurious “NAT” qualifier from the TCP keepalives.

OK.

>> 9. Please, add text that some of IKEv2 (and its extensions) mechanisms
>>   become useless with TCP encapsulation and MUST NOT (SHOULD NOT?)
>>   be used. In particular - cookie has a little value with TCP since it is no longer
>>   allows responder to remain stateless. Moreover, TCP handshake determines
>>   peer IP address and protects to some extend from spoofing (I assume ISN
>>   is unpredictable as it should be). Another thing that becomes useless is
>>   sending NAT keepalive messages (but see previous comment).
>>   And IKEv2 extension that becomes useless with TCP encapsulation is
>>   IKEv2 fragmentation.
>
> I do not think we should recommend that any of these extensions MUST NOT be used,

Note, that I've also included "SHOULD NOT" as an alternative since MUST NOT is probably too strong.

> specifically since TCP encapsulation is something done as fallback for connections in which
> UDP is blocked, and in the case of MOBIKE, may be used on a connection that uses UDP
> on other networks.
> - Cookies: the TCP connection here should not be considered ‘state’ from the perspective of IKE.
> The TCP connection is independent of the IKE sessions. It still may be useful to keep the cookie mechanism.

Well, I see the only useful application for the cookie in case of TCP encapsulation -
if puzzle mechanism is adopted then the cookie must be used even in this case.

> - We already address NAT keepalives: "If TCP keep-alives are used, IPSec ESP NAT keep-alives may be
> considered redundant and can safely be disabled.”
> - Fragmentation is still useful, depending on the implementation. One way of implementing is by taking
> the TCP messages, re-encapsulating them as traditional UDP, and forwarding them onto a legacy stack.
> There is also the consideration of MOBIKE—we want to negotiate fragmentation support in case we
> switch back to a network that supports UDP!

I think that all the mechanisms that seem to become unnecessary with TCP encapsulation
must be separately discussed in the document. There must be some text describing under which
circumstances these mechanisms are still useful and when it is safe to abandon them. I don't insist
on MUST NOT (or SHOULD NOT), but some guidlines must be given, otherwise
implementers will wonder: why should we spent resources doing useless things.

Thank you,
Valery.