Skip to content
enk-odePublic

About

Tamper detection for the FreeBSD boot path. A loader patch series measures firmware, EFI variables, loaded images, TPM and disk at every boot, writes a tamper-evident record and warns before unlocking GELI; elebake builds, signs and deploys it. For the laptop you carry: see evil-maid changes with your own keys, no vendor cloud.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

elvboot — elevated boot

elvboot notices when somebody has been at your machine's boot path.

It is a FreeBSD verified-boot and tamper-detection project for a computer you own and carry around: a laptop whose firmware, boot medium or disk could be touched while you are not looking. The loader you boot is built, signed and deployed by you; at every boot it measures the platform it finds itself on — firmware tables, EFI variables, the images the firmware loaded, TPM counters and PCRs, the boot medium, the disk — compares them with what you declared, writes a tamper-evident record it can only write if it really ran, and tells you before it hands the disk key to the kernel. Nothing is enforced behind your back: the goal is to see manipulation, reliably, every boot, with evidence that survives a reboot (the signed report).

Why would you want that? Because full-disk encryption protects data at rest, but not the code that asks for the passphrase. A modified loader, a swapped boot stick, a firmware setting changed in the night — those are the evil-maid moves, and they are invisible to a stock boot. elvboot makes them visible, with your own keys, on your own hardware, without a vendor cloud. The longer answer, with the public cases, is the planted file.

The family, by name:

  • elebake — the tool this repository ships: the compiler of the boot trust chain. It turns your decisions into a loader, a signed boot medium and the records that judge each boot. How it is built: ARCHITECTURE; why this way: why it is compiled in.
  • platform trust gates — the loader-side engine, a FreeBSD patch series (see below): measurements, claims, gates, policies and the record chain, running inside the EFI loader before GELI and the kernel. The loader at run time, with its code: how the disk opens.
  • earlboot / elvbootd — the runtime witnesses generated by elebake: rc.d scripts that re-check after boot (PCR agreement, expected image set) and record what the loader published. See the tutorial, 18 and 26.

What elebake gives you

  • A boot-media pipeline, gates or not. A stage is a described boot tree: a checkout of the sources, a curated file list, the kernel you name (stage build kernel, any KERNCONF of the tree), signed with your UEFI db key, attested with your OpenPGP key, pushed onto a removable card that proves its letter before it is written. A stage that binds no policy builds the same way and boots like stock; the builds are reproducible -- the same records, the same sources, the same loader bytes, the same PCR 4. See: tutorial 5, 14, 16, 23; QUICKSTART; workflow rebuild.
  • A boot trust chain you compile. Expectations, claims, gates and policies are named records in a database; stage site mk, stage build, stage sign and stage deploy turn them into a loader with generated C policy tables, veriexec manifests and site baselines, signed with your UEFI db key, on a removable card the machine boots from. See: tutorial 8, 10, 11, 12; workflow policy-change; why it is compiled in.
  • Measurements of the real platform. ACPI tables, EFI variables and the firmware's loaded images as learned sets (what stays the same across your boots, what moves), the TPM PCR bank, TPM reset and clock counters, NVMe power cycles, the boot origin, and the fingerprint of the GELI key the loader derived — each a claim with a verdict, each verdict in the record. See: tutorial 7, 18, 22; workflows witness-learn, pcr-learn, time-anchor.
  • A report over the kept boots. elvbootd keeps the loader's kenv of every boot with the session's verdicts, hash-chained, under /var/db/elvboot/boots; elvboot report <stage> (the second harness of this repository: the same engine and database, its own vocabulary) renders them as Markdown -- the boots, the fallen claims with expectation against measurement, the aggregates, the chain, the witnesses' receipts, the sources with their digests -- to sign with elebake attest. See: tutorial 25; the signed report; the harness elvboot.sh.
  • Three factors for the encrypted root, judged by the TPM. The loader compares no password. Its one dialog hands the passphrase to the TPM, whose sealed objects carry it as their auth value under a PCR policy; the released bytes are the second GELI key file next to the one on the card, and the disk opens or it does not. A second object with the same bytes and the duress passphrase raises an increment-only counter in the TPM and marks the boot for earlboot -- nothing on the console differs, nothing on the medium holds a hash to tell the two apart. The second object carries the key of a decoy root; opening it kills the owner's seal by an increment-only counter the TPM keeps, and the way back is the recovery slot on paper. stage tpm provisions all of it from the stage's leafs; every session is salted and encrypted. See: tutorial 21, 24; how the disk opens, the decoy root, the question; workflows tpm-seal, tpm-rotate, duress-reseal.
  • A record chain the loader must write. An EFI variable, keyed HMAC, counter and anchors: a boot that did not run your loader leaves no valid record, and you see the gap. See: tutorial 17, 22; the planted file.
  • Dump and restore. dump writes the whole database as an executable script of its own commands; restore replays it. Adds are idempotent, so a replay is safe and a dump kept in git is a reproducible configuration. See: ARCHITECTURE, dump & restore; an example, docs/example-dump.sh; workflow restore.
  • Export and import. A signed, sealed pair — the dump and a bundle of the artifacts it names — attested with one OpenPGP key (a Nitrokey works), pinned on the receiving side, with serials against downgrade and provenance receipts. A second machine, a rescue medium or a fresh install can take over the exact state; this repository's own restore probe found its first real bug this way. See: tutorial 20; QUICKSTART; the rescue boot.
  • Reproducible artifacts. The database is the single source of truth: every generated file (policy tables, manifests, loader.conf, earlboot scripts) is regenerated from records, builds run in isolated checkouts of a pinned source branch, signatures are deterministic. A restored database rebuilds the same chain. See: ARCHITECTURE, the database; tutorial 6, 16.
  • Backups and rollback with evidence. Deployed loaders are backup records with label and description; stage rollback saves the suspect loader first, then puts the known-good one back. See: QUICKSTART; tutorial 16.
  • Emit and inspect. Every command generates shell. Pipeline commands print it for review (append | sh to act); bookkeeping is pinned to act directly. You can read what the tool is about to do, and the test suites analyse that output instead of touching the system. See: tutorial 4; ARCHITECTURE, function classes, generation time vs. runtime and interpreters.
  • Help that cannot erode. elebake help and the manual page are generated from the same help blocks the architecture tests check. See: the manual page; its source docs/elebake.8; features against documentation.
  • One process when it counts. elebake-binary.sh <db> <command...> runs a command, or a whole dump (batch <file>), inside one process: the anchors are functions, the emitted lines are calls. The import of a full database went from 22 minutes to 20 seconds on an old desktop. make install RUNNER=binary makes it the elebake you type. elebake-compile.sh is the same file by its other name and writes the script instead of running it -- what a run would do, for reading (the file's header says when that is the right tool and when it is not). elebake-walkthrough.sh <db> <command...> is the third name: the whole tree of a command as text, checks answered against the database as it is, every act shown under its anchor, nothing run -- in seconds. See: elebake-binary.sh, elebake-compile.sh, elebake-walkthrough.sh; the import that prompted it, tutorial 20.

The FreeBSD sources -- read this first

elebake is nothing without the loader it compiles for. The measurement/claim/gate/policy engine that reads the compiled decisions at boot is a FreeBSD patch series, platform trust gates, and the catalogs elebake offers are parsed from the headers of that series. Against a stock FreeBSD tree the catalogs are empty and nothing measures anything.

git clone -b elvboot-15.1 \
    https://github.com/johannes-bruegmann/freebsd-src.git ~/git/freebsd-src
./elebake.sh setenv ELEBAKE_FREEBSD_SRC ~/git/freebsd-src

Branch elvboot-15.1 is based on releng/15.1; the loader-side engine lives under stand/efi/loader/local/ and its README points back here. Parts of the series are on their way upstream. The tutorial connects the tree in 6 and reads its catalogs in 7; QUICKSTART has the short form.

Ideas that carry the tool

  • Detection, not enforcement. The design assumes the boot medium can be tampered with and concentrates on noticing — measurements are published, findings survive reboots, the owner decides what happens on a shortfall (the question, the planted file).
  • Catalogs come from the World, records hold decisions. What the loader can measure is parsed live from the checked-out sources; what you want lives in the database as named, reusable records (expectations, claims, gates, triggers, policies) — validated sharply where arsenal meets catalog (tutorial 7, 10).
  • Replays are an architecture principle. dump exports the whole database as an executable script; adds are idempotent-immutable, so restores and re-runs are safe (ARCHITECTURE).
  • No implicit defaults. The kernel that guards a machine, the license header of a generated file, the curation of a boot tree, the directory a command writes to — all explicit decisions, all fail-early when missing (tutorial 13).
  • One anchor, one thing. Commands expand their arguments to the right until every detail is known (stage keys → stage keys phase → stage keys policy → stage keys claim); the architecture suite refuses nested loops, dispatch inside an anchor and oversized bodies (ARCHITECTURE, testing).

Status

Working today, on real hardware: database and environment model, key registries (pem/openpgp/pkcs11, Nitrokey signing), stages (checkout, isolated stand/ and kernel builds, curation filter, include, manifest, verify, attest, sign, deploy to a removable card, markers, backups, rollback, a card that proves its letter before every write), the foundation compiler (measurement catalogs, arsenal, per-phase policy binding, foundation.c rendered by every build), compile-time baselines and run-time kenv records, inventory sets learned from boots (ACPI, EFI variables, loaded images), the record chain, the time anchor, the TPM factor with its decoy root and the two counters, earlboot and elvbootd rc.d witnesses, dump/restore, the signed export/import pair with the minimized rescue variant, and three test suites (architecture, unit, integration) that run in parallel.

The walk that built all this is recorded in docs/TUTORIAL.md; its current state (19) is the silent boot: every gate green, no claim skipped, the database published as an attested, encrypted dump.

Beside it: the rescue system on the medium (stage rescue: a dataset on the production pool, described in records, sent to every card, booted and witnessed) and the quarantine (stage quarantine: the decoy root of the duress way, built the same way into a container the TPM's file alone opens, with its guard, its signed baseline and its witness). The rescue: the rescue boot, workflows rescue-build and rescue-refresh. The quarantine: the decoy root, tutorial 27, workflow quarantine. What is documented and what is not: features against documentation. Open: the review of the loader series, time windows after a series of settled boots.

Getting started

Requirements: FreeBSD (base system tools; uefisign, gpg and a PKCS#11 stack where the respective backends are used), the patched source tree above, a machine with UEFI Secure Boot you control the keys of, and ideally a TPM.

License

BSD-2-Clause — see LICENSE. Contributions welcome, see CONTRIBUTING.md.

About

Tamper detection for the FreeBSD boot path. A loader patch series measures firmware, EFI variables, loaded images, TPM and disk at every boot, writes a tamper-evident record and warns before unlocking GELI; elebake builds, signs and deploys it. For the laptop you carry: see evil-maid changes with your own keys, no vendor cloud.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages