Skip to content

Confirm which Secure Boot variables each db enrolment route actually needs (community testing wanted) #1267

Open

Description

@darksidemilk

FOG's docs now describe two ways to get this server's certificate into UEFI db, and they need different numbers of variables. Only one of them has been tested, and only on a narrow set of machines. This issue is to find out where the line actually falls, with help from the community.

What we think is true

db is what firmware consults to verify a boot image. PK and KEK only control who may change db. So how many variables you need is not a property of db — it is a property of who performs the write, and whether the platform is in Setup/Custom Mode.

Enrolling via Expected to need Reasoning
The firmware's own tool, platform in Setup/Custom Mode db alone The write is unauthenticated; nothing has to vouch for it
A hypervisor setting (e.g. VMware uefi.secureBoot.dbDefault.file0) db alone Same — the hypervisor writes the default before the guest owns the platform
A running OS: FOG's enrolment task, efi-updatevar/similar on Linux, PowerShell's Secure Boot cmdlets PK, KEK and db In User Mode a db write must be authenticated by a KEK-signed update, and the machine only trusts FOG's KEK if FOG's PK is enrolled too

What has actually been tested

One cell. On VMware, MOK.der added to db alone — no PK, no KEK — then a FOG-signed EFI binary booted directly with no shim. That is the top row, on one hypervisor.

Everything else in that table is mechanism-based reasoning, not measurement. It is the kind of reasoning that has already been wrong more than once during this work: an earlier round concluded that upstream's iPXE loader "cannot drive virtio" when the actual cause was a firmware NIC with no IPv4 configuration, and a claim that shim derives its second stage purely from its own filename turned out to be incomplete (ipxe/ipxe#1684).

What would help

If you have enrolled FOG's certificate into db, please report:

  1. How you enrolled — firmware menu, hypervisor setting, FOG's Enroll Secure Boot Key task, a Linux tool, PowerShell, something else
  2. Which variables you wrote — db only, or PK + KEK + db
  3. Whether the platform was in Setup/Custom Mode at the time (firmware menus usually label this Custom, not Setup Mode)
  4. Whether it worked, and if it failed, what the firmware or tool said
  5. Make and model, or hypervisor and firmware build

Specifically useful, because they are the untested cells:

  • db alone from a firmware menu on physical hardware — confirmed on VMware only so far
  • db alone attempted from an OS tool. If this succeeds anywhere, the User Mode reasoning above is wrong and the docs should say so
  • PK + KEK + db from a firmware menu — does any firmware refuse a partial set even in Setup/Custom Mode?
  • PowerShell Set-SecureBootUEFI — nobody here has tried it, and it is the route a Windows-shop admin will reach for first
  • Anything that triggered BitLocker recovery. Changing Secure Boot variables is measured into PCR 7, so it can; we would like to know how often it does in practice

Why it matters

If the OS-side row is right, then FOG's own enrolment task genuinely needs all three variables and the .auth files are not redundant — which is worth stating clearly, because the db-alone finding makes them look redundant at a glance. If it is wrong, FOG's task could be simplified to a single variable and the enrolment story gets substantially shorter.

Either way the docs currently lean on one measurement, and should not.

Related

  • FOGProject/fog-docs#129 — where this is documented; the table above is the corrected version
  • #1265 — the local ESP boot archive that made db enrolment worth documenting
  • #1266 — two reporting bugs in the enrolment path, which made db enrolment look unavailable on a server that was configured for it

🤖 Generated with Claude Code

https://claude.ai/code/session_017KitrjXwpVEsH4PnKDi83L

