Requirements for signing

Agreed design

  1. Package uploaded to whatever queue
  2. process-upload matches it to a configured list of packages that need signing, and triggers signing service
  3. Signing service unpacks binary and generates detached signatures
    • The list of things to be signed is part of the source package template (see below)
  4. Signing service updates and uploads a source package with the detached signatures
    • The source package is generated from a template in the binary package. This is slightly weird, but it can't get out of sync and makes reproducibility easy. It allows binNMUs to work without adding too much complexity to the signing service.

Template organization

The signed source package will be a native package, so any "-" in the binary version must be replaced by another character (such as "+" or ".") in the template changelog. For binNMUs, the "+bX" at the end of the binary version must be mapped to ".bX" in the template changelog. The versions of signed binary package may be overridden to undo these changes.

dak (config) changes

The mappings of packages to be signed are being published at https://incoming.debian.org/debian-buildd/project/external-signatures/requests.json and https://security-master.debian.org/debian-security-buildd/project/external-signatures/requests.json (restricted access).

signing box requirements

#  (archive, suite, source or binary (template package), architecture) 
{
  "packages": [
    {
      "suite": "unstable", 
      "version": "0.1-1", 
      "architecture": "all", 
      "package": "linux-image-m68k-signed-template"
    }, 
    {
      "suite": "unstable", 
      "version": "0.1-1", 
      "architecture": "all", 
      "package": "package"
    }
  ]
}

Source template inside a binary package

/usr/share/code-signing/template-binary-package-name/

{$pkg_name: {
    "files": [
         {"sig_type": "efi" | "linux-module", "file": "file-name-relative-to-package-root"}, ...
    ]
}}

Describing the trust chain

BenHutchings proposes the following addition, to avoid accidentally creating a trust chain from production to test signing certificates.

For every binary package mentioned in files.json, there must be an additional "trusted_certs" key. The value for this key is an array identifying all certificates that are built-in to the signed code as roots of trust for verifying additional privileged code, excluding any certificates for which the private key was generated and discarded during the build process. The certificates are identified by their SHA-256 fingerprint, i.e. the SHA-256 digest of the certificate in DER format, formatted as a hexadecimal string.

For example, for a binary package "foo" that trusts only Debian's current UEFI CA, the following would be added:

{"foo": {
    "trusted_certs": ["079646974bce09b1f04da67bd722d1fb0947ae4c4010bccdbba52d5b23cbf1a2"]
}}

The value for "trusted_certs" may be an empty array (in case there are no such certificates) but the key must still be present.

The signing service must verify that this key is present and that all certificate fingerprints in the array are in the permitted (configurable) set of trusted certificates.

Open questions

Secure Boot General Information

The idea is to use the latest shim signed by Microsoft that will enable us to bootstrap into a later boot loader that can be signed by Debian. grub itself will need to be signed by a FTP master, so we will need to sort out key signing. Same for the kernel.

Roughly matches existing deployment in Ubuntu, although hopefully with some further improvements on top.

Software

The shim is an EFI executable that is in a format that is acceptable for signing by microsoft. UEFI has a database of keys that can be used for signing, the shim is to be used by a 3rd party.

It supports its own user-modifiable key database (?MokManager) so an end user can install their own key (requires the user to be physically present). Grub will call into the shim to verify the kernel, so you get a fully signed root of trust. Could theoretically verify initramfs and root filesystem. You can also disable sig validation so shim will launch anything you give it (again requiring physical presence)... from then on it will boot any copy of grub/kernel, without disabling secure boot entirely... allows for kernel and grub development without having to jump through a lot of hoops.

The aim is the least worst that still respects user's freedoms. Local key management was implemented by SUSE, the rest by redhat.

Potential improvements: fall-back bootloader so if a system loses all boot entries, the shim will re-enroll and register them and boot normally.

sbsigntool

Grub has many patches from redhat/mjg causing it to operate in a secure boot way. When grub core is signed it refuses to load any modules that are unsigned. Secure boot core images are larger as a result. That code is in debian, some of it is configured off by default, but that is trivial to change. There is code to build custom uploads. For more information, please see: http://thread.gmane.org/gmane.linux.debian.devel.boot/143954

