Re: [TLS] implementation of cookies in DTLS

Eric Rescorla <> Mon, 14 March 2011 23:26 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id C00303A6B8B for <>; Mon, 14 Mar 2011 16:26:20 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -102.787
X-Spam-Status: No, score=-102.787 tagged_above=-999 required=5 tests=[AWL=-0.110, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, MIME_8BIT_HEADER=0.3, RCVD_IN_DNSWL_LOW=-1, USER_IN_WHITELIST=-100]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id nlFNPwYm5ani for <>; Mon, 14 Mar 2011 16:26:18 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 2C9143A6B5F for <>; Mon, 14 Mar 2011 16:26:17 -0700 (PDT)
Received: by iwl42 with SMTP id 42so46305iwl.31 for <>; Mon, 14 Mar 2011 16:27:41 -0700 (PDT)
MIME-Version: 1.0
Received: by with SMTP id b4mr4450852ick.372.1300145260713; Mon, 14 Mar 2011 16:27:40 -0700 (PDT)
Received: by with HTTP; Mon, 14 Mar 2011 16:27:40 -0700 (PDT)
In-Reply-To: <>
References: <> <> <> <> <> <> <> <> <> <>
Date: Mon, 14 Mar 2011 16:27:40 -0700
Message-ID: <>
From: Eric Rescorla <>
To: =?ISO-8859-1?Q?Michael_T=FCxen?= <>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: "" <>
Subject: Re: [TLS] implementation of cookies in DTLS
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Mon, 14 Mar 2011 23:26:20 -0000

FWIW, I believe the correct answer is that the server should always use
sequence number 0 for HelloVerifyRequest, and that clients should not do
duplicate suppression during the initial handshake. I agree it's a
tiny bit clunky,
but IMO it's the best option.


On Mon, Mar 14, 2011 at 12:42 PM, Michael Tüxen
<> wrote:
> On Mar 14, 2011, at 8:26 PM, Robin Seggelmann wrote:
>> On 14.03.2011, at 20:13, Michael Tüxen wrote:
>>> On Mar 14, 2011, at 7:16 PM, Robin Seggelmann wrote:
>>>> On 14.03.2011, at 19:01, Michael Tüxen wrote:
>>>>> On Mar 14, 2011, at 5:20 PM, Robin Seggelmann wrote:
>>>>>> On 14.03.2011, at 16:52, Robin Seggelmann <> wrote:
>>>>>>> On Mar 14, 2011, at 4:30 PM, Nikos Mavrogiannopoulos wrote:
>>>>>>>> On 03/14/2011 04:12 PM, Robin Seggelmann wrote:
>>>>>>>>>> Hello, I've been reading the section "Denial of Service
>>>>>>>>>> Countermeasures" of DTLS and as I understand it the proposed
>>>>>>>>>> subsystem (client-hello and client-hello-verify-request) is
>>>>>>>>>> expected to operate before allocating state for the session to
>>>>>>>>>> discard requests from clients with forged addresses.
>>>>>>>>>> Some comments: 1. The document says: If a server receives a
>>>>>>>>>> ClientHello with an invalid cookie, it SHOULD treat it the same as
>>>>>>>>>> a ClientHello with no cookie.
>>>>>>>>>> What does it mean with regards to the handshake sequence. Does the
>>>>>>>>>> second HelloVerifyRequest has seq=0 or seq=1?
>>>>>>>>> The second HelloVerifyRequest should have seq=0 again, since the
>>>>>>>>> server must not change its state. That's how I implemented it in
>>>>>>>>> OpenSSL.  The server does not change any sequence numbers until a
>>>>>>>>> cookie has been verified and the regular handshake continues.
>>>>>>>> What about the record_seq. Is it also 0? If yes  a client
>>>>>>>> would see this record packet as a replay and discard it. If no
>>>>>>>> it seems you have to keep state...
>>>>>>> The record_seq is still increased, because it has to be unique. I wouldn't consider this as a problem because it's just a counter you're increasing. There is no resource allocation necessary and there is no benefit for an attacker to send many ClientHellos to increase the sequence number. It's only used for HMAC verification and replay check and will be reset to 0 after the ChangCipherSpec anyway.
>>>>>>> However, I see your point. Maybe the document should state more explicitly that handshake sequence numbers must not be increased, because they always have to be the same and always have to start with 0, while the record_seq has to be unique and therefore has to change.
>>>>>> I forgot to mention that in OpenSSL I'm using the same record_seq counter for every incoming request until a CH with a valid cookie arrives. This is due to a workaround to implement an UDP based and thus one-to-many style protocol in OpenSSL's one-to-one architecture, but so I'm not required to allocate anything.
>>>>> Hi Robin,
>>>>> can you be more specific? Did you implement it such that Nikos
>>>>> message exchange is valid? So do you copy the rec. seq. number
>>>>> from the incoming packet? Do you use the same counter for multiple
>>>>> client until you receive a CH with a valid cookie?
>>>> I don't copy the record sequence. The server is using one counter for multiple clients until the CH with a valid cookie. So the first HelloVerifyRequest has record seq 0, the second 1 and so on. When a cookie has been verified, the ServerHello will have the next record seq, while the next HelloVerifyRequest for an other client will have 0 again.
>>> So does this mean that one client affects the other?
>> Only by increasing the record sequence. As an example, a scenario with a low RTT client (lc), a high RTT (hc) client, the server listening with SSL object s1 and then s2:
>> hc: ClientHello(rseq:0, hseq: 0)
>> s1: HelloVerifyRequest(rseq:0, hseq:0)
>> lc: ClientHello(rseq:0, hseq: 0)
>> s1: HelloVerifyRequest(rseq:1, hseq:0)
>> lc: ClientHelloCookie(rseq:1, hseq: 1)
>> s1 will be connected to lc, now s2 listens
>> s1: ServerHello(rseq:2, hseq:1)
>> hc: ClientHelloCookie(rseq:1, hseq: 1)
>> s2 will be connected to hc, now s3 listens
>> s1: ServerHello(rseq:0, hseq:1)
>> So the more ClientHellos arrive before one with a valid cookie, the higher is the record sequence number. That's the only "state" in the server that changes. Otherwise I would have to maintain the record sequence per client which would require resource allocation or always use the same with the retransmission issues Nikos pointed out.
> I would prefer if different clients would not affect each other. Why can't you just
> reflect the record sequence number? Then there is no need to store it per client.
> Best regards
> Michael
>> Regards,
>> Robin
>>> Best regards
>>> Michael
>>>> This is because I'm using an SSL object (and its rec seq counter) for listening, which will be assigned to the first client with a valid cookie to continue the connection, so the next handshake message, that is the ServerHello, will habe the next record seq. A new SSL object (with reset counters) is then created to continue listening and responding to ClientHellos.
>>>> Best reagards,
>>>> Robin
>>>>> Best regards
>>>>> Michael
>>>>>>> Regards,
>>>>>>> Robin
>>>>>>>>>> e.g. if I receive ClientHello (record_seq=0, seq=0)  ------>
>>>>>>>>>> <-- HelloVerifyRequest (record_seq=0, seq=0)
>>>>>>>>>> ClientHello (record_seq=1, seq=1)  ------> (wrong cookie)
>>>>>>>>>> <-- HelloVerifyRequest (record_seq=1, seq=1) [seq copied from
>>>>>>>>>> clienthello]
>>>>>>>>>> ClientHello (record_seq=2, seq=2)  ------> (wrong cookie)
>>>>>>>>>> <-- HelloVerifyRequest (record_seq=2, seq=2) [seq copied from
>>>>>>>>>> clienthello]
>>>>>>>>>> ClientHello (record_seq=3, seq=3)  ------>
>>>>>>>>>> [server allocates session and continues handshake]
>>>>>>>>> That may be helpful, but in my opinion "must not change its state"
>>>>>>>>> includes not changing any sequence numbers.
>>>>>>>> What is of most concern is the record_seq. A client would just discard
>>>>>>>> packets with the same sequence number.
>>>>>>>> regards,
>>>>>>>> Nikos
>>>>>> _______________________________________________
>>>>>> TLS mailing list
> _______________________________________________
> TLS mailing list