Activity

  1. added
    needs-infoUnder-specified; needs more detail from the reporter before action
    on Aug 21, 2026
  2. mastacontrola commented on Aug 28, 2026

    @mastacontrola
    Member

    Ran the untested cells against EDK2/OVMF. Three of the table's entries need
    changing, and one of them changes the advice rather than just the wording.
    Docs PR: FOGProject/fog-docs#148.

    Rig

    QEMU 10.2.2, q35,smm=on, edk2-ovmf 20260508, Linux guest writing through
    efivarfs. SMM is not optional here — it is what protects the variable store
    from the guest, so without it every "the write succeeded" would be meaningless.

    Two starting states, both stock Fedora firmware images:

    • OVMF_VARS_4M.qcow2 — no PK → Setup Mode
    • OVMF_VARS_4M.secboot.qcow2 — Microsoft's PK/KEK/db → User Mode, and a PK
      whose private key I do not hold. That is the real-hardware situation, not a
      simulation of it.

    Every battery produces successes and denials in the same boot, so a denial is
    firmware policy rather than a broken rig. That mattered — see the traps below.

    1. "The write is unauthenticated" is wrong

    Setup Mode skips the signature check. It does not accept a bare certificate.
    Writing the raw .esl/.der bytes to db, KEK or PK is EINVAL even in
    Setup Mode
    ; the authenticated-variable wrapper is always required.

    That is the real reason a firmware file picker takes MOK.der while FOG ships
    .auth files: the picker builds the wrapper for you and FOG's task cannot.

    2. db alone works — and presupposes someone else supplies the PK

    FOG's own db.auth, written by itself with no PK and no KEK: accepted, lands
    as 8494 bytes, survives a reboot. Top row confirmed on a second platform.

    But the platform then stays in Setup Mode with SecureBoot=0. Written
    alongside an unrelated PK and no KEK at all, the next boot comes up
    SecureBoot=1 with FOG's certificate in db — which is exactly the VMware
    dbDefault.file0 shape. So "db alone" is really "db alone, because the firmware
    or hypervisor is providing the PK".

    3. The OS-side row: right conclusion, wrong mechanism

    Platform state db by enrolled KEK db by unenrolled key KEK by enrolled PK KEK by KEK db unauthenticated
    User Mode, Microsoft's PK EACCES EACCES EACCES EACCES EINVAL
    User Mode, our own PK/KEK accepted EACCES accepted EACCES EINVAL

    On a machine holding a vendor PK, db, KEK and PK are all three refused.
    So the answer to "does the OS route need one variable or three" is neither — the
    route is closed, and writing all three is not a workaround for it. Nothing
    moved: sizes were identical before and after.

    FOG's task works because it runs with the platform in Setup/Custom Mode,
    which is the same precondition as the firmware-menu row — not because it writes
    three variables instead of one.

    Where the .auth files genuinely earn their place is the second row of that
    table: once FOG's own PK and KEK are enrolled, a later db update is accepted
    on a KEK-signed update alone. So they are not redundant, but the reason stated in
    the issue ("a db write must be KEK-signed, and the machine only trusts FOG's KEK
    if FOG's PK is enrolled too") describes a situation you can only reach by having
    owned the platform in Setup Mode first.

    Also confirmed: FOG's published PK.auth/KEK.auth/db.auth are well formed —
    written in Setup Mode all three land and the next boot is SetupMode=0 SecureBoot=1.

    Three traps that fake a firmware denial

    Worth stating, because anyone reporting into this issue with efi-updatevar can
    hit all three and report a confident wrong answer. I did, twice, before the
    positive control caught it.

    1. efivarfs marks db/KEK/PK immutable. An in-place write returns EPERM
      from the kernel, which is indistinguishable from a firmware refusal in the
      tool's message. chattr -i first — and it is re-applied after every successful
      write, so it must be cleared before each one.
    2. efi-updatevar has its own writability precheck. "Cannot write to db,
      wrong filesystem permissions" is the tool declining to call write(); the
      firmware was never asked. I ended up writing efivarfs directly so the errno
      came from the firmware.
    3. No /bin/sh (minimal initramfs): efi-updatevar popen()s mount -l, so
      every write fails with "Failed to get output of mount -l" — which again reads
      as a denial.

    Still open

    I cannot settle these here: physical firmware menus, PowerShell
    Set-SecureBootUEFI
    , and BitLocker/PCR 7 in practice. Those three are still
    worth community reports and the docs callouts still ask for them.

  3. added
    needs-infoUnder-specified; needs more detail from the reporter before action
    and removed
    needs-infoUnder-specified; needs more detail from the reporter before action
    on Aug 28, 2026
  4. mastacontrola commented on Sep 8, 2026

    @mastacontrola
    Member

    The PowerShell Set-SecureBootUEFI cell, measured

    One of the untested cells was "PowerShell Set-SecureBootUEFI — nobody here has tried it, and it is the route a Windows-shop admin will reach for first." Measured now, and it lands the same place the efi-updatevar row did.

    Rig

    A Windows 11 VM (VirtualBox, SMM-protected varstore) whose platform key is Oracle's own VirtualBox PK — a vendor PK whose private key I do not hold, with the machine in User Mode. That is deliberately the real-hardware situation, the same shape as the Microsoft-PK row, not a Setup-Mode shortcut.

    FOG publishes db as an assembled .auth. Set-SecureBootUEFI will not take that — it composes the authenticated descriptor itself from -Time, -ContentFilePath (the ESL) and -SignedFilePath (a detached PKCS#7). So FOG's file was carved into those pieces; the signature fed to the cmdlet is FOG's own, unmodified, verified to be CN=FOG Project Secure Boot Signing before use. Five attempts, covering every shape a real admin would try: the carved ESL + FOG's bare SignedData (the UEFI form), the ContentInfo-wrapped variant, the ESL alone, FOG's whole .auth handed over, and Format-SecureBootUEFI from MOK.der (the documented Microsoft flow).

    Result: the OS route is closed, and PowerShell is no exception

    Every attempt was refused. The proof is host-side, not the cmdlet's word for it: reading the varstore directly after the run, db holds exactly the five Microsoft CAs the machine shipped with, and CN=FOG Project Secure Boot Signing is absent — the one entry FOG's db.auth would have added. Nothing moved.

    So the PowerShell answer to "one variable or three" is the same neither the table already reaches for the OS row: on a machine holding a vendor PK you do not control, a db write is refused, and a friendlier command does not change that. FOG's own task succeeds only because it runs with the platform in Setup/Custom Mode — the same precondition as the firmware-menu row, not a property of writing three variables.

    Still open

    Two cells I could not settle here and am not claiming: physical firmware menus, and BitLocker / PCR 7 in practice — this VM has no vTPM, so the measured-boot question is genuinely untouched. Both still want community reports.

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

    needs-infoUnder-specified; needs more detail from the reporter before action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions