Skip to main content

bitlocker-dbx-rollback: unlock BitLocker again after a Secure Boot dbx change, without the recovery key

CI Release 1.0.0 PyPI bitlocker-dbx-rollback Python 3.14 and 3.15 BitLocker TPM only, PCR 7 and 11 No Microsoft binaries redistributed Claude Code plugin mypy strict MIT licence Stars

Your Windows laptop suddenly says "BitLocker needs your recovery key to unlock your drive because Secure Boot policy has unexpectedly changed", and you do not have the key. If the change was to the Secure Boot revocation list (dbx), this tool can get the TPM to unlock the drive by itself again. It works out exactly which dbx the TPM is waiting for, proves which Microsoft signed updates rebuild it byte for byte, and writes a guarded script that puts it back.

It was built to recover a real laptop, and it did: Windows started again with the TPM alone, and the recovery key was read out and saved.

uv tool install bitlocker-dbx-rollback
dbx-rollback analyze --efivars efivars/ --dislocker-log bitlocker-info.log --out target-dbx.bin
dbx-rollback plan --factory-dbx factory-dbx.bin --target target-dbx.bin --payloads payloads/

Is this your problem?

It fits when all of these hold:

  • The blue BitLocker screen gives the reason Secure Boot policy has unexpectedly changed.
  • The drive's only protectors are TPM and Numerical Password (TPM only BitLocker, the Windows default), sealed to PCRs 7 and 11.
  • Something wrote to the firmware's dbx from outside Windows. The classic case: an Ubuntu USB stick whose secureboot-db.service appends Microsoft's revocation list to every PC it boots. fwupd dbx updates and BIOS updates can do the same.
  • The firmware can load its factory Secure Boot keys, and its PK, KEK and db are still the factory ones.

If you have the 48 digit recovery key, type it in instead. This tool is for when you cannot.

How it works

  1. The sealed state. A TPM only protector seals the volume key to PolicyAuthValue then PolicyPCR(7, 11). The protector stores the PCR digest the TPM will accept. analyze reads it from dislocker-metadata output and checks the policy really is that shape.
  2. PCR 7 from variables. Firmware measures SecureBoot, PK, KEK, db and dbx, a separator, then the db entry that verified each image. analyze replays that for every list boundary of today's dbx and every db entry. Firmware only ever appends to dbx, so the sealed dbx is a prefix of today's. One prefix matches.
  3. Rebuild by signed appends. dbx only accepts additions signed by a KEK. So the firmware's factory keys go back first (dbx becomes the factory list), then Microsoft's own signed updates are appended in the order Windows once applied them. Firmware drops entries it already has and adds the rest as one new list, so the structure comes back exactly. plan simulates that and searches for the order that rebuilds the target byte for byte.
  4. Find the missing updates. fetch downloads every uefi.org release from LVFS and every version in microsoft/secureboot_objects, and collects the files a Windows install kept in SecureBootUpdates and WinSxS. Some updates only ever shipped inside Windows updates; psf pulls their patches out of an express package from the Microsoft Update Catalog, and apply-delta applies them with msdelta.dll from a Windows install you own, under Wine.
  5. A guarded kit. kit refuses to write anything unless the sequence rebuilds the target in simulation. Its rebuild.sh runs on the locked machine from a Linux stick, writes only dbx, checks PK, KEK and db first, checks every step's size and content, stops at the first difference, can be rerun, logs everything, and has a read only verify mode for after a reboot.

Recover a machine

The full walkthrough, with the firmware steps, is in the manual. In short:

# On the locked PC, booted from a Linux stick whose secureboot-db.service is MASKED:
sudo dislocker-metadata -V /dev/nvme0n1p3 > bitlocker-info.log
mkdir efivars && cp /sys/firmware/efi/efivars/{SecureBoot,SetupMode,PK,KEK,db,dbx,dbxDefault}-* efivars/

# Anywhere:
dbx-rollback analyze --efivars efivars/ --dislocker-log bitlocker-info.log --out target-dbx.bin
tail -c +5 efivars/dbxDefault-* > factory-dbx.bin
dbx-rollback fetch --out payloads/ --lvfs --secureboot-objects
dbx-rollback plan --factory-dbx factory-dbx.bin --target target-dbx.bin --payloads payloads/
dbx-rollback kit --efivars efivars/ --factory-dbx factory-dbx.bin --target target-dbx.bin \
  --sequence payloads/A payloads/B ... --out kit/

# On the locked PC: firmware setup, Secure Boot off, clear the Secure Boot keys, load the factory keys,
# Secure Boot on. Then from the stick:
sudo bash kit/rebuild.sh
sudo bash kit/rebuild.sh verify     # after one more reboot

When verify prints VERIFIED, unplug the stick and start Windows. Then save the recovery key: manage-bde -protectors -get C: in an administrator prompt.

Safety

  • Nothing here writes to the encrypted drive or the TPM. The kit writes one firmware variable, dbx.
  • Never use Clear TPM or a firmware option that resets security settings (on HP: Restore Security settings to Factory Defaults). That destroys the TPM protector, and with it this route.
  • Clearing the Secure Boot keys is only safe when the firmware can load its factory keys afterwards. On the HP this was built on, Load HP Factory Default Keys becomes selectable only after Clear All Secure Boot Keys.
  • The recovery key always still works. Nothing in this process can stop it from working.

No Microsoft binaries

This repository ships code only. Signed dbx updates are downloaded by fetch from their public homes (LVFS, microsoft/secureboot_objects, the Microsoft Update Catalog), and msdelta.dll comes from a Windows installation you own. Tests use synthetic data.

With an AI agent

The repository is a Claude Code plugin: claude plugin install it from this repository, and its skill walks an agent through the analysis with the same stop rules. dbx-rollback guide prints the full manual for any agent.

Install

Python 3.14 or later. uv tool install bitlocker-dbx-rollback or pipx install bitlocker-dbx-rollback. fetch --lvfs needs zstd; the Windows update steps need wine and cabextract.

dbx-rollback man --install makes man dbx-rollback work. The source is docs/MANUAL.md.

Develop

make init-dev
make checks

make checks runs isort, black, editorconfig-checker, darglint, flake8, mypy in strict mode, bandit, the man page check and pytest, the same as CI. See CONTRIBUTING.md and AGENTS.md.

Star history

Star history of jpsanders/bitlocker-dbx-rollback

Licence

MIT. Made by James Phillip Sanders.

Metadata

Release files for bitlocker-dbx-rollback 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bitlocker-dbx-rollback 1.0.0
File Size Uploaded Provenance Actions
bitlocker_dbx_rollback-1.0.0.tar.gz 225.7 kB With provenance Details for bitlocker_dbx_rollback-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bitlocker-dbx-rollback 1.0.0
File Interpreter ABI Platform Actions
bitlocker_dbx_rollback-1.0.0-py3-none-any.whl Python 3 none any Details for bitlocker_dbx_rollback-1.0.0-py3-none-any.whl

Total release size: 256.6 kB

Release files / bitlocker_dbx_rollback-1.0.0.tar.gz

Download URL bitlocker_dbx_rollback-1.0.0.tar.gz
Size 225.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1b4c46783e401cfdccce7f38f79fa566a9073b512515455942c7426c86aa108f
BLAKE2b-256 checksum
How to use checksums
7dbdb8eb8ff6f835c791dba7cca07832d404a375c0ce6fc23c33576e3ac0eebf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / bitlocker_dbx_rollback-1.0.0-py3-none-any.whl

Download URL bitlocker_dbx_rollback-1.0.0-py3-none-any.whl
Size 30.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c425507269bae11f4766ae1632c919bda421d1a005f6ac73dd468cb287b4d31
BLAKE2b-256 checksum
How to use checksums
fabb8c717be146fd5873a69d6e5b23aababb63ddf3ab75b9603eb5da5dbb5702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for bitlocker-dbx-rollback 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bitlocker_dbx_rollback-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page