[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 15/19] appended signatures: parse PKCS#7 signedData and X.
Re: [PATCH v3 15/19] appended signatures: parse PKCS#7 signedData and X.509 certificates
Tue, 17 May 2022 23:19:44 +1000
apologies for the delay, I've left IBM and am taking a while to get back
on my feet.
> On Thu, Apr 21, 2022 at 09:32:41PM +1000, Daniel Axtens wrote:
>> >> This code allows us to parse:
>> >> - PKCS#7 signedData messages. Only a single signerInfo is supported,
>> >> which is all that the Linux sign-file utility supports creating
>> >> out-of-the-box. Only RSA, SHA-256 and SHA-512 are supported.
>> >> Any certificate embedded in the PKCS#7 message will be ignored.
>> >> - X.509 certificates: at least enough to verify the signatures on the
>> >> PKCS#7 messages. We expect that the certificates embedded in grub will
>> >> be leaf certificates, not CA certificates. The parser enforces this.
>> > Doesn't grub support CA certificates for EFI?
>> For EFI, the verification isn't done by grub, it's done by either the
>> shim or by firmware. They do - per the spec - support certificate
>> chaining. So you could validly put a CA cert into db or MokList and have
>> a signature on an Authenticode signature chain back to that.
>> > Why limit to leaf certificates here?
>> Conventionally, appended signatures don't include embedded certificates
>> whereas Authenticode signatures do. There's nothing stopping you putting
>> one into the PKCS#7 message for an appended signature - it's just not
>> the way they are used on kernel modules or kernel binaries. So if
>> there's not an embedded certificate that can chain back to a CA
>> certificate, grub has to have access to the leaf certificate.
>> > If this is technical limitation of the code in question could you fail
>> > the build when CA certificate is used rather than crashing the
>> > bootloader when it boots?
>> I guess. I think IBM has been reasonably open in saying that static key
>> secure boot is not the end of the road for Power, so we expect that
>> ultimately keys could be loaded from somewhere other than the binary
>> like firmware storage. So even if we added this check in grub-mkimage,
>> we'd still need to keep it at runtime as well.
>> >> - X.509 certificates support the Extended Key Usage extension and handle
>> >> it by verifying that the certificate has a single purpose, that is code
>> > ^^^^^^^^^^^^^^
>> > This should be updated I suppose.
>> So this is - surprisingly - still accurate! We still only support 1
>> _Extended_ Key Usage. The change that we made as a result of SUSE's bug
> It is unclear to me OpenFirmware enforces such restriction as well ? My
> understanding is that the (single purpose) restriction is lifed in
> firmware becuase it happily accepts our cert and boots SUSE signed grub
> in secure boot without complaining Key Usage. If so I wonder why it is
> necessary for having the stricter check in grub ?
I suppose it depends on the particular OpenFirmware implementation. You
would have to ask IBM via official channels what restrictions the
proprietary firmware imposes. The SLOF prototype probably imposes no
restrictions because it was thrown together very very quickly as a proof
of concept and development tool.
I do still want to tease out (or repeat ad nauseum) the difference
between Key Usage and Extended Key Usage. The original code permitted a
Key Usage of only Digitial Signature and no critical Extended Key
Usages. Subsequent versions, such as this one, support multiple Key
Usages, so long as the Digital Signature Usage is present, and either
zero or one Extended Key Usage sections, which permit only the Code
AIUI/IIRC, SUSE OBS keys have Digital Signature and another Key Usage
set - which was where we ran into issues with your keys.
>> report was to support additional regular, non-extended key
>> usages. Here's the change broken out:
> Would this change be used next version ?
The next proprietary firmware version, or the next revision of this
series? I don't have any insights into the future firmware
development. For grub, that change is part of this v3 series already.
>> commit 6056d5fc59907c486309c401135757f00ebf7760
>> Author: Daniel Axtens <email@example.com>
>> Date: Tue Nov 30 15:00:57 2021 +1100
>> x509: allow Digitial Signature plus other Key Usages
>> Currently the x509 certificate parser for appended signature
>> verification requires that the certificate have the Digitial Signature
>> key usage and _only_ the Digitial Signature use. This is overly strict
>> and becomes policy enforcement rather than a security property.
>> Require that the Digitial Signature usage is present, but do not
>> require that it is the only usage present.
>> Reported-by: Michal Suchanek <firstname.lastname@example.org>
>> Signed-off-by: Daniel Axtens <email@example.com>
>> diff --git a/grub-core/commands/appendedsig/x509.c
>> index 70480aa73c9d..6ae985b30ff8 100644
>> --- a/grub-core/commands/appendedsig/x509.c
>> +++ b/grub-core/commands/appendedsig/x509.c
>> @@ -547,7 +547,7 @@ cleanup:
>> * Verify the Key Usage extension.
>> - * We only permit the Digital signature usage.
>> + * We require the Digital signature usage.
>> static grub_err_t
>> verify_key_usage (grub_uint8_t *value, int value_size)
>> @@ -586,10 +586,10 @@ verify_key_usage (grub_uint8_t *value, int value_size)
>> goto cleanup;
>> - if (usage != digitalSignatureUsage)
>> + if (!(usage & digitalSignatureUsage))
>> err =
>> - grub_error (GRUB_ERR_BAD_FILE_TYPE, "Unexpected Key Usage value: %x",
>> + grub_error (GRUB_ERR_BAD_FILE_TYPE, "Key Usage (0x%x) missing Digital
>> Signature usage",
>> goto cleanup;
>> Kind regards,
>> Grub-devel mailing list
> Grub-devel mailing list
|[Prev in Thread]
||[Next in Thread]|
- Re: [PATCH v3 15/19] appended signatures: parse PKCS#7 signedData and X.509 certificates,
Daniel Axtens <=