Skip to main content
Systems Engineering

Fixing UEFI Secure Boot Chain-of-Trust Failures

How PK, KEK, db, dbx, shim and MOK layers interact, and the mokutil, sbsign, and sbctl steps that repair a broken UEFI trust chain.

Fixing UEFI Secure Boot Chain-of-Trust Failures
KBY Technologies12 min read

In this guide

Share

A dual-boot workstation that suddenly fails to boot at POST with a message along the lines of “Verification failed: (0x1A) Security Violation” is not necessarily a firmware bug in the conventional sense — it is often the secure boot chain of trust doing what it was designed to do: refusing to execute a bootloader whose signature no longer resolves against an enrolled key. Exact error wording varies by firmware vendor, so do not rely on a single string to identify the cause. Most guides treat this as a BIOS setting to toggle off. That is the wrong instinct for anyone running signed kernels, custom shim binaries, or enterprise-managed key databases. Understanding why the chain breaks — and how to repair it without disabling the security boundary entirely — requires treating UEFI firmware as a small, deterministic public-key infrastructure rather than a black box.

This article walks through the key hierarchy UEFI firmware enforces, why the secure boot chain of trust can collapse after kernel updates, dual-boot installs, or firmware resets, and how to diagnose and rebuild it using standard Linux tooling.

#Problem Statement: Where the Chain Actually Breaks

Secure Boot is not a single validation step. It is a linked sequence of signature checks, each dependent on the integrity of the one before it. A failure at any link — Platform Key, Key Exchange Key, signature database, or the second-stage shim loader — can surface as a similar generic firmware error, which is why triage is so frequently mishandled. Common real-world triggers include:

  • A distribution-signed shimx64.efi being replaced by a self-compiled GRUB binary with no matching Machine Owner Key (MOK) enrolled.
  • Firmware vendors or operating systems pushing a dbx (forbidden signature database) update that revokes a previously trusted binary — revocations of this kind were part of the 2023 BlackLotus bootkit remediation.
  • A motherboard BIOS reset (CMOS clear, firmware flash) returning the Secure Boot variables to OEM defaults, orphaning any manually enrolled Linux keys.
  • Dual-boot installs leaving boot entries pointing at the wrong loader. Check efibootmgr -v to see which entries exist, their order, and which file each one loads, and compare that with the fallback path (/boot/efi/EFI/BOOT/BOOTX64.EFI, i.e. EFIBOOTBOOTX64.EFI on the ESP).

None of these are firmware defects. They are predictable consequences of a key hierarchy operating as specified — the difficulty is that most engineers have never actually inspected it directly.

#Architectural Breakdown of the Secure Boot Chain of Trust

The UEFI specification defines four NVRAM-resident key stores, each with a distinct authority scope. Grasping this hierarchy is the basis for competent troubleshooting.

  • PK (Platform Key) — the key that authenticates updates to the KEK database (and to the PK itself). It is typically owned by the OEM. Without access to the PK private key, you cannot authorise changes to the KEK, short of putting the firmware back into Setup Mode.
  • KEK (Key Exchange Key) — keys that authenticate updates to the db and dbx variables. This is an authorisation relationship between variable writes, not a certificate-signing hierarchy. Microsoft’s KEK is present on almost every consumer board; most Linux distributions rely on it indirectly via the shim’s Microsoft-signed certificate rather than enrolling their own.
  • db (Signature Database) — the allow-list. Any binary whose Authenticode-style signature chains to a certificate in db (or whose hash is listed there) is permitted to execute during boot.
  • dbx (Forbidden Signature Database) — the revocation list, checked before db. A hash or certificate present here blocks execution even if it also matches an entry in db.

Below this firmware-enforced layer sits a second, software-enforced layer that most administrators actually interact with: shim and MOK (Machine Owner Key). Shim is a small, Microsoft-signed EFI binary that itself verifies GRUB or the kernel against the distribution’s built-in key and a separate, user-controllable MOK database (stored in MokList and exposed to the OS at runtime as MokListRT). This two-tier design exists specifically so distributions can rotate their own signing keys without requiring a Microsoft re-signature for every kernel build — but it also means a MOK enrolment failure produces a Secure Boot failure with no firmware-level fault at all.

The full secure boot chain of trust for a typical Linux dual-boot system therefore looks like this: PK/KEK (authorise updates) → db (Microsoft UEFI CA) → shim.efi → distribution key / MOK database → grubx64.efi → vmlinuz signature. A break at any single link halts the entire sequence.

secure boot chain of trust

#
Measured Boot and the TPM Dimension

