Re: [Ntp] Details of the fragmentation attacks against NTP and port randomization

Fernando Gont <fgont@si6networks.com> Thu, 13 June 2019 13:36 UTC

Return-Path: <fgont@si6networks.com>
X-Original-To: ntp@ietfa.amsl.com
Delivered-To: ntp@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 44271120226 for <ntp@ietfa.amsl.com>; Thu, 13 Jun 2019 06:36:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.399
X-Spam-Level:
X-Spam-Status: No, score=-0.399 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=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 Zq8tTADyEFtx for <ntp@ietfa.amsl.com>; Thu, 13 Jun 2019 06:36:07 -0700 (PDT)
Received: from fgont.go6lab.si (fgont.go6lab.si [91.239.96.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 24033120222 for <ntp@ietf.org>; Thu, 13 Jun 2019 06:36:06 -0700 (PDT)
Received: from [192.168.0.70] (unknown [94.54.130.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by fgont.go6lab.si (Postfix) with ESMTPSA id 217888F4A8; Thu, 13 Jun 2019 15:35:46 +0200 (CEST)
To: Danny Mayer <mayer@ntp.org>, ntp@ietf.org
References: <CAN2QdAGS20q=7+r+qMFEBBu4gNmSDR9-vYDbvgC=ZnqWLEU-6w@mail.gmail.com> <739c2eaa-05f1-0b30-4b64-fc5d3f91ce5b@pdmconsulting.net> <a3a545cf-d83d-a2c7-ad6c-3e349de78615@si6networks.com> <9f75e400-cf2f-053f-ed06-f4d6df415eaf@pdmconsulting.net> <70d86938-5d50-7732-5257-c698d7d308d6@si6networks.com> <b4a5d0ec-606e-7994-9bc9-e21e24f38def@ntp.org>
From: Fernando Gont <fgont@si6networks.com>
Openpgp: preference=signencrypt
Autocrypt: addr=fgont@si6networks.com; prefer-encrypt=mutual; keydata= mQINBE5so2gBEACzBQBLUy8nzgAzSZn6ViXT6TmZBFNYNqTpPRvTVtUqF6+tkI+IEd9N2E8p pXUXCd0W4dkxz6o7pagnK63m4QSueggvp881RVVHOF8oTSHOdnGxLfLeLNJFKE1FOutU3vod GK/wG/Fwzkv9MebdXpMlLV8nnJuAt66XGl/lU1JrNfrKO4SoYQi4TsB/waUQcygh7OR/PEO0 EttiU8kZUbZNv58WH+PAj/rdZCrgUSiGXiWUQQKShqKnJxLuAcTcg5YRwL8se/V6ciW0QR9i /sr52gSmLLbW5N3hAoO+nv1V/9SjJAUvzXu43k8sua/XlCXkqU7uLj41CRR72JeUZ4DQsYfP LfNPC98ZGTVxbWbFtLXxpzzDDT8i3uo7w1LJ2Ij/d5ezcARqw01HGljWWxnidUrjbTpxkJ9X EllcsH94mer728j/HKzC9OcTuz6WUBP3Crgl6Q47gY5ZIiF0lsmd9/wxbaq5NiJ+lGuBRZrD v0dQx9KmyI0/pH2AF8cW897/6ypvcyD/1/11CJcN+uAGIrklwJlVpRSbKbFtGC6In592lhu7 wnK8cgyP5cTU+vva9+g6P1wehi4bylXdlKc6mMphbtSA+T3WBNP557+mh3L62l4pGaEGidcZ DLYT2Ud18eAJmxU3HnM8P3iZZgeoK7oqgb53/eg96vkONXNIOwARAQABtCVGZXJuYW5kbyBH b250IDxmZ29udEBzaTZuZXR3b3Jrcy5jb20+iQJBBBMBAgArAhsjBQkSzAMABgsJCAcDAgYV CAIJCgsEFgIDAQIeAQIXgAUCTmylpQIZAQAKCRCuJQ1VHU50kv7wD/9fuNtTfxSLk3B3Hs3p ixTy8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 13 Jun 2019 16:35:38 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0
MIME-Version: 1.0
In-Reply-To: <b4a5d0ec-606e-7994-9bc9-e21e24f38def@ntp.org>
Content-Type: text/plain; charset="utf-8"
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/ntp/lyi4rwgblcf7kSpqjvq3K6UOqqg>
Subject: Re: [Ntp] Details of the fragmentation attacks against NTP and port randomization
X-BeenThere: ntp@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: <ntp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ntp>, <mailto:ntp-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/ntp/>
List-Post: <mailto:ntp@ietf.org>
List-Help: <mailto:ntp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ntp>, <mailto:ntp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 13 Jun 2019 13:36:10 -0000

Hello, Danny,

On 12/6/19 01:33, Danny Mayer wrote:
> 
> On 6/7/19 6:53 AM, Fernando Gont wrote:
>> On 5/6/19 05:41, Danny Mayer wrote:
>>> On 6/4/19 2:39 AM, Fernando Gont wrote:
>>>> On 4/6/19 06:09, Danny Mayer wrote:
>>>>> On 6/3/19 2:24 PM, Watson Ladd wrote:
>>>>>
>>>>>> Dear all,
>>>>>>
>>>>>> The debate over client port randomization is missing an important
>>>>>> fact: off-path attacks against NTP are not prevented by the origin
>>>>>> timestamp due to the OS handling of fragmentation. In
>>>>>> http://www.cs.bu.edu/~goldbe/papers/NTPattack.pdf we see that sending
>>>>>> a properly crafted IP fragment can selectively overwrite NTP packets,
>>>>>> thus allowing an attacker to modify received data without overwriting
>>>>>> the origin timestamp. I would recommend we adopt port randomization
>>>>>> to handle this problem.
>>>>>>
>>>>>> Sincerely,
>>>>>> Watson Ladd
>>>>> Actually if you read Section VI you will see that the last sentence of
>>>>> that section states that they do not consider it to be a sufficient defense.
>>>> Wasn't Your argument that the timestamp was enough to mitigate off-path
>>>> attacks?
>>>>
>>> Yes and no. The draft you wrote requires using random ports to avoid
>>> off-path attacks.
>> No.
> Actually that's exactly what it says. See the abstract of your own draft.

It's a mitigation. It is not meant to be *the only* mitigation.




>> The draft we wrote says employing predictable identifiers is a bad
>> practice that has been known for over 20 years. We have been on this
>> road so many times. You just don't use predictable IDs.
> You do this of off-path attackers.

?



>> Using them leads to trouble, with no benefit. Using random port numbers
>> helps mitigate such trouble.
> No always which why your RFC is a BCP. What needs to be clarified is
> when it is wise to do so and when not to do so and what are the
> consequences if you do so. You cannot make proposals without including them.

Could you please tell me the advantages of using the flawed scheme (src
port=123)?





>>> The paper demonstrates that for at least some O/S's an
>>> off-path fragmentation attack succeeds regardless of the port number.
>>> This is at a layer below NTP. So randomizing the ports doesn't matter
>>> for this attack according to the paper. The proper way to deal with this
>>> fragmentation attack is to fix the underlying O/S behavior as has
>>> already been done for most of them. The NTP basic payload is only 48
>>> bytes so there is no reason to allow fragmentation in the first place.
>> The IPv4 minimum MTU is 68 bytes. Anything longer than that may need to
>> be fragmented.
> Yes, and when you add the UDP envelope and the IP envelope to the NTP
> Payload you have 78 bytes (if I did the addition correctly). If there
> were way to avoid fragmentation I'd recommend doing so particularly for
> NTP packets as they are time-sensitive, separate from this fragmentation
> attack. 

That's layer 3, where port randomization is layer 4. I'm fine with any
smarts you want to do at any other layers... but that's exactly the
point: what you do at other layers has nothing to do with port
randomization, which happens at layer-4.



>>> So RFC6056 doesn't really apply as a mandate.
>> It's a BCP from the *transport area* about how to employ ephemeral port
>> numbers. I can't see what's the rationale to ignore such advice.
> It's advice and you need to examine consequences in both directions
> before you recommend this.

Indeed, and hopefully the next rev will expand on this.

May I ask, once again:
* What are the befenits of src=123?

* If you assume there are bad implications of port randomization, which
would be a show stopper for this I-D, why aren't we already suffering
from that trouble in all the scenarios where we have multiple NTP
clients operating behind a NAT?



>>> You can certainly ask to
>>> update draft-ietf-ntp-bcp to recommend randomizing the port for outgoing
>>> queries.
>> Yes. That's what our draft does.
> No, it actually obsoletes RFC5905! You should be updating the NTP BCP
> since you seemed to have missed the draft review.

There is an error in the I-D, indeed: it should say "Updates", rather
than "Obsoletes". We will fix this.

RFC5905 talks about port number selection. SO it's RFC5905 that should
be updated.



>>> In any case RFC6056 is about randomizing ports and is not
>>> really a security document. If it were then it would have made a very
>>> basic recommendation concerning the port: if you have received your
>>> response and it is valid then close the port immediately and the next
>>> time you want to make a new request open a new random port to perform
>>> the request. That way the off-path attacker will have no way of knowing
>>> what the new port number will be.
>> The document provides advice for all transport protocols. What you
>> describe only applies for connection-less protocols, where the app-layer
>> only does occasional packets exchanges.
> And falls short of proper advise on what to do when the port is not in
> use. 

It talks about port number *selection*, not *usage*. FOr obvious reasons
it also doesn't answer questions such as "Should my app protocol reuse
the same connection, or use different connections to exchange objects?".
It also doesn't comment on "should i use a 'connected' UDP socket or not?"



> NTP *is* a connectionless protocol and that's what this WG is
> dealing with.

The RFC6056 talks about ephemeral port selection, irrespective of
whether the transport protocol is conenctionless or connection oriented.




>>> In the case of NTP you don't want to trust a single server, The draft
>>> NTP BCP recommends at least 3 different servers and preferably 4 to
>>> allow for the loss of one server.
>> You keep mixing things up.
>>
>> There's a lot of things you may want to do (and probably should!) at the
>> app layer. This document is concerned with what you do at the *transport
>> layer*. Any good practices at the app layer don't rule out good
>> practices at the transport layer.
> Yes, but you need to consider the consequences of what you do at each
> layer, you cannot do this in a vacuum. You seem to ignore the whole in
> preference of the detail. It's the whole you need to deal with.

The transport area considered that "whole" when it issued its BCP. If
you want to go against such BCP, please provide arguments in that direction.

I'd expect that in the context of the normal scenario of multiple NTP
clients behind NAT devices, you might have a hard time. But please give
it a try.




>> You keep arguing that you want to keep a very bad practice, because
>> somehow you are doing something else that you thing will relieve you
>> from the possible pain of the bad practice.
> Not at all. If the circumstances are right then you should do it.

PLease go and tell the transport area. And while you do it, please
answer the question I asked before, namely:
What are the problems you expect with port randomization, and if they
are such big problems, how you are dealing with them in networks such as
IPv4-based where NATs are already part of the architecture.



>>>  See section 3.2. If you are really
>>> concerned about security you should arrange with your server providers
>>> to include either a MAC at the end of the packet or use the new NTS
>>> security mechanism to validate and secure the packets returned. If you
>>> are concerned about attacks you should be employing firewalls anyway.
>>> Lastly you can get yourself a GPS unit and use that to get your clock
>>> information. For the really paranoid, get an atomic clock!
>> I guess with the same line of reasoning you could argue that if you're
>> really concerned about security, you wouldn't keep the servers connected
>> to the Internet?
> 
> No I'm saying use proper security where possible or close the port when
> not using it and open it on a new port when you need it again. *That* is
> good practice yet nowhere in RFC6056 does it say that.

Because it talks about port number selection, not usage.

Want a similar example: IPv6 address configuration and IID
generation/selection vs IPv6 address usage policies. You are mixing up
two orthogonal things.

Thanks,
-- 
Fernando Gont
SI6 Networks
e-mail: fgont@si6networks.com
PGP Fingerprint: 6666 31C6 D484 63B2 8FB1 E3C4 AE25 0D55 1D4E 7492