|
|
Subscribe / Log in / New account

Attestation for kernel patches

By Jonathan Corbet
March 2, 2020
The kernel development process is based on trust at many levels — trust in developers, but also in the infrastructure that supports the community. In some cases, that trust may not be entirely deserved; most of us have long since learned not to trust much of anything that shows up in email, for example, but developers still generally trust that emailed patches will be what they appear to be. In his ongoing effort to bring more security to kernel development, Konstantin Ryabitsev has proposed a patch attestation scheme that could help subsystem maintainers verify the provenance of the patches showing up in their mailboxes.

One might wonder why this work is needed at all, given that email attestation has been widely available for almost exactly as long as the kernel has existed; Phil Zimmermann first released PGP in 1991. PGP (and its successor, GnuPG) have always been painful to use, though, even before considering their interference with patches and the review process in particular; PGP-signed mail can require escaping characters or be mangled by mail transfer agents. It is safe to say that nobody bothers checking the few PGP signatures that exist on patches sent via email.

Ryabitsev's goal is to make attestation easy enough that even busy kernel developers will be willing to add it to their workflow. The scheme he has come up with is, for now, meant for integration with processes that involve using git send-email to send out a set of patches, though it is not tightly tied to that workflow. A developer can add attestation to their process by creating a directory full of patches and sending them out via git send-email in the usual manner; attestation is then done as a separate step, involving an additional email message.

In particular, the developer will run the attest-patches tool found in Ryabitsev's korg-helpers repository. It will look at each patch and split it into three components:

  • Some patch metadata: specifically the author's name and email address, along with the subject line.
  • The commit message.
  • The patch itself.

The tool will use sha256sum to create a separate SHA-256 checksum for each of the three components. The three checksums are then joined, in an abbreviated form, to create a sort of unique ID for the patch that looks like:

    2a02abe0-215cf3f1-2acb5798

The attest-patches tool creates a file containing this "attestation ID", along with the full checksums for all three components:

    2a02abe0-215cf3f1-2acb5798:
      i: 2a02abe02216f626105622aee2f26ab10c155b6442e23441d90fc5fe4071b86e
      m: 215cf3f133478917ad147a6eda1010a9c4bba1846e7dd35295e9a0081559e9b0
      p: 2acb5798c366f97501f8feacb873327bac161951ce83e90f04bbcde32e993865

A block like this is generated for each patch given to attest-patches. The result happens to be a file in the YAML format, but one can live in ignorance of that fact without ill effect. The file is then passed to GnuPG for signing. The final step is to email this file to signatures@kernel.org, where it will appear on a public mailing list; attest-patches can perform this step automatically.

On the receiving end, a reviewer or subsystem maintainer runs get-lore-mbox with the -aA options; -A does not actually exist yet but one assumes it will appear shortly. As the tool creates a mailbox file suitable for feeding to git am, it will verify the attestation for each of the patches it finds. That is done by generating its own attestation ID for each patch, then using that ID to search for messages on the signatures mailing list. If any messages are found, the full checksum for each of the three patch components is checked. The GPG signature in the file is also checked, of course.

If the checks pass — meaning that an applicable signature message exists, the checksums match the patches in question, and the message is signed by a developer known to the recipient — then get-lore-mbox will create the requested mailbox file, adding a couple of tags to each patch describing the attestation that was found. Otherwise the tool will abort after describing where things went wrong.

A test run of the system has already been done; Kees Cook generated an attestation message for this patch series. He said that this mechanism would be "utterly trivial" to add to his normal patch-generation workflow.

Jason Donenfeld, instead, was unconvinced of the value of this infrastructure. He argued that "maintainers should be reading commits as they come in on the mailing list" and that attestation would make the contribution process harder. He asked: "is the lack of signatures on email patches a real problem we're facing?"

Ryabitsev responded that he saw this mechanism as addressing two specific threats:

  • An "overworked, tired maintainer" may be tempted to perform cursory reviews of patches from trusted developers; attestation at least lets them know that those patches actually came from their alleged author.
  • Maintainers might diligently review patches arriving in email, then use a tool like get-lore-mbox to fetch those patches for easy application. If lore.kernel.org has been compromised, it could return a modified form of those patches and the maintainer may well never notice. Once again, attestation should block any such attack.

He ended with a hope that the process he has developed is easy enough that developers will actually use it.