Secure Boot verifies signatures; it does not attest to boot state. Systems using measured boot extend PCR registers (typically PCR 4, 7, and 8-11) with SHA-256 hashes of each executed component. If you are also using TPM-sealed disk encryption (e.g. LUKS with systemd-cryptenroll or BitLocker), a legitimate change to the shim or kernel — even one that passes Secure Boot signature validation — will still change the PCR values and can lock you out of your encryption key. This is a common cause of “Secure Boot passed, but I can’t unlock my disk” tickets, and it is frequently confused with a chain-of-trust failure proper. Make sure you have your recovery key before changing boot components.

#Implementation Logic: Diagnosing and Rebuilding the Chain

Repairing a broken secure boot chain of trust follows a strict order of operations. Skipping steps — particularly changing MOK before confirming the KEK/db/dbx state — leads to a system that boots once and then fails again after the next kernel update. Pilot any change on a single machine before applying it across a fleet.

#
Step 1 — Inventory the current key state

Before touching anything, dump the existing NVRAM variables and keep the output. On Linux, efi-readvar (from the efitools package) reads directly from firmware.

1sudo efi-readvar -v PK
2sudo efi-readvar -v KEK
3sudo efi-readvar -v db
4sudo efi-readvar -v dbx
5
6# Confirm Secure Boot state and whether firmware is in Setup Mode
7sudo mokutil --sb-state
8sudo bootctl status | grep -iE 'secure boot|setup'
9
10# Hash of the installed shim, to compare with dbx entries
11# (path varies by distribution)
12pesign -h -P -i /boot/efi/EFI/debian/shimx64.efi

Compare the hash printed by pesign (the Authenticode hash) with the SHA-256 entries in the dbx output above. If dbx contains a hash matching your currently installed shim revision, no amount of MOK re-enrolment will fix the boot — the firmware is actively revoking that binary. Revocations of this kind accompanied the BlackLotus remediation; Microsoft’s guidance is in KB5025885, which concerned revoking vulnerable Windows boot managers. Effects on Linux shim binaries came from separate SBAT and dbx changes, so check your distribution’s advisories for the affected shim versions.

If the failure is at the shim-to-GRUB link (the most common dual-boot scenario), first consider what is installed. On a stock distribution install, GRUB is already signed by the distribution key that shim trusts, so the usual fix is to reinstall the signed packages and re-run the installer rather than self-sign. On Debian/Ubuntu, for example, reinstall grub-efi-amd64-signed and shim-signed, then run grub-install; use your distribution’s equivalents elsewhere. Self-signing with your own MOK is only needed for custom-built GRUB or kernels.

For the custom-build case, you need to enrol your MOK certificate. This requires a reboot into shim’s enrolment interface — it cannot be completed purely from userspace, by design, to prevent malware from silently enrolling its own trust anchors.

1# Generate a MOK keypair if one does not already exist
2# (PEM certificate for sbsign, DER copy for mokutil)
3openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv 
4  -out MOK.pem -nodes -days 3650 -subj "/CN=Local Machine Owner Key/"
5openssl x509 -in MOK.pem -outform DER -out MOK.der
6
7# Stage the key for enrolment on next boot
8sudo mokutil --import MOK.der
9# You will be prompted to set a one-time enrolment password
10
11# Back up the current GRUB binary before doing anything else
12sudo cp -a /boot/efi/EFI/debian/grubx64.efi /root/grubx64.efi.bak
13
14# Sign to a NEW file, leaving the original untouched
15sudo sbsign --key MOK.priv --cert MOK.pem 
16  --output /root/grubx64.efi.signed 
17  /boot/efi/EFI/debian/grubx64.efi
18
19# Verify the signature before replacing anything
20sbverify --list /root/grubx64.efi.signed

Only once the signed file verifies, and after the MOK enrolment below has completed, copy it over the original (sudo cp /root/grubx64.efi.signed /boot/efi/EFI/debian/grubx64.efi). To undo, copy /root/grubx64.efi.bak back; if the system will not boot, restore it from live media, and keep a rescue USB handy.

On reboot, shim launches MokManager; you must press a key during the boot countdown, choose Enroll MOK, and enter the enrolment password set above. The certificate is then stored in MokList. This is the point where the secure boot chain of trust is actually re-established at the shim layer for a custom-signed binary — everything prior is just preparation.

Fixing UEFI Secure Boot Chain-of-Trust Failures architecture diagram 2

#
Step 3 — Verify signatures instead of trial-and-error rebooting

