Skip to content

Tracking: End‐to‐end NixOS boot security #549372

Open

Description

@emilazy

@ElvishJerricco and I are working on bringing support for end‐to‐end trusted boot to upstream NixOS, thanks to NLnet funding and building on experience using and maintaining Lanzaboote, our systemd integration, and the NixOS installer images.

Our planned approach will enable more seamless integration with Nix builds and upstream infrastructure, and extend the chain of trust to cover the entire stage 2 system closure. The primary target is TPM‐based Measured Boot to allow flexible attestation and validation of the entire boot chain, with Secure Boot covering early boot machinery and UEFI drivers. The approach can support both user‐controlled keys and future out‐of‐the‐box Secure Boot support using the official Microsoft keys.

The core components of the effort are:

  • autopen: A new cryptographic signing tool that enables the integration of signing directly into Nix builds while maintaining essential purity and reproducibility properties. This allows building systems with Secure Boot support without stepping outside of the Nix build model, and will make it possible for the official NixOS Hydra to build reproducible ISOs with Secure Boot support, while keeping private keys safe. See the detailed explanation of the design from a Nix perspective for more detail on how autopen accomplishes these goals.

  • UEFI Secure Boot support for NixOS: We are working on upstreaming optional support for using autopen to sign essential packages like shim, systemd‐boot, fwupd, and Linux kernel images, including NixOS integration. We intend to target the shim review requirements including kernel lockdown to ensure that the Secure Boot guarantees are maintained and get ready for having our shim signed by the Microsoft keys in future, while still maximizing flexibility and user freedom by seamlessly supporting Machine Owner Keys and fully user‐controlled signing chains.

  • Stage 2 measurement: Using a new design for content‐based Nix store integrity inspired by composefs, we plan to implement optional support for pinning and measuring a cryptographic hash of the entire NixOS system closure. This will provide guarantees approaching those of existing dm-verity approaches to system integrity used for fixed‐function appliances, while being fully compatible with mutable stores and standard NixOS upgrade mechanisms, enabling future applications like hardware‐backed disk encryption locked to the system configuration, and validation of remote server integrity.

Pull requests

Funding

This project is funded through NGI Fediversity Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet program. Learn more at the NLnet project page.