Involved and related software/packages: shim grub efilinux linux openssl mokutil pesign sbsigntool secureboot-db efitools vboot-kernel-utils

MSFT key requirements

MSFT has a short list of requirements, it boils down to these critical points:

TODO: Ubuntu does a key sharding process, required some kind of approval from Microsoft, find out what this procedure is

Pre-submission testing

Task list

See the tracking bug 820036.

Packages needing signing

Suites enabled for signing

References

Earlier proposed signing architectures

First option: by-hand script in dak

signing architecture with dak

The main idea is to have a signing-box with access to the signing usb keys.

Basically, the steps can be described as:

Ideally dak would upload the -signed version of the package automatically, but this can be done later. Right now, we currently have the ?YubiKeys plugged into the fasolo machine, so the signing-box would also run in fasolo for now. For security and better key management, the signing-box would run as another user that we called codesign in the diagram above.

One of the suggestions is to use a machine called coccia to host the detached signatures for the DDs to retrieve them.

what we have

signing-box code:

dak patch:

what we need

Second option: use buildd + debhelper instead of dak

The idea is that instead of changing dak, add the signing logic to a helper script and use that in build process on the buildd.

Signing architecture with buildd

Basically, the steps can be described as:

  1. The maintainer uploads the source package to dak (without the binary packages)
  2. dak/wanna-build sends the package to the buildd as usual; the buildd works as normal and start the build process of the package in an isolated environment (chroot)
  3. During the package build, it uses the dh_signcli tool (which doesn't exist yet) to request signatures on various files.
  4. dh_signcli communicates with dh_signd (which also doesn't exist yet) outside of the chroot environment to request signatures. This communication can be done via some method (maybe d-bus, maybe unix socket?), so that dh_signcli can work even if the chroot environment doesn't have network enabled. dh_signd checks if the package is allowed to request signatures.
  5. dh_signd sends a tarball of binaries to the signing-box through ssh
  6. The signing-box uses the ?YubiKey to sign the binaries

  7. The signing-box sends a tarball back to dh_signd with the detached signatures
  8. dh_signd send the detached signatures back to the dh_signcli
  9. The package build continues, using the output of dh_signcli to assemble packages that include signatures.
  10. buildd uploads the build output into the archive as normal.

Handling errors

Issues

1. When the package enters in the NEW queue, the binary package sent by the maintainer is not discarded, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=798000 Possible solutions:

Or actually fix the bug.

2. Builds are going to stall waiting on the signing service to do stuff. That could take some time for Linux, for example, with many many signs needed for individual modules.

3. Signing during build process isn't reproducible.

Perhaps we could record signatures in the buildinfo file, and have a dummy signing service that replays them from there.

4. Signing service may be exploitable by compromised buildd.

what we have

signing-box code:

what we need

Wrap-up of the discussions so far

  1. Cons about the byhand approach:
    • 1.1. byhand files for security-master break the security-master -> ftp-master sync.

    • 1.2. The autobyhand scripts don't work for uploads that go to NEW
    • 1.3. byhand files are not that nice; I would rather not add more of them
    • 1.4. byhand files aren't publish in the public archive, so harder to see what was actually signed. Nothing enforces the binaries in the *.deb and the *.tar.gz are related after all. Or that a *.deb is present.
    • 1.5. Not clear how to publish signed binaries for the manual step in preparing uploads for the security archive.
  2. About the Buildd approach:
    • 2.1. The exact same -signed.deb package is not reproducible, but the signature can be easily striped away and we can compare if the generated package is the same. While the byhand approach we would have two source packages, and the source for the -signed package would be shipped with the detached signatures.
    • 2.2. Signing things automatically is dangerous as an attacker can attack the infrastructure and get things signed (even if we have a whitelist to limit our signing process to some packages as grub and the kernel), so we will need to revoke signatures or the key. We could develop a mechanism to easily revoke things.
    • 2.3. Ftp masters don't want verify each package by to say it is safe to sign
    • 2.4. As buildd will access an external signing service, it makes it hard to isolate the builds and restrict the potentially evil things only to this build