Rather than repeatedly rebooting to test, check signatures before committing. For MOK-signed binaries, use sbverify against your own certificate. sbctl verify only checks against keys that sbctl itself manages, so it will report a MOK-signed binary as unsigned and should not be used for this workflow:

1# Inspect signatures on the binary
2sbverify --list /boot/efi/EFI/debian/grubx64.efi
3
4# Verify against your MOK certificate
5sbverify --cert MOK.pem /boot/efi/EFI/debian/grubx64.efi

If you instead manage your own keys with sbctl (not shim and MOK), then sudo sbctl status and sudo sbctl verify are appropriate, and list which EFI binaries are signed with sbctl’s keys.

If you are managing this across a fleet rather than a single workstation, this validation step belongs in your provisioning pipeline, alongside the same kind of pre-flight checks used in broader architectural patterns for infrastructure validation — treating firmware trust state as a testable artefact rather than a one-off manual fix.

#Failure Modes and Edge Cases

Several failure patterns recur often enough to warrant specific attention:

  • Setup Mode after firmware reset or key clearing: if firmware ends up in “Setup Mode” (no PK enrolled), Secure Boot is not enforced, so the system will boot unsigned binaries, giving a false sense of security. Setup Mode is a separate firmware variable (SetupMode) from SecureBoot, so mokutil --sb-state alone does not tell you about it. Check with bootctl status, which shows “setup” for Secure Boot when in Setup Mode, read the SetupMode variable directly, or inspect the PK with efi-readvar -v PK.
  • Kernel update outrunning signature enrolment: automatic kernel upgrades (DKMS-built out-of-tree modules in particular) frequently ship unsigned .ko files. With lockdown mode enforced, the kernel will refuse to load them even though the boot itself succeeds — surfacing as module load errors, not boot failures, which throws off diagnosis.
  • Dual-firmware confusion on OEM boards: some manufacturers ship a “Secure Boot” toggle that may reset keys to factory defaults when cycled. This can look identical to a failed enrolment but is actually firmware discarding state; record the key state (Step 1) before changing firmware settings.
  • TPM PCR mismatch masquerading as Secure Boot failure: as noted earlier, a legitimately signed and Secure-Boot-valid kernel can still fail to unseal a TPM-bound LUKS key after any change to boot components. The chain of trust is intact; the measured boot attestation is not.

#Scaling and Security Trade-offs

Whether to manage Secure Boot manually or centrally depends heavily on fleet size and threat model:

  • Single workstation / student lab: manual MOK enrolment via mokutil is entirely adequate. Overhead is a few minutes per kernel-signing-key rotation, typically only needed once per distribution lifecycle.
  • Managed fleet (50+ endpoints): manual enrolment does not scale — every endpoint requires physical or remote KVM interaction with MokManager at boot, since it cannot be automated over SSH. Organisations at this scale should sign kernels centrally with an HSM-backed key and push signed artefacts, avoiding per-device MOK prompts entirely.
  • Security posture vs convenience: disabling Secure Boot entirely removes the protection it provides against bootkits like BlackLotus and LoJax. Measured boot and TPM sealing operate independently of Secure Boot enforcement, but they do not replace it.
  • Custom PK enrolment (advanced): replacing the OEM PK with a self-generated one gives full control over the secure boot chain of trust but removes the ability to dual-boot Windows without also enrolling Microsoft’s KEK/db certificates manually — a step frequently missed, resulting in a Linux-only machine by accident. Back up the existing PK, KEK, db and dbx first.
  • Revocation latency: dbx updates from OEMs propagate only on firmware update or explicit KEK-authenticated write; a compromised shim revision can remain trusted on unpatched firmware for months after public disclosure, regardless of OS-level patching.

Treat Secure Boot failures as key lifecycle problems rather than firmware quirks, and the fix is almost always a targeted repair or re-enrolment rather than a wholesale reset. Disabling the feature should be the last resort, not the first troubleshooting step, given how much downstream tooling — disk encryption, kernel lockdown, remote attestation — quietly depends on the chain staying intact.

About this page

Credited to

Dates

Published

Last updated

Sources

This page lists no external sources.

Corrections

  • : Corrected during a review of published articles. Details
Reader Interaction

Comments

Add a thoughtful note on Fixing UEFI Secure Boot Chain-of-Trust Failures. Comments are checked for spam and held for moderation before appearing.

Loading comments...

Learn More About KBY

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

Engineering insights, direct to you.

Receive the latest Systems Engineering tutorials, production guides, Engineering Labs and operational best practices.

Fixing UEFI Secure Boot Chain-of-Trust Failures