From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DC02C433EF for ; Thu, 10 Feb 2022 08:01:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A363381F9A; Thu, 10 Feb 2022 09:01:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EW68kfkO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1AE3081F9A; Thu, 10 Feb 2022 09:01:19 +0100 (CET) Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BA9C98169D for ; Thu, 10 Feb 2022 09:01:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1034.google.com with SMTP id h14-20020a17090a130e00b001b88991a305so7708672pja.3 for ; Thu, 10 Feb 2022 00:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=083Xdn5FWUe69f7/gde2PvXJfyXS8HuxKDy0U+9jWgM=; b=EW68kfkOoGIVfwRZtQt7x4M0PO6dy+PPlZ+44yIkb+vQesUg0nonEtkEshvygZZejH CWM/29TZ8CWgQg8rtHKujX02rYpDbBQioQi2PSUG20pabo6EAcQziFTBkScfCPUwlDWn 4bve/Oo/SD2NsGUSgaKmt9Zs3H5punSwsm4MbjHhgRTa0u3NvskzKRwUp9bBe1MWzcDz yclAXjgUHK3cyB5eWse3Ej4OY7XuAmqJPM7AFt6d0ApSALKTg2lYmfjjo+GCUda0UTml IUrS+tXTGtLVx/Y8QbyF6smzekcy8jBNWzZ1krZ6h6bhQoEsfDhsr3mOjJQ4nRQq4IxR fnzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=083Xdn5FWUe69f7/gde2PvXJfyXS8HuxKDy0U+9jWgM=; b=VRpmcQcDBWj5jxUUNtAwOP2oNQrvDcUXEBWPMvX/oiAGqxR0jTjsihh7wsBELJHcVA +QsfHGW3OQPFBS5T2C8Q1bbbJS7Sf2nXTn3B6PekWpfhepkMscQqq+05Ci54S2X5r7fB EoAamX4kG+gSLw2sZpHe4Fuh6LMzIaAt2pXFx9keWipneguG2rHniUWBJbkq4Xqnval7 aB7Z/c9ss7K4sdn5jK+nlBzWsm62O4S8X873x+LJ376ZgyZJkA4gF56zB6elNxD3yWmt 572bkllAyuiAg/ZpVGeMNnQUJViwJQFnfH8heha7ZUyVJxmycVeVo4YnT3kEA+8szPdp vUSQ== X-Gm-Message-State: AOAM5318QcHQraejfyDnH3qmlgjKxGyvT3yCRA/nUHaNSW2xy9+IyW/9 +hr2nkSNuTWHGnhActY3H6m3sg== X-Google-Smtp-Source: ABdhPJwwRGcLrbZpNVN2tde3pptNqt//J/9cIhGMa33Jb6tqseQlNWo5ecPMu6O3Ma57mKmuDbZs3w== X-Received: by 2002:a17:90b:1d90:: with SMTP id pf16mr1528981pjb.245.1644480073122; Thu, 10 Feb 2022 00:01:13 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id m14sm23062559pfc.170.2022.02.10.00.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:01:12 -0800 (PST) Date: Thu, 10 Feb 2022 17:01:09 +0900 From: AKASHI Takahiro To: Ilias Apalodimas Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: Re: [RFC PATCH 1/2] efi_loader: fix dual signed image certification Message-ID: <20220210080109.GJ12412@laputa> Mail-Followup-To: AKASHI Takahiro , Ilias Apalodimas , Heinrich Schuchardt , u-boot@lists.denx.de References: <20220204073202.4141198-1-ilias.apalodimas@linaro.org> <20220210051348.GD12412@laputa> <730ecf32-43d3-58be-63a3-122985d25583@gmx.de> <20220210074115.GH12412@laputa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Thu, Feb 10, 2022 at 09:55:20AM +0200, Ilias Apalodimas wrote: > On Thu, Feb 10, 2022 at 04:41:15PM +0900, AKASHI Takahiro wrote: > > On Thu, Feb 10, 2022 at 09:33:46AM +0200, Ilias Apalodimas wrote: > > > > > > > msg = pkcs7_parse_message(auth, auth_size); > > > > > > [...] > > > > > > > > > > @@ -717,32 +665,32 @@ static bool efi_image_authenticate(void *efi, size_t efi_size) > > > > > > > */ > > > > > > > /* try black-list first */ > > > > > > > if (efi_signature_verify_one(regs, msg, dbx)) { > > > > > > > + ret = false; > > > > > > > EFI_PRINT("Signature was rejected by \"dbx\"\n"); > > > > > > > - continue; > > > > > > > + goto out; > > > > > > > > > > > > If we go to "out" here, we have no chance to verify some cases: > > > > > > 1) An image has two signatures, for instance, one signed by SHA1 cert > > > > > > and the other signed by SHA256 cert. A user wants to reject SHA1 cert > > > > > > and put the cert in dbx. > > > > > > > > > > I am not sure I am following, what does he gain be rejecting the SHA1 > > > > > portion only? Avoid potential collisions? > > > > > > > > If an image has a SHA1 and a SHA256 signature attached and SHA1 *or* > > > > SHA256 is in dbx, we must reject the image. Don't expect a dbx entry for > > > > each of the hashes. - But isn't this what your are doing here: for all > > > > signatures of the image look for one hit in dbx? > > > > > > > > > > Yes exactly. Any match on dbx of any certificate or sha256 of a certificate > > > or a sha256 of the executable will reject the image. > > > > But we believe that SHA256-based signature is still valid > > even if we don't trust SHA1. > > UEFI spec 2.9 page 1715 describes exaclty what we propose here as a > change. The SHAxxx choise is irrelevant, any potential match should reject > the image. > > > > > > Regards > > > /Ilias > > > > Best regards > > > > > > > > Heinrich > > > > > > > > > > > > > > > But this image can and should yet be verified by SHA256 cert. > > > > > > > > > > Why should it be verified? My understanding of the EFI spec is that any match > > > > > in dbx of any certificate in the signing chain of the signature being verified means > > > > > reject the image. > > > > > > > > > > > 2) A user knows that a given image is safe for some reason even though > > > > > > he or she doesn't trust the certficate which is used for signing > > > > > > the image. > > Then he should resign his image with a proper certificate. No, I don't think so. The hash-based verification is for that. -Takahiro Akashi > Regards > /Ilias > > > > What do you think of this case? > > > > -Takahiro Akashi > > > > > > > > -Takahiro Akashi > > > > > > > > > > > > > } > > > > > > > > > > > > > > if (!efi_signature_check_signers(msg, dbx)) { > > > > > > > + ret = false; > > > > > > > EFI_PRINT("Signer(s) in \"dbx\"\n"); > > > > > > > - continue; > > > > > > > + goto out; > > > > > > > } > > > > > > > > > > > > > > /* try white-list */ > > > > > > > if (efi_signature_verify(regs, msg, db, dbx)) { > > > > > > > ret = true; > > > > > > > - break; > > > > > > > + continue; > > > > > > > } > > > > > > > > > > > > > > EFI_PRINT("Signature was not verified by \"db\"\n"); > > > > > > > + } > > > > > > > > > > > > > > - if (efi_signature_lookup_digest(regs, db, false)) { > > > > > > > - ret = true; > > > > > > > - break; > > > > > > > - } > > > > > > > > > > > > > > - EFI_PRINT("Image's digest was not found in \"db\" or \"dbx\"\n"); > > > > > > > - } > > > > > > > + /* last resort try the image sha256 hash in db */ > > > > > > > + if (!ret && efi_signature_lookup_digest(regs, db, false)) > > > > > > > + ret = true; > > > > > > > > > > > > > > -err: > > > > > > > +out: > > > > > > > efi_sigstore_free(db); > > > > > > > efi_sigstore_free(dbx); > > > > > > > pkcs7_free_message(msg); > > > > > > > -- > > > > > > > 2.32.0 > > > > > > > > > > > > > > > > > Thanks > > > > > /Ilias > > > >