Whether that will actually happen remains to be seen. The use of signed tags on pull requests is still far from universal, despite the fact that they, too, are easy to generate and Linus Torvalds requires them for repositories not hosted on kernel.org. Based on past discussions, it seems unlikely that Torvalds will require attestation for emailed patches. So if patch attestation is to become widespread in the kernel community, it will be as a result of lower-level maintainers deciding that it makes sense. Of course, a successful attack could change attitudes quickly.

Index entries for this article
KernelDevelopment tools
KernelSecurity/Patch verification


to post comments

Attestation for kernel patches

Posted Mar 2, 2020 23:47 UTC (Mon) by flussence (guest, #85566) [Link] (5 responses)

Wouldn't it be easier to make existing commit.gpgSign signatures round-trip through format-patch? There's plenty of space under the "--\n$gitversion" signature for an actual signature.

Attestation for kernel patches

Posted Mar 3, 2020 4:12 UTC (Tue) by logang (subscriber, #127618) [Link]

I would definitley prefer something like that.

My git configuration already signs every commit with my key from a smart card and it's a shame that the send-email flow loses that information.

Attestation for kernel patches

Posted Mar 3, 2020 4:19 UTC (Tue) by qyliss (subscriber, #131684) [Link]

I believe that those signatures include, for example, the parent and the committer. Not all that information is preserved through format-patch, and nor would it necessarily be desirable for it to be.

Attestation for kernel patches

Posted Mar 5, 2020 12:02 UTC (Thu) by atnot (subscriber, #124910) [Link]

One problem with this is the immense size and overhead of pgp signatures, which makes them kind of impractical to use. Modern tools like minisign generate signatures that are small enough to fit on one line. However, I'm afraid many people unfortunately won't switch away from pgp very soon.

Attestation for kernel patches

Posted Mar 12, 2020 3:52 UTC (Thu) by OrbatuThyanD (guest, #114326) [Link] (1 responses)

honestly, gpg needs to be replaced as the default signing mechanism for git patches.

git needs alternatives, stat. gpg needs to be allowed to die.

Attestation for kernel patches

Posted Mar 13, 2020 3:43 UTC (Fri) by flussence (guest, #85566) [Link]

I don't disagree. At least the existing GPG support can be a set-and-forget affair; what's being proposed here looks very manual and limited to one specific workflow.

Attestation for kernel patches

Posted Mar 3, 2020 7:35 UTC (Tue) by nim-nim (subscriber, #34454) [Link]

There seems quite a lot of overlap with https://blogs.gnome.org/hughsie/2020/02/28/introducing-jcat/

Attestation for kernel patches

Posted Mar 3, 2020 10:07 UTC (Tue) by unixbhaskar (guest, #44758) [Link]

I do agree with Jason in this regard. It will certainly make "unnecessarily" complicate the matter. It might be a good idea, but certainly, disrupt and kick away lots of people from contributing.

Well, if you insist, sooner or later it will get under the hood. Kai, this is not criticizing, but it might be easy for a few people, think about the rest.

Attestation for kernel patches

Posted Mar 3, 2020 21:16 UTC (Tue) by dkg (subscriber, #55359) [Link]

The proposed mechanism seems surprisingly convoluted for its intended purpose.

It would be simpler to add some sort of --sign-with option to git send-email, and some sort of --require-signature-from option to git am, and use e-mail PGP/MIME (or S/MIME, i don't really care) cryptographic signatures.

Then users could add the appropriate options to their git config and move on with their existing workflow.

One legitimate concern with this counter-proposal is that the "patch metadata" won't be automatically covered by the signature. This has been a long-standing flaw in cryptographic e-mail signatures, but it has a very simple resolution (replicating the relevant e-mail headers inside the cryptographic payload), which is already in use by multiple e-mail clients.

Attestation for kernel patches

Posted Mar 4, 2020 7:11 UTC (Wed) by gdt (subscriber, #6284) [Link] (1 responses)

Can I suggest that the person compiling the kernel, as well as the maintainer, should be an enduser of patch attestation? I think it's reasonable for a person compiling the kernel to be able to be able to ask "were any the patches contributing to this kernel altered from those patches the developer intended to send?"

Attestation for kernel patches

Posted Mar 31, 2020 10:22 UTC (Tue) by madalinbucur (guest, #122118) [Link]

There are (rare) occasions where the maintainer alters the patches when he applies them, this would complicate that step.

The whole thing relies on the signature sent to a certain mailing list.
Can't a rogue patch sender also sign and send to that signature mailing list?


Copyright © 2020, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds