Re: [COSE] COSE Support for AES-CTR and AES-CBC

Sophie Schmieg <sschmieg@google.com> Thu, 27 October 2022 18:12 UTC

Return-Path: <sschmieg@google.com>
X-Original-To: cose@ietfa.amsl.com
Delivered-To: cose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 49C07C14F74D for <cose@ietfa.amsl.com>; Thu, 27 Oct 2022 11:12:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -17.607
X-Spam-Level:
X-Spam-Status: No, score=-17.607 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5] autolearn=unavailable autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=google.com
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 7Wjcr0Sn_jtJ for <cose@ietfa.amsl.com>; Thu, 27 Oct 2022 11:12:47 -0700 (PDT)
Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id A33B4C14F74E for <cose@ietf.org>; Thu, 27 Oct 2022 11:12:47 -0700 (PDT)
Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-36cbcda2157so23640207b3.11 for <cose@ietf.org>; Thu, 27 Oct 2022 11:12:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=+AcMD4lwk8ERr7tFHQJ+PmSY2fl0kdbxH6RHs5iPpDY=; b=ckvHn1VVjYhyDb8g4/3gFfyQbAGMEGGJheL4jyG1uq1l7WxpWFjyYUDxHFwcjNri0E 6wh6zBjjtdKHgSulXfdu2IM/d8roU5YXpwUBVTq5aS0swWpv1P0P+6QmjGldpHmMxNB9 wP6YFHpQq6GjnrWZWaN31aH78NUdObTMR2PdUAJkJM1KdLh25pSgNzwjKE8MFMFMpe8x wmHAxYNWCSeJ60ZX9VjfUgggtO3LWzgbDd2puSgg9NQMK+BZZpbhe+un2ZI8mFtJF+BX s8eWk5WZFSlT6K/PfqJE56KSUFj3B31fHkIZc4x9QpL0oe+M1nwXgGkzUVuRC4jTQ9BH UZ+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+AcMD4lwk8ERr7tFHQJ+PmSY2fl0kdbxH6RHs5iPpDY=; b=73YlyinJZKCqwWRLm8151aQt4pwbanq9zFjD7DN494n6MltppdMm6SjvDYU8+BxN44 3k6z3SPc/u+JOs1B0eusaOUUy5KDTDHrItf2lLWC+1QklCgzK+LuGF3aXF/0MI2xacML IyJKMP5iwAk8k4onnGVidmzm0EuUavVRI3OKRpAHTKbMUZXb/+WfNtEv9aRWfA2Is2ME hVgMOV9DXPVovXQwpnO8KsGhqvXaHw5N7K8UHEtG4js0AgjXiyP9fWs6RETEFN8oI42M Rw4F4RZ0RaQV0AK/H8YkwTmM17/ss3MT3S6A25Equt5Hd0F6bdnExP98WFFcwK6UoJg6 i1Iw==
X-Gm-Message-State: ACrzQf3K1SPaDFT0G/chdm3nVQKnD80t6E6SXKQkbW6z6MA9iufRiRIY ZNSFN8mv7N/IRM2qwwxV6iFyCxM48feP888if4PG3xTs6XeGow==
X-Google-Smtp-Source: AMsMyM798SriwVzrZk7swoUGmKzFKQplsAqme9FrKKE0BYkuUaWjf27wAcHrvKnB/MUZQefanheL5Kt5dM/Ch5b463g=
X-Received: by 2002:a81:aa0f:0:b0:360:f698:9036 with SMTP id i15-20020a81aa0f000000b00360f6989036mr46840482ywh.65.1666894366456; Thu, 27 Oct 2022 11:12:46 -0700 (PDT)
MIME-Version: 1.0
References: <CAGi82uNOmJJdO2HKcE8M491Vv_PLgk8J8vvfsEE88CMZkmALmw@mail.gmail.com> <a69db82e96374a36b1f7164da3c5556e@amazon.com>
In-Reply-To: <a69db82e96374a36b1f7164da3c5556e@amazon.com>
From: Sophie Schmieg <sschmieg@google.com>
Date: Thu, 27 Oct 2022 11:12:34 -0700
Message-ID: <CAEEbLAZXLmvQbXkdqJcO2erQLVBic3gfuGPv8XRTSxZRiAaAvQ@mail.gmail.com>
To: "Arciszewski, Scott" <scottarc=40amazon.com@dmarc.ietf.org>
Cc: "Zundel, Brent" <brent.zundel=40avast.com@dmarc.ietf.org>, "cose@ietf.org" <cose@ietf.org>
Content-Type: multipart/alternative; boundary="00000000000097bc5a05ec081652"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cose/BPKWnJraRblWEC9nuIJrNmyr9hE>
Subject: Re: [COSE] COSE Support for AES-CTR and AES-CBC
X-BeenThere: cose@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: CBOR Object Signing and Encryption <cose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cose>, <mailto:cose-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cose/>
List-Post: <mailto:cose@ietf.org>
List-Help: <mailto:cose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cose>, <mailto:cose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 27 Oct 2022 18:15:06 -0000

Hi all,

I'm Sophie from Google's ISE Crypto team and wanted to add a few comments
to this proposal.
I have to agree with Scott's other objection, adding unauthenticated
encryption modes will open COSE to several attacks.

Attack 1: Signature Stripping
Since the kid of the authentication layer and the encryption layer would no
longer be correlated, the attacker can replace the outer signature/mac
layer with their own valid signature/tag without knowing the plaintext that
they are signing. The usual defense against this attack is to use an
IND-CCA2 cipher and include the sender identity in the plaintext. However,
CTR and CBC mode are not IND-CCA2 and would therefore not be able to
implement this mitigation. This means that there has to be an
implementation enforced mapping from outer kid to inner kid to mitigate
this attack.

COSE, similar to JOSE, defines the algorithm in the ciphertext instead of
the key. In JOSE, this design weakness results in several common
vulnerabilities (alg=none, HMAC to ECDSA attacks). In COSE, this weakness
is currently mitigated due to the limited selection of algorithms and the
strict separation of digital signatures and MACs. However, adding new
algorithms to COSE can affect the security of existing algorithms, as
implementations might trust the ciphertext's algorithm information and not
have algorithm information on the key. You can find more information about
this family of attacks in my RWC talk [1]. This leads to the following
family of attacks, which can be combined with Attack 1.

Attack 2: GCM to CTR authentication key compromise attack
AES-GCM is a combination of AES-CTR and GHASH, with the tag being the CTR
encrypted output of the GHASH of the rest of the ciphertext. Knowledge of
the unencrypted GHASH output allows the attacker to calculate the
authentication key used by AES-GCM, allowing for forgeries. In a situation
where the attacker has access to a (partial) decryption oracle, they can
manipulate the ciphertext, switching from AES-GCM to AES-CTR and extracting
the unencrypted GHASH output and with it the GCM authentication key.

Attack 3: GCM to CTR malleability attacks
AES-GCM using AES-CTR for its encryption leads to another attack, allowing
the attacker to switch the algorithm from GCM to CTR, and stripping the tag
of the ciphertext. This bypasses the authenticity check of GCM, allowing
the attacker to manipulate the ciphertext (and with that the plaintext).
This attack can even be used to turn a mere decryption failure oracle into
a decryption oracle, by crafting messages that trigger decryption failures
if a plaintext guess is incorrect, leading to another way to exploit Attack
2.

Attack 4: GCM to CBC plaintext recovery attacks
Changing the algorithm field from AES-GCM to AES-CBC can lead to another
type of attack, where guesses of 16 bytes of plaintext at a time can be
verified via a CBC padding oracle. The details are summarized (including a
proof of concept) in the description of CVE-2020-8911 [2].

In general, COSE is already a fairly overly verbose standard (e.g.
including the algorithm identifier in the ciphertext), so it seems to me
that saving the 16 bytes of overhead of the GCM tag is not worth the risk
of opening implementations up to these attacks which we know from JOSE
implementations are extremely frequent mistakes.

Re: Cryptographic review of standards using CBC and CTR mode: Even though
the modes are well understood, the interactions between modes are much less
obvious, see for [3] for a detailed discussion of this issue. The attacks I
lined out are far from theoretical, and have plagued various
implementations (whether they are implementing JOSE or not implementing any
particular standard), so I think having cryptographers review standards
that use modes like this could be a good idea in general.

[1] https://youtu.be/CiH6iqjWpt8?t=1045
[2]
https://github.com/google/security-research/security/advisories/GHSA-f5pg-7wfw-84q9
[3] https://ieeexplore.ieee.org/document/959888