Repository navigation
secure-boot: bind the booted FIT config to the signed one; fail-closed fixes - #146
Open
3rdIteration wants to merge 1 commit into
Open
3rdIteration wants to merge 1 commit into
3rdIteration wants to merge 1 commit into
Conversation
…d fixes Findings from a review of the Luckfox secure boot chain, including the U-Boot source at the pinned SDK commit. * U-Boot (SPL + proper): the SDK's fit_config_check_sig() predates the upstream fix for CVE-2020-10648 / CVE-2021-27097 / CVE-2021-27138. It verified the signature over whatever the unsigned `hashed-nodes` list named and never checked that the configuration being booted was on it. New patch-fit-config-binding.sh adds upstream's rules before the RSA check on signed builds (config in hashed-nodes, no '@' node names, no unsigned image/config), wired into os-build.sh and build-local.sh and asserted by assert-uboot-fit-signature.sh. NOT yet compiled or booted. * initramfs /init: a missing fuse.programmed flag fell back to an nvmem OTP byte that is the chip ID on every board (bench row E4), so it skipped rootfs verification. Now only an explicit fuse.programmed=0 skips; no flag is "unknown" and verifies. The OTP byte can only force verification on. * initramfs /init: the UBIFS path hashed /dev/ubi0_0 but mounted ubi0:rootfs by name. Mount ubi0_0, the volume that was hashed. * provision_fit_build_keys: a key triple left in a kept SDK tree was reused before SEEDSIGNER_FIT_KEY_DIR was consulted, so a build with a real key could silently sign with the public dev key. A supplied key now always wins; a leftover non-dev key is called out. * assert-uboot-fit-signature.sh: fail the build, not warn, when the built U-Boot .config or sources cannot be found (override: SEEDSIGNER_ALLOW_UNVERIFIED_UBOOT=1). * fitsign.py verify / luckfox_release.py check: also compare every payload against its signed sha256 hash node and apply the same binding rules; previously an altered kernel or ramdisk still read VALID. Tests: 7 new cases in tests/test_fitsign.py and a new tests/test_initramfs_fuse_verdict.sh that runs the real /init decision block against each command-line / OTP case. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes from a review of the Luckfox Pico secure boot chain, including the U-Boot source at the pinned
SDK_COMMIT.What changed
1. U-Boot does not bind the booted configuration to the signed one (SPL and U-Boot proper).
The SDK's
fit_config_check_sig()is a 2017.09 fork that predates the upstream fix for CVE-2020-10648 (and CVE-2021-27097 / CVE-2021-27138). It verifies the signature over whatever thehashed-nodesproperty lists and never checks that the configuration it was asked to verify is on that list.hashed-nodesand/configurationsdefaultboth sit outside the signed region, and nodes that are neither listed nor the child of a listed node are left out of the hash.New
opt/luckfox/patch-fit-config-binding.shadds upstream's rules before the RSA check, on signed builds only:hashed-nodes;@;/imagesand/configurationsmust be inhashed-nodes.It is wired into
os-build.shandbuild-local.shnext topatch-mtd-part-parse.sh, added toassert_shared_build_files(), andassert-uboot-fit-signature.shfails the build if the built source lacks it. Every image in existing build output (mini/max/pi,uboot.imgandboot.img) already satisfies all three rules.2.
/initskipped rootfs verification when the fuse flag was absent.With no
fuse.programmed=1on the command line it fell back to nvmem OTP byte 0x80, which bench row E4 showed is the chip ID on fused and unfused boards alike. So a missing flag read as "unfused" and skipped the check, the opposite of the rule in secure-boot.md §5.2. Now only an explicitfuse.programmed=0skips. No flag is "unknown": it verifies and shows an orangePASSED / rootfs valid / fuse state / unknownscreen. The OTP byte can only force verification on.3.
/initverified one UBI volume and mounted another (NAND dev variant).It hashed
/dev/ubi0_0but mountedubi0:rootfsby name. It now mountsubi0_0.4. A leftover key beat
SEEDSIGNER_FIT_KEY_DIR.provision_fit_build_keysreused any key triple already in the kept SDK tree before looking at the supplied key, so a build given a real key could silently sign with the public dev key. A supplied key now always wins, and a leftover key that is not the committed dev key is called out.5.
assert-uboot-fit-signature.shfailed open.If the built U-Boot
.configor sources could not be found it warned and passed. It now fails the build. Override:SEEDSIGNER_ALLOW_UNVERIFIED_UBOOT=1.6.
fitsign.py verifyandluckfox_release.py checknever compared payload bytes.They checked the RSA signature over the hash nodes only, so an altered kernel or ramdisk still read
VALID. Both now compare every payload with its signed sha256 and apply the same binding rules as item 1.Docs:
docs/luckfox/secure-boot.md(§4.2, §5.2, §6.5, corrections log) andAGENTS.md.Testing
tests/test_fitsign.py, classBinding).tests/test_initramfs_fuse_verdict.shruns the real/initdecision block against 12 command-line / OTP cases.uboot.img/boot.imgfor mini, max and pi from local build output..config.Reviewer notes
fdt_get_path/fdt_parent_offsetinto the SPL./initchanges are syntax-checked and logic-tested, not booted. On a board whose bootloader passes nofuse.programmedflag at all, boot now takes a full verification pass where it used to skip.🤖 Generated with Claude Code