Re: [COSE] [Suit] [Teep] ECDH-ES + A128KW vs. ECDH-ES + HKDF-256

"lgl island-resort.com" <lgl@island-resort.com> Sun, 31 December 2023 19:13 UTC

Return-Path: <lgl@island-resort.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 51B4AC14F604; Sun, 31 Dec 2023 11:13:17 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.908
X-Spam-Level:
X-Spam-Status: No, score=-1.908 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=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] autolearn=ham autolearn_force=no
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 08CVY-qyOVgD; Sun, 31 Dec 2023 11:13:13 -0800 (PST)
Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2112.outbound.protection.outlook.com [40.107.237.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id A27D9C14F5F6; Sun, 31 Dec 2023 11:13:12 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DkYU6jxzrHWoxzgJL5SSDtv5EtoevDXFrn8/cLkxtzSQPe4tsA/jnCJ4SohEoHE6R2rEwN3yO6pmIDn9AxxwMdMhVtOhIreqUxx2Y+fNkJZyfaeBzU6eJTFBm5u5S/u5qlE03kooFlWakLKzxXyCqmL/kPyz7VuJAUI2jeAVjGzYwFlJ2j7wbswrFZ7WyS42X21gyUzGl7wOIasCrF9/7OxszLpSvd6P4Kp/UOTLSnFeTAJ6xaPCCxa09B/HB4RW878D1jcF7pEo0NOYwEOoQNxi3ShTFCEq8fLByNJGQmGLVDFFylRcF2O5BPAIkD/f24WFQkEVAtyHC0ITahqZ+Q==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=84mUhFcCOUsBWqD5zPZ7Y7kdLO20wiyVWTy7r8sT1qk=; b=PTZplzYpgn1KlniawjNJU+q0Ky72IC5DjxUA1iJ/z7yIjcQmKVSsqtYSJqiVv9jj4OomqXIgWyNBF7aBdJa9VrqKBRSMceb4qJsuFkNUxZGPFni1PZcEvvg/oH0vOPPff6if2BaBSz0+LnbNWZW1J4/lut4rMWcgui5pFrwRJG7m7yvWJxcq5i5X12dbqOWZPTumPj9+AR2V9sry/wI3QbAaJBhWEnsVST8N/hS0LpIw3LU7gRy3otQFVdlxnuphWYw/61ahSDXBS1cgEKaC8bQptIMCRTRd8ZykwUhAlbKYicoE5Z6dp76Uao2Y4wD/svHXIEJtH4cPy7f9NOJsEg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=island-resort.com; dmarc=pass action=none header.from=island-resort.com; dkim=pass header.d=island-resort.com; arc=none
Received: from PH7PR22MB3092.namprd22.prod.outlook.com (2603:10b6:510:13b::8) by SJ2PR22MB5364.namprd22.prod.outlook.com (2603:10b6:a03:583::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.22; Sun, 31 Dec 2023 19:13:07 +0000
Received: from PH7PR22MB3092.namprd22.prod.outlook.com ([fe80::353a:75f1:88a7:5f90]) by PH7PR22MB3092.namprd22.prod.outlook.com ([fe80::353a:75f1:88a7:5f90%6]) with mapi id 15.20.7135.023; Sun, 31 Dec 2023 19:13:07 +0000
From: "lgl island-resort.com" <lgl@island-resort.com>
To: Hannes Tschofenig <hannes.tschofenig@gmx.net>
CC: Russ Housley <housley@vigilsec.com>, Akira Tsukamoto <akira.tsukamoto@gmail.com>, Brendan Moran <brendan.moran.ietf@gmail.com>, suit <suit@ietf.org>, teep <teep@ietf.org>, Ken Takayama <ken.takayama.ietf@gmail.com>, cose <cose@ietf.org>
Thread-Topic: [Suit] [Teep] ECDH-ES + A128KW vs. ECDH-ES + HKDF-256
Thread-Index: AQHaMPyLrfXX2YEdqUqw6OT+QV5e+LCtvTYAgAq4eACABpczAIAELieAgACdwoA=
Date: Sun, 31 Dec 2023 19:13:07 +0000
Message-ID: <E1BF4864-9C0B-43C0-AB06-B6B1015315D5@island-resort.com>
References: <08f701da2d9f$c043a6c0$40caf440$@gmx.net> <655A0104-EF30-42E4-862D-6D4D6E4FDDD9@vigilsec.com> <843e1218-8847-48cc-ada5-9b9cc50e17cf@gmail.com> <00ba01da2e6e$81f1f910$85d5eb30$@gmx.net> <9F676C9F-1573-4DBE-A12A-A9A63BC77014@island-resort.com> <65A259BD-75EF-4EAE-B255-29EBD1ABC319@vigilsec.com> <5E005DCF-86C5-4359-929D-A60DD1C703E1@island-resort.com> <731ab283-e078-4186-ae60-0725d0bf1356@gmx.net> <76B7A923-CC43-45DC-B8BF-D03D95542874@island-resort.com> <06e13dea-6e69-4ef6-a496-ced908cfd982@gmx.net> <3506EFA4-3956-4EB2-9174-3F20222267C0@island-resort.com> <cb729c84-869f-4afa-b4d1-56b32cf923d5@gmx.net>
In-Reply-To: <cb729c84-869f-4afa-b4d1-56b32cf923d5@gmx.net>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=island-resort.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: PH7PR22MB3092:EE_|SJ2PR22MB5364:EE_
x-ms-office365-filtering-correlation-id: 1e74d9fd-d252-441f-14e0-08dc0a34855b
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: BPrF2Wi6fFS5Arx2Er5TTBME3wPo3rvFFxNDLWy4tHD6gwvqz/nAt89Qf39nSt6jCKWJujdC44+iMTcbvGKjTNF26Hs4vXHXUFJQh2HUjM/53N51+k5IHzNPD7Oyj6lValWSPUXRj87mN5vPbFvaC8UIZWSg6Ywi5Q4iFK5ogr9q8H9DZ0TCMZl3yGUGuTK5ViL1AN1+Xt+sJ3quteAZzjk9sdumNEZJrEK2VA22HoR7dSVCBrB6Ovkdq6m6QBrcMVU5vMZlRLrMeaWZmbokv7+zHet/QUmIBSfxcw9ZuJfFpYFx8Rc9lpc3DFYUrZVbTBQazbeRMNIVsMOIJmXDrsIf4kx9I9u4CFHi15Z8PoW0h9RAi/yBl92aokn3qahHsUwqIOxtjaie2zeyk6xp/MzFwpvct8fsd499Rj77635uhBjn2iqs3CoVzOJSg1J8RVke73SwaFIrkN21GfLDdkJXvcj3H1XV2/Tkv4L5nWJZ1xULTYuMy0k4rhHtuoDU+SuG1S20tglym99FK2TG0i9PCXjt0cZflkG1qRZ4HgKmzjNbgTfTgDo9KNXjLXdaFsI59ne8JnqHBubHGVa8vbeayFbR+I1pzJttUSgnM1y+8sIuAkYORRfwmCkl39Ymlj60xaq2xAj/LdIpermAfA==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH7PR22MB3092.namprd22.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39830400003)(366004)(376002)(396003)(136003)(346002)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(38070700009)(41300700001)(38100700002)(122000001)(166002)(66899024)(33656002)(2906002)(36756003)(2616005)(86362001)(5660300002)(478600001)(66446008)(64756008)(6916009)(966005)(76116006)(91956017)(66476007)(66556008)(66946007)(316002)(8936002)(8676002)(54906003)(53546011)(6506007)(6512007)(71200400001)(4326008)(83380400001)(26005)(6486002)(45980500001); DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: QNmNd0BsA8dyb/RxvqssmA4q4B9FAfR9dy3VaBDv3z0pK6siASB9IlGq4jasVGQc9q/8uBvYknCw+7L1YsdWHd7Ru5QCdMVQFZh5xuGG0LHNkzzre42Wzp+LqYMZlf2oScKcvcSz0UmqbdvIoiDUDi3n26c/8a3Bk529YsSdP41nfQWJ0y9OVKAlUhMQ0pswzga0zOV368JdUVKynEv/4x9Carpda+diEi/YuD8hOZLsehsoS82JXDEglu4pevzCwnzRhapoo8vkv3c8H91R9gVWUPRHDOS/acV1Dt7MzKWR4Go2QVR2V83n65SlglJKVIi0Mi4/TV4aBfG4ZJGiENHoZq7bXICdEuwsnShcGDw512l0kMVgblkE94oUJIV+O3Ku3RfLA++R8vwSVlBeaW3Rkv6kdpsafXjY6BG2jRUqabMqw7SSJivweeFw/sDZv3c+D6XH6KJrEm2/FyZXtwHK7g9WZhJYkzBjC4I8DF/DuznXj4duVHBGEe6TM43hu+PUMZf1/2hqQjvVZcKRt0hMtzlhL9XFTORyNTKIKSc4S/M+fc2LHXhtMAcUiT3ZgfMi9e2JCv2g9DM+HnlPzciV1jz9BQ7Kjy4GN+kugejlzKhWI2/oKRxHlbv0gXIEEAa/TMHq2HGsFJRYufOQrD2zSQkhT8RiHFFpikTozVrS5p1zVWEXxq6QUpAeCWUw3LkPRWanIeu6vF7ZmYhMcFtA4vtSrGxNbDmSdVoUZDcRRUn3nX97XS0LnOVNOn5xcSVUfvU27KpkWYP365FUpOeL1741JoMppC2kfXYKlSkzFkkXhM30tH8FI2hluJ1GYM22s0YqhmXamPGYazMm3Va1Ujb2m4CJeUQVo/PFnw8+R1g+WnuyP3dTuvW58T7ccszCZ3DnBnt0NSWGKW7wzaG1sm4+ymUOYPHYR+P5xNSBSjzg8pn6QI4UsDBRpN5gYQY32SzeWebQUVRsfy1mcAAvCLnnDzbA66psVRH7Iw3jKVztBljgBBapDaTehNi1JPOkpbiqUJpBHDXxrsXXN8IebwqimGlzpWTLINDn/SBSdNJXdVcJdy04bn4osjQRSOeNwb+A5Td4L2PEzMXuIDPLaEkTrdUIoRe3ZrvASgwhtYJmhrclcCilh4XeX0HlFafcKEAkGS+O83S1ueOFV5zi0Pba3FmhI9Vie6BphZjfSUPR6ktYmhOOIpPo+LXCU0g9ryVNBUF6XaZCy20Hj84uWSBugsg12YXk6tSbCV9hXoSlM5DY9dRWEkkc08SpvI6j8drJ5k/q8Epbswnq5BeFQvlK3XBLbKz76O2uFiX2OfTp7wFfWCSVsDClAi8CrHNc0IwFjS2LObFwKPyvFM5yoOiiyu0RUPaRYtOuuLhG7jcURMt08ZorZ4d9i8ky8iPiHf7O+Tn/LhN5u+zdV/95ARFcKJH/TWZrEPhraSyFfZ0OmDahjYbtJhkOwmW0ZoofgWRYZVSjRqeVoZd0LnRBplwA3UaxO+93+wqwh62n5IluxViCNDoipULFI4aRUbdhi5lNk/sPuuLGCDGnvqbhx6R74MqX94q9/C/K29FY2Ql7eZlN5fJ2nT5/bZUHXHXN2Xnk/HDbViN+jjWxbQ==
Content-Type: multipart/alternative; boundary="_000_E1BF48649C0B43C0AB06B6B1015315D5islandresortcom_"
MIME-Version: 1.0
X-OriginatorOrg: island-resort.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: PH7PR22MB3092.namprd22.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 1e74d9fd-d252-441f-14e0-08dc0a34855b
X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Dec 2023 19:13:07.1437 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: ad4b5b91-a549-4435-8c42-a30bf94d14a8
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: yfKvMrMgBD0YJUyzjNXn4NbLWR+0YYcaRz610Tx+129a+pJl1qb291Ui1WrV30FL5zbpZCwEsu08mIHy6ORSoA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR22MB5364
Archived-At: <https://mailarchive.ietf.org/arch/msg/cose/du_JkOs3qmmYGTuMN9eSC9-opzs>
Subject: Re: [COSE] [Suit] [Teep] ECDH-ES + A128KW vs. ECDH-ES + HKDF-256
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: Sun, 31 Dec 2023 19:13:17 -0000

+COSE WG (didn’t notice it wasn’t in discussion until now)

Yes, exclusively considering the COSE for SUIT use case, it seems safe enough from what you describe below.

But, from a general COSE view, I still see risk and/or and open issue.
- Privacy provided by COSE shouldn’t be at risk if there is no signing
- The safety of one algorithm shouldn’t be continent on the receiver not implementing other algorithms

I suppose we could write these things in errata security considerations and be done with COSE.

A large part of my comment here is about process and generality. Hannes, you’re (understandably) just focusing on SUIT. That’s understandable, but not enough in the long run. For example, I’m bring up HPKE to to say it should be used for SUIT, but because it is an example of another more thorough standard (except it didn’t support multiple recipients).

My interest is more in encryption of EAT tokens. Often the EAT signing will be before the encryption so it won’t protect the COSE algorithm ID.

When I was managing a team at Qualcomm, I would have responded to an issue like this by redirecting some the people that worked for me to work on this until it was solved.   IETF is kind of a volunteer organization, so we can’t do that. Personally, I plan to work on this later 2024 after I’ve paid attention to some of my other projects for a while.

I also understand how frustrating this is. Around 2017 I chose to use COSE signing with CMS encryption for a Qualcomm EAT precursor product because COSE encryption wasn’t ready and was hard to understand.

LL



On Dec 31, 2023, at 1:48 AM, Hannes Tschofenig <hannes.tschofenig@gmx.net> wrote:


Hi Laurence,


comments below.


Am 28.12.2023 um 18:58 schrieb lgl island-resort.com:


On Dec 24, 2023, at 5:19 AM, Hannes Tschofenig <Hannes.Tschofenig@gmx.net><mailto:Hannes.Tschofenig@gmx.net> wrote:


Hi Laurence, Hi all,

In draft-ietf-suit-firmware-encryption we use a two-layer approach, which means that there is

- a content encryption layer, and

- the recipient layer


For the content encryption layer we have included the protected headers in the Enc_structure structure with AEAD ciphers. The protected header may contain the algorithm identifier. In COSE, it is not mandatory to include the algorithm identifier in the protected header. For non-AEAD ciphers, the Enc_structure structure is not used.

Looks to me that all you have to do change the algorithm ID in the protected header from AES-GCM to AES. If the receiver is capable of processing messages with plain AES content encryption it will happily do so not knowing that it was AES-GCM in the original message. Since plain AES provides no data authentication the receiver won’t notice that the algorithm ID was modified. The protected headers aren’t really protected.

I haven’t thought this through deep enough to know how big a hole this is.


The attack you are describing is to change the algorithm id from AES-GCM to AES-CBC. If you do so, this change would be detected by the signature covering the entire SUIT manifest.

Furthermore, the recipient will check whether the use of AES-CBC is an allowed algorithm. Finally, for the attack to work as presented in LAMPS the recipient then has to try to decrypt the payload and return the result back to the sender.

None of this is realistic but nevertheless worth describing in the draft.



The delivery of firmware images is a one-shot message, if we ignore the possibility for conveying errors using SUIT report. The SUIT report, at least in my reading, would not give an adversary the information necessary for performing the attack outlined at https://datatracker.ietf.org/meeting/118/materials/slides-118-lamps-attack-against-aead-in-cms. It does not hurt to add a paragraph to the SUIT report draft saying that the returned information must not include decrypted payloads in case of a failure. In general, however, SUIT reports behaves like an oracle since it will give different responses depending on the success or failure of the SUIT manifest processing. It might be worthwhile to think about how to mitigate such attacks.

Yes, encryption for SUIT may be a use case safe from this attack, but COSE encryption should be safe regardless of the use case.

I agree but the use of AES-CBC is limited to special use cases and the use case envisioned was firmware encryption. For other use cases, a receipient receiving a payload encrypted with AES-CBC has to fail because there is no use for algorithms other than AEAD ciphers. In general, one has to store algorithm information alongside the key and not let attackers switch algorithms.



COSE-HPKE was mentioned in the mails below, although we do not use it in the SUIT firmware encryption draft. In the COSE-HPKE draft we use a one-layer and a two-layer approach. For the two layer approach, the situation is very similiar to my description above. The algorithm identifier is not included in the KDF at the recipient layer but it is instead included in the Enc_structure structure since the current version of the algorithm id is mandatory in the protected header. (See also the request to make it optional https://github.com/cose-wg/HPKE/issues/39).

I realize you can’t use HPKE for SUIT for a few reasons. I mention HPKE, because its design seems intrinsically immune. I think that is partly because of the design and validation process it used. Seems like COSE didn’t use as good a process.


You can use HPKE for SUIT but we haven't specified it. In the above paragraph I am observing that HPKE in the two layer approach is not necessarily immune to the attack.



So, what should we do? We could follow the approach Russ presented at IETF#118 and later described in https://datatracker.ietf.org/doc/draft-housley-lamps-cms-cek-hkdf-sha256/

His approach applies a KDF to the CEK and an algorithm id. The result is a new CEK, namely CEK'. CEK' is subsequently used for content encryption. This approach is generic but, on the other hand, a point solution to the specific attack presented to LAMPs. In his presentation Russ mentioned that we should/could include other information into the KDF but his write-up ultimately didn't contain that approach.

Alternatively, we could also include the algorithm id from the content encryption layer into the KDF already used for ES-DH and HPKE. This approach would not work for AES-KW.


Here is the part that worries me a bit: We keep changing the KDFs on a frequent basis and the KDFs used for the different algorithms are not well aligned across the different protocols and "container" formats. I have dropped a mail to Paul Van Oorschot asking him for feedback since he was the first one to come up with the class of attacks we are talking about here.

For me, the next step would be a document that is much more prescriptive on the use of KDF’s in COSE encryption. It probably will need to have something new to say how all algorithm IDs in all the COSE layers are input to the KDF. It might be standards track.

Then we need to review and debate and revise thoroughly to be sure we really got it right.

IMO, it is unfortunate, particularly for SUIT, that COSE encryption published in 9052 and 9053 isn’t quite complete in this area.

In SUIT we luckilly have a dedicated document that explains how to use encryption properly. At the start, we thought we just have to reference COSE_Encrypt from the COSE specification and to be done with it. As we know, it turned out to be quite different.


Ciao

Hannes


LL





_______________________________________________
Suit mailing list
Suit@ietf.org<mailto:Suit@ietf.org>
https://www.ietf.org/mailman/listinfo/suit