Join our Newsletter — 33% off our NHI Course
Home› Guides› Linux Secure Boot and Shim Guide: MOK, Kernel…
Guide Endpoint Security

Linux Secure Boot and Shim Guide: MOK, Kernel Lockdown and Signed Modules

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 8 November 2026 12 min read
On this page

Linux Secure Boot adds a layer of trust that Windows does not have, the shim and its Machine Owner Key list, and that layer is where most Linux Secure Boot outages and most weak configurations come from. On a typical x86 server or laptop, firmware trusts a Microsoft-signed shim, shim trusts the distribution's key and any keys the machine owner has enrolled, and the kernel then decides which modules may load and whether root may modify the running kernel. Revocations through dbx and SBAT can make old boot media unbootable overnight, and a carelessly enrolled MOK can let anyone with that key sign code the machine will trust. This guide explains the Linux chain from shim to signed modules, who holds the keys, how to run MOK enrolment, kernel lockdown and module signing safely, and how to prepare for revocation events. It complements the platform-level Firmware and Boot Security Guide and is written for Linux platform engineers, endpoint teams and security architects.

Key takeaways

  • The MOK list is a trust store you own. Any key in it can sign boot components and kernel modules that the machine will accept, so treat MOK private keys like code-signing keys.
  • SBAT replaced hash-by-hash revocation. shim's generation-number scheme lets one SbatLevel update revoke every vulnerable GRUB or shim build, which is efficient and also why outdated media suddenly stops booting.
  • Enforce module signatures. module.sig_enforce=1 or CONFIG_MODULE_SIG_FORCE blocks unsigned modules; in permissive mode they load and only taint the kernel.
  • Lockdown makes root less than the kernel. Kernel lockdown blocks /dev/mem, unsigned kexec, BPF and kprobes restrictions, unencrypted hibernation and other paths from user space into the running kernel.
  • Disabling validation is a key event. mokutil --disable-validation turns shim into insecure mode after a password prompt at the console; detect and prevent it on managed fleets.

How identity and access work in the Linux Secure Boot chain

Secure Boot is an identity system for code: each stage checks the signer of the next. On Linux the chain usually runs firmware, shim, GRUB, kernel, then kernel modules.

StageVerified byTrusted keysRevocation
shim (shimx64.efi)UEFI firmwareUEFI db, typically the Microsoft UEFI CA (third-party) certificatesdbx hashes and certificates
GRUB and other second stagesshimDistribution key built into shim, MOK list, and db unless disableddbx, MokListX, SBAT generation numbers
Kernelshim protocol used by GRUBSame as aboveSame as above
Kernel modulesThe running kernel.builtin_trusted_keys (built in), .platform (db and MOK keys when Secure Boot is on).blacklist keyring populated from dbx
kexec imagesThe running kernel under lockdownKernel keyrings or IMA appraisalAs for modules

The MOK variables

shim and MokManager keep their state in UEFI variables, documented in the shim source as MokVars.txt:

  • MokList: Authorised keys and hashes, boot-services only, with a runtime copy MokListRT exposed to the kernel.
  • MokListX: Forbidden keys and hashes, with runtime copy MokListXRT.
  • MokSBState: If set to 1, shim switches to insecure mode and stops validating. MokSBStateRT lets the OS see that state.
  • MokDBState: If set, shim does not use db for validation, so only shim's built-in key and MOK are trusted.
  • Request variables: MokNew, MokAuth, MokSB and MokPW are set by mokutil from the running OS and only act after a reboot, when MokManager asks the person at the console to confirm with the request password.

That reboot-and-confirm step is the security property: root on a running system can request a change but should not be able to complete it without physical or out-of-band console presence.

Admin roles and privileged access

RoleHoldsRisk if misusedControl
Firmware administratorUEFI setup password, PK and KEK controlCan disable Secure Boot or replace keysUnique firmware passwords per device in a vault; BMC access restricted
MOK enrollerConsole access during MokManager promptsCan enrol a key that signs arbitrary boot codeEnrolment only for approved keys, by named staff, logged
Signing key custodianMOK or module signing private keysCan sign malicious modules trusted fleet-wideHSM or PKCS#11 token, separate from build hosts
Linux rootRunning systemCan request MOK changes, load signed modules, change boot entriesLockdown, signature enforcement, monitoring of mokutil use
  • Remote consoles count as physical presence: On servers, the MokManager prompt appears on the BMC console. Anyone with BMC access can confirm a request, so BMC credentials belong in your privileged access process. See the Privileged Access Management Guide.
  • Request passwords: mokutil --import asks for a one-time password that MokManager later checks. Do not reuse a standard password across the fleet; an attacker with root who knows it can stage and then socially engineer the confirmation.

Integrations, API tokens and service accounts

The non-human identities in this chain are signing keys and the build systems that use them.

  • DKMS and third-party drivers: Out-of-tree modules (GPU, storage, security agents) must be signed by a key the kernel trusts. Distributions commonly generate a local MOK for DKMS and prompt to enrol it. Every machine with its own locally generated, unprotected key is a machine where root can sign a rootkit module. For fleets, sign modules centrally with one managed key per product line instead.
  • Custom kernels: The kernel build autogenerates certs/signing_key.pem if no key is configured. The kernel documentation advises supplying your own x509.genkey and moving or destroying the private key rather than leaving it in the source tree. CONFIG_MODULE_SIG_KEY can point to a PKCS#11 URI so the key stays in a token.
  • Signing tools: RHEL documents efikeygen and pesign for kernel images and scripts/sign-file for modules; sign-file does not warn about certificate validity dates, so a module signed outside the key's validity period fails.
  • CI pipelines: A pipeline that signs modules is a code-signing service. Restrict who can trigger it, log every signature, and never expose the key to build steps that run untrusted code. See the Code Signing Security Guide.

Inventory each signing key with its owner, storage, scope and expiry, as you would any machine credential. See the Machine Identity, PKI and Certificate Lifecycle Guide.

SBAT and revocation events

Revoking boot code by image hash does not scale. The shim project's SBAT document records that the BootHole response in 2020 added 3 certificates and 150 image hashes to the x64 dbx, consuming about 10 kB of the roughly 32 kB typically available. SBAT (Secure Boot Advanced Targeting) instead embeds a .sbat section in each shim, GRUB and other component, listing a component name and generation number, and shim compares it against the SbatLevel UEFI variable.

  • How a revocation works: When a vulnerability is fixed, the global generation for that component (for example grub) is raised, and the new SbatLevel payload rejects every binary with a lower number. Vendors also carry product-specific entries such as grub.vendorc for their own mistakes.
  • Published payloads: The shim repository's SbatLevel_Variable.txt is the single source of these revocations, for example the 2022 revocations raising grub to 2 and later 3 and shim to 2 for named CVEs. Shim manages the variable on systems that run it; other operating systems booting under the UEFI CA can set it too.
  • End-of-life products: The SBAT document recommends raising a product's generation past any shipped binary when it reaches end of support, which deliberately stops it booting under Secure Boot.

Preparing for revocation outages

  1. Keep shim, GRUB and kernels current on every host, including rarely booted recovery partitions and appliances.
  2. Refresh boot media: PXE, ISO and rescue images must carry current signed shims, or they fail on machines that have applied newer revocations.
  3. Watch dual-boot and shared firmware: A revocation applied by one operating system lands in firmware variables shared by every OS on that machine.
  4. Stage dbx updates: Apply firmware revocation updates to a pilot ring that includes each hardware model and boot path before the fleet.
  5. Recovery path: Document how to boot recovery media and update shim on a machine that will not boot, and keep that media current.

For the Windows-side certificate rotation that followed BlackLotus, see the Firmware and Boot Security Guide.

Choosing a trust model

  • Distribution default (shim plus vendor key): The right choice for most organisations. Revocations and signed updates arrive through normal packages; your work is keeping them current and keeping MOK empty or minimal.
  • Distribution default plus one organisational MOK: Suits estates with in-house or third-party kernel modules. One centrally held key, enrolled through a controlled process, replaces dozens of per-machine DKMS keys.
  • Own platform keys (custom PK, KEK and db): Removes reliance on the Microsoft third-party CA and lets you trust only your own signed boot chain, but you then own every signing, revocation and recovery step, including option ROMs on add-in cards. Reserve it for appliances or high-assurance fleets with mature PKI.
  • Using MokDBState to ignore db: Narrows trust to shim's built-in key and MOK on machines that never boot Windows or other third-party loaders, at the cost of breaking anything signed only through db.

Logging and detection

  • State checks: mokutil --sb-state reports whether Secure Boot is enabled; mokutil --list-enrolled lists MOK keys; keyctl list %:.platform shows keys the kernel accepted from db and MOK. Collect these regularly and compare against an approved list.
  • Lockdown events: Blocked actions log Lockdown: X: Y is restricted, see man kernel_lockdown.7. Unexpected entries from non-administrative processes deserve investigation.
  • Tainted kernels: In permissive mode an unsigned module loads and the kernel is tainted, with the module flagged E. Alert on taint from unsigned modules.
  • Command monitoring: Audit execution of mokutil (especially --import, --delete and --disable-validation), efibootmgr, kexec and writes to /boot/efi.
  • Measured boot: Where TPM-based attestation is available, compare PCR measurements against known-good values to catch changed boot components. See the Linux Logging and auditd for Defenders Guide.