Activity

  1. added
    1.severity: significant
    5.scope: tracking
    on Aug 5, 2026
  2. baloo commented on Aug 5, 2026

    @baloo
    Member

    This is a fantastic job! Thank for you for leading the way.

    One thing I'd like to see in the UDS protocol of autopen would be the support for multiple messages. Specifically for the signature of kernel modules, I'd like to see all the modules be submitted for signature in a single multipart payload. They should all be signed, or none. I believe this is easier for audit and also failure cases:

    • A single event for all modules instead of an event per module in an audit log is easier to track.
    • The whole set needs to be signed to succeed, otherwise there needs to be a retry logic on the client side of the UDS.

    I think a signature format (along with options) in the autopen request would be nice:

    • Kernel modules and PE files are signed using pkcs7/cms documents (detached signature), the "signer" interface should produce those documents.
      • Windows PE signature has support for countersignatures to provide signed timestamps. Those countersignatures are fields placed in the CMS.
    • Linux IMA is its own kind of signature scheme (raw ecdsa signature iirc), if we ever wanted to support that.
    • GPG signatures could be used in the future (debian package repos, RPMs, ...)
  3. emilazy commented on Aug 14, 2026

    @emilazy
    MemberAuthor

    Thanks @baloo!

    The underlying autopen protocol does support multiple messages and signing them in parallel, since it’s just exposing methods via Cap’n Proto RPC. For kernel modules, though, I’m pursuing an approach that doesn’t require us to do signatures on individual modules at all. We can use the hash‐based Merkle tree integrity checking once that lands upstream, but in the meantime I’m pursuing a trick to get a similar end result. I hope to have a PR up for that soon with more details.

    In general, I think that it’s best to have as few signature derivations as possible, and keep their reverse dependency closures small, so as to limit how many things require configuring autopen to build and keep as much as possible bit‐identical regardless of what keys are used. (The ISO will inevitably need signed UEFI executables on an ESP, which will inevitably differ based on signing key, but signing kernel modules would mean that the contents of the compressed initramfs would change too, so there’s a tangible difference in how much you require recursive diffoscope‐style diving into in order to satisfy yourself that what Hydra built is functionally equivalent.)

    Given the Merkle tree structure of Nix dependency trees, it’s natural to pin as much as possible by content, and only use signatures where we need to tie trust in top‐level entry points to systems like Secure Boot that require embedded signatures with a fixed root certificate. (That’s also why I think doing as much with a Measured Boot approach as possible is the best fit.) So in the end we’ll hopefully have < 10 signature derivations × 2 architectures per Hydra eval; it didn’t feel worthwhile to add support for multiple signatures per invocation at the CLI and Nix levels to me just to get shim down from three signing derivations to one, especially since a one‐to‐one correspondence of signature derivations and signed messages makes the auditing and reproducibility stories simpler in some ways. (Edit: And also of course since shim will need special handling anyway for the Microsoft signatures.)

    In terms of supporting wrapper formats, I considered this, but lean towards feeling that encoding format knowledge in the signing service is a mistake – it means having to handle non‐trivial formats in security‐sensitive code and having to trust them on the way back out when reusing upstream signatures, as well as risking ossification of format support and increasing network traffic (e.g. from sending entire kernel images rather than just the Authenticode CMS message). autopen currently deals exclusively in raw signatures, which means any format can be handled in a pure manner in the surrounding Nix derivations;systemd-sbsign(1)’s offline signing support is used to handle the Authenticode/PE format, and the X.509 certificate generation works similarly. We can audit the entire chain if we have a transparency log that records derivations and hashes. Since we already have a prepare → sign → attach derivation structure, I think we don’t gain much by baking format support into the protocol. Fedora’s Siguldry service made the same choice.

  4. emilazy commented on Oct 7, 2026

    @emilazy
    MemberAuthor

    The deterministic module signing work is up in #571141, #571142, #571170, and #571181, based on the new kmodigest tool.

  5. ndgigliotti commented on Oct 13, 2026

    @ndgigliotti
    Contributor

    Hi @emilazy and @ElvishJerricco, I wanted to check how this fits with your work before opening any PRs.

    I had trouble getting Secure Boot working on my Surface Laptop Studio 2. Limine went to a black screen without ever showing its menu. Lanzaboote boots fine from a USB stick, but hangs on a black screen right after the systemd-boot menu when booting from the internal SSD. A plain systemd-stub UKI boots fine from the same disk.

    I built a UKI installer into the stock systemd-boot module with a lot of help from Codex and Claude Code. It builds one UKI per generation with systemd-stub and ukify, and can sign them with a db key kept on the machine. I reviewed the code and run it daily. It's been my laptop's only boot path for a couple of weeks, with Secure Boot on and a TPM-unlocked LUKS root, through systemd updates and rollbacks. I also had help writing this comment, which I reviewed too.

    The working branch includes NixOS VM tests: master...ndgigliotti:nixpkgs:systemd-boot-uki-signed-managers

    I could submit it in four parts:

    1. Unsigned UKIs
    2. Signing UKIs
    3. Keeping old generations' images across systemd updates
    4. Signing systemd-boot itself

    Install-time signing conflicts with your build-time approach, so I don't want to push 2 and 4 as a competing design. Would 1 and 3 be useful, or do your plans already cover UKIs? If nothing fits, I'll keep it out of tree and switch to yours when it lands.

  6. nixos-discourse commented on Oct 14, 2026

    @nixos-discourse
  7. emilazy commented on Oct 14, 2026

    @emilazy
    MemberAuthor

    Hi @ndgigliotti, support for signing systemd-boot has already landed in #549373, and we already have a UKI builder in NixOS as system.build.uki. The ukify part of those commits looks like it mostly duplicates that existing functionality within the bootloader script; even when signing a UKI outside of Nix, it’s not necessary to move the build outside. We may use UKIs for the signed kernel images; it would have a lot of advantages like .dtbauto support, though there are trade‐offs to consider.

    However, the approach of signing in the bootloader script, as done by Lanzaboote and those commits, won’t work for upstream support: the signing inherently happens outside of a Nix derivation build, and therefore it cannot compose with further builds that consume the signed kernel image. That doesn’t work when we need to be able to build signed kernel images on central build infrastructure, build ISOs within Nix that take signed kernel images and bootloaders as inputs, copy NixOS system closures with pre‐signed kernels to remote machines without signing keys, etc., which is why we’re designing around the autopen approach.

    I think it doesn’t make sense to upstream these changes to Nixpkgs, as the approach we’re working on will support those seamlessly while still enabling all the same use cases that work with local activation‐time signing. Lanzaboote already does a good job of supporting that out‐of‐tree today, and I think there’s no fundamental obstacle to its signing tooling working with the systemd stub.

  8. ndgigliotti commented on Oct 15, 2026

    @ndgigliotti
    Contributor

    Thanks, that makes sense. I'll keep this out of tree and switch once autopen covers local keys.

    Regarding Lanzaboote, its own stub is what hangs on this machine, and it can't use the systemd stub today. That's why I went with systemd-stub UKIs. I can report the hang to Lanzaboote but I'm not sure how useful it will be.

  9. emilazy commented on Oct 15, 2026

    @emilazy
    MemberAuthor

    Since a lot of people seem interested in Epic’s EAC Linux v2 requirements, here’s a post about that I wrote on Discourse.

  10. nixos-discourse commented on Oct 22, 2026

    @nixos-discourse
  11. nixos-discourse commented on Nov 7, 2026

    @nixos-discourse

    This issue has been mentioned on NixOS Discourse. There might be relevant details there:

    https://discourse.nixos.org/t/nixos-uefi-sige-iso-files/80995/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.severity: significant5.scope: tracking

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions