Re: [TLS] Possible timing attack on TLS 1.3 padding mechanism

Nikos Mavrogiannopoulos <nmav@redhat.com> Fri, 02 March 2018 08:32 UTC

Return-Path: <nmav@redhat.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8596612422F for <tls@ietfa.amsl.com>; Fri, 2 Mar 2018 00:32:16 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 3.079
X-Spam-Level: ***
X-Spam-Status: No, score=3.079 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, GB_SUMOF=5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-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 K0skMCwi1r2R for <tls@ietfa.amsl.com>; Fri, 2 Mar 2018 00:32:15 -0800 (PST)
Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) (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 E89421241F8 for <tls@ietf.org>; Fri, 2 Mar 2018 00:32:14 -0800 (PST)
Received: by mail-wm0-f52.google.com with SMTP id i3so1527445wmi.4 for <tls@ietf.org>; Fri, 02 Mar 2018 00:32:14 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=mh8w/UeyyOD4Z5TMPxe2ud22T2cL4AUvCPIEvbhMUSQ=; b=bc5bF1RdVFle/nUj4YdPF/ytt6Fp1xW36ughqpmG4FCR+Jfgeaq+v59wV4oKXrC8jz ZnTk6rGuEjnfCOrHQ0v4z4iv/FN92BTdm5IBmzJLWYblvHml+Bap3riZjvMOqgQ+IP6r EGwp5ujqODffx7GAjx01GVzbgAO1JalPDc6GQqXKybll4bt/lC9JFM+j8UracA/GRw7n jNpK4p5ZY/ISyKdY3Co6tIq8aAlKHo+FLO7gcf7NlKcrL/O33jelQ+oRtsDFyLYHc+WU YWNWSPnSKqVjri7gK7w6FT78Rv50wVMoR5Sm9yvAtAI2J+HWbDYPmwSQEDSoaem5V1R2 HPwA==
X-Gm-Message-State: AElRT7EfZEsVRMVss7raHQDit63+kl6VZst8trVWuQyUgX4HMKQMLa1O Ir+kTMstLzDgLibKPgto6f3iH4F1tjg=
X-Google-Smtp-Source: AG47ELuuEyzSjEr3enVlbhIffLqOE9/6sTlra9of2858lxS6+Vl1PscJQB/8pYjWGKtsup5Wk6OGAQ==
X-Received: by 10.28.122.11 with SMTP id v11mr784787wmc.38.1519979533392; Fri, 02 Mar 2018 00:32:13 -0800 (PST)
Received: from dhcp-10-40-1-102.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id q186sm714592wmb.33.2018.03.02.00.32.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Mar 2018 00:32:12 -0800 (PST)
Message-ID: <1519979532.514.11.camel@redhat.com>
From: Nikos Mavrogiannopoulos <nmav@redhat.com>
To: "Paterson, Kenny" <Kenny.Paterson@rhul.ac.uk>, "<tls@ietf.org>" <tls@ietf.org>
Date: Fri, 02 Mar 2018 09:32:12 +0100
In-Reply-To: <16A9FD3A-7805-4130-8438-39D0D3E7E3AB@rhul.ac.uk>
References: <16A9FD3A-7805-4130-8438-39D0D3E7E3AB@rhul.ac.uk>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.26.5 (3.26.5-1.fc27)
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/6elV1g6j4G3Jph1Zmw9-jE8o7Ts>
Subject: Re: [TLS] Possible timing attack on TLS 1.3 padding mechanism
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tls/>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Mar 2018 08:32:17 -0000

On Thu, 2018-03-01 at 21:52 +0000, Paterson, Kenny wrote:
> Hi,
> 
> I've been analysing the record protocol spec for TLS 1.3 a bit,
> specifically the new padding mechanism. I think there's a possible
> timing attack on a naïve implementation of de-padding. Maybe this is
> already known to people who've been paying more attention than me!
> 
> Recall that the padding mechanism permits an arbitrary number of 00
> bytes to be added after the plaintext and content type byte, up to
> the max record size. This data is then encrypted using whichever AEAD
> scheme is specified in the cipher suite. This padding scheme is quite
> important for TLS 1.3 because the current AEAD schemes do leak the
> length of record plaintexts. There should be no padding oracle style
> attack possible because of the integrity guarantees of the AEAD
> schemes in use. 
> 
> The idea for the timing attack is as follows. 
> 
> The natural way to depad (after AEAD decryption) is to remove the 00
> bytes at the end of the plaintext structure one by one, until a non-
> 00 byte is encountered. This is then the content type byte. Notice
> that the amount of time needed to execute this depadding routine
> would be proportional to the number of padding bytes. If there's some
> kind of response record for this record, then measuring the time
> taken from reception of the target record to the appearance of the
> response record can be used to infer information about the amount of
> padding, and thereby, the true length of the plaintext (since the
> length of the padded plaintext is known from the ciphertext length).
> 
> The timing differences here would be small. But they could be
> amplified by various techniques. For example, the cumulative timing
> difference over many records could allow leakage of the sum of the
> true plaintext lengths. Think of a client browser fetching a simple
> webpage from a browser. The page is split over many TLS records, each
> of which is individually padded, with the next GET request from the
> client being the "response record". (This is a pretty simplistic view
> of how a web browser works, I know!). The total timing difference
> might then be sufficient for webpage fingerprinting, for example. 
> 
> I'm not claiming this is a big issue, but maybe something worth
> thinking about and addressing in the TLS 1.3 spec.
> 
> There's at least a couple of ways to avoid the problem:
> 
> 1. Do constant-time depadding - by examining every byte in the
> plaintext structure even after the first non-00 byte is encountered. 
> 2. Add an explicit padding length field at the end of the plaintext
> structure, and removing padding without checking its contents. (This
> should be safe because of the AEAD integrity guarantees.) 
> 
> Option 2 is probably a bit invasive at this late stage in the
> specification process. Maybe a sentence or two on option 1 could be
> added to the spec.

Hi,
 It was brought previously to the WG [0], and the bottom line was to push
for any solution to implementations.

As of the "naïve implementation of de-padding", I wouldn't put like that.
It is a straightforward method of de-padding after reading the draft, and
I believe all implementations out there use that method.

regards,
Nikos


[0].
https://www.ietf.org/mail-archive/web/tls/current/msg24365.html