MetricTarget
Hosts with Secure Boot enabled100% of capable hardware
Hosts with unapproved MOK keysZero
Hosts enforcing module signatures100% of servers
Hosts with lockdown in integrity mode or stricterRising to 100% where drivers allow
Boot media and images with current shim100% before each revocation is applied
Kernels tainted by unsigned modulesZero

Hardening baseline

Kernel lockdown

Kernel lockdown (Linux 5.4 and later, CONFIG_SECURITY_LOCKDOWN_LSM) blocks access to the running kernel image from user space. It restricts /dev/mem, /dev/kmem, /dev/kcore and /dev/ioports, BPF and kprobes, MSR writes and ioperm/iopl on x86, ACPI table overrides, debugfs, unencrypted hibernation, and loading of unsigned modules or kexec images unless IMA appraisal vouches for them. The lsm= boot parameter must include lockdown where it is set. The lockdown=integrity and lockdown=confidentiality boot options select the level; confidentiality additionally blocks reading kernel memory, which can break some tracing and diagnostic tools. Many distributions enable lockdown automatically when booted with Secure Boot, so check /sys/kernel/security/lockdown rather than assuming.

Rollout

  1. Inventory: Record Secure Boot state, enrolled MOK keys, out-of-tree modules and lockdown mode on every host.
  2. Clean up MOK: Remove unknown or per-machine DKMS keys after moving those modules to a centrally managed signing key.
  3. Enable Secure Boot on hardware where it is off, starting with a pilot ring per hardware model, with recovery media tested first.
  4. Enforce module signatures with module.sig_enforce=1 after confirming every required module is signed.
  5. Enable lockdown in integrity mode; evaluate confidentiality for high-value hosts where tooling allows.
  6. Protect firmware: Set firmware passwords, restrict BMC console access, and keep MokSBState at secure mode.
  7. Roll back safely: Kernel parameters can be reverted from the boot menu with console access; keep that path documented, and never "roll back" by disabling validation fleet-wide.

Framework mapping

ControlReference
Verified boot chain, SBAT, dbxNIST SP 800-53 SI-7(9) Verify Boot Process; SI-7(15) Code Authentication
Module signature enforcement, lockdownNIST SP 800-53 SI-7; CM-7 Least Functionality
Signing key custodyNIST SP 800-53 AC-6; CSF 2.0 PR.PS-01
Attacks addressedATT&CK T1542.003 Bootkit, T1547.006 Kernel Modules and Extensions, T1014 Rootkit

See the Rootkits and Bootkits Guide.

Common misconfigurations

  • Secure Boot switched off to fix a driver: The most common outcome of a DKMS prompt nobody understood, leaving the whole chain unverified.
  • Validation disabled in shim: MokSBState set to insecure mode, which keeps the firmware reporting Secure Boot enabled while shim validates nothing. Check mokutil --sb-state, not just firmware settings.
  • Per-machine signing keys left on disk: Locally generated MOK private keys readable by root, so any root compromise can sign a persistent kernel module.
  • Permissive module signing: CONFIG_MODULE_SIG without enforcement, so unsigned modules load with only a taint flag.
  • Stale boot media: Old ISOs and PXE images that fail after an SBAT or dbx update, turning a security fix into an outage and pressure to disable Secure Boot.
  • Lockdown assumed: Teams assume lockdown is active because Secure Boot is on, without checking the running mode.

Practitioner checklist

  • Report Secure Boot state, MOK keys and lockdown mode from every Linux host.
  • Maintain an approved MOK key list and remove anything not on it.
  • Move module signing to a central key in an HSM or PKCS#11 token.
  • Enforce module signatures with module.sig_enforce=1 on servers.
  • Enable lockdown in integrity mode and confirm it in /sys/kernel/security/lockdown.
  • Keep shim, GRUB, kernels and all boot media current ahead of SBAT and dbx updates.
  • Pilot firmware revocation updates per hardware model with tested recovery media.
  • Restrict firmware passwords and BMC consoles that can confirm MokManager prompts.
  • Alert on mokutil changes, kernel taint and lockdown violations.

Standards and references

Related NHI Mgmt Group resources: Firmware and Boot Security Guide · Rootkits and Bootkits Guide · Firmware and Bootkit Compromise Playbook · Linux Kernel Hardening and sysctl Guide · Linux Package Signing and Repository Trust Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 8 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.