Close the FIT signature fail-open on the image gate
v2 cover Close the FIT signature fail-open on the image gate
fit_image_verify_required_sigs() returns success when the control devicetree has no /signature node, so a FIT with absent or invalid signatures verifies. The only indication is a compiled-out debug(). Reported on 2026-09-08 [1].
Patch 1 adds CONFIG_FIT_REQUIRE_CONFIG_SIGS handling to the image gate, patch 2 adds test/py coverage for the missing-node case.
The configuration gate has the same early return and is already covered by Ludwig Nussel's series [2], now at v8, which only touches fit_config_verify_required_keys(). This is complementary and reuses Ludwig's Kconfig symbol.
Default n, and the message is conditional on it: enabling enforcement breaks 13 of 32 test_vboot cases that assert the old contract, and Rockchip has no /signature node by design [3]. Tested on sandbox only.
[1] https://lore.kernel.org/u-boot/CA+pz=k+hAU5dqbO4GOLJ0fRMRdyrq=kTSnwUc0OcR3r9PotUgg@mail.gmail.com/
[2] https://lore.kernel.org/u-boot/20260618144742.v7.4.6d1d5d14140677a76a7cd7bb99a9088d8c8f480c@changeid/
[3] https://lore.kernel.org/u-boot/[email protected]/
Changes in v2:
- Shortened the cover letter; details moved into the patches.
Eva Crystal (2):
image-fit-sig: also require signatures on the image gate
test: vboot: add coverage for a control FDT with no /signature node
boot/Kconfig | 27 +++++++++++ boot/image-fit-sig.c | 15 ++++++ test/py/tests/test_vboot.py | 96 +++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+)
Signature · 1 line
2.53.0
PATCH v2 1/2 image-fit-sig: also require signatures on the image gate
fit_image_verify_required_sigs() at boot/image-fit-sig.c:187 looks up the "/signature" node of the U-Boot control devicetree and returns success when it is absent, at boot/image-fit-sig.c:203-207:
/* Work out what we need to verify */
*no_sigsp = 1;
key_node = fdt_subnode_offset(key_blob, 0, FIT_SIG_NODENAME);
if (key_node < 0) {
debug("%s: No signature node found: %s\n", __func__,
fdt_strerror(key_node));
return 0;
}With no /signature node there are no keys marked 'required', so nothing downstream can fail the image: a FIT whose signatures are absent, malformed or invalid verifies successfully. The only indication is a debug() call, which is compiled out of a normal build.
fit_config_verify_required_keys() carries the same early return, and in that path reqd_sigs also stays at 0, so the closing
"if (reqd_sigs && !verified)" check never fires either.
'iminfo' at this HEAD verifies images but not configurations, so it reaches this gate directly. Against a control devicetree with no /signature node at all, and a FIT whose configuration signature carries no 'value':
## Checking hash(es) for FIT Image at 10400100 ...
Hash(es) for Image 0 (kernel): sha256+
Hash(es) for Image 1 (fdt-1): sha256+That '+' is fit_image_verify_with_data() reporting the signature verified, on a board holding no keys whatsoever.
Add FIT_REQUIRE_CONFIG_SIGS, which turns a missing "/signature" node, and a "/signature" node holding no required keys, into a verification failure on both gates. With CONFIG_FIT_REQUIRE_CONFIG_SIGS=y the same command gives:
## Checking hash(es) for FIT Image at 10400100 ...
Hash(es) for Image 0 (kernel): No signature node in control FDT: FDT_ERR_NOTFOUND
error!
Unable to verify required signature for '' hash node in 'kernel' image node Bad hash in FIT image!
The option defaults to n, and that is a measured choice. Full test_vboot on sandbox with these patches applied:
option at its default (not set): 32 passed, 0 failed CONFIG_FIT_REQUIRE_CONFIG_SIGS=y: 19 passed, 13 failed
The 13 are not a defect in the patch. test/py/tests/test_vboot.py:312 boots an unsigned-images FIT against a key-less devicetree and asserts that it boots, which encodes the old contract. Restructuring that is Ludwig Nussel's 5/8. Default n keeps the shipped behaviour byte-for-byte unchanged.
The new console message is printed only when the option is enabled. Jonas Karlman objected to an unconditional message: Rockchip enables FIT_SIGNATURE for image hash integrity alone and has no /signature node by design, so an unconditional message would be noise on every boot there. Measured with the option off, the string "No signature node in control FDT" appears 0 times in the boot output, and 'iminfo' prints the same 'sha256+' lines as an unpatched build.
printf() is used rather than log_err() so that this stays applicable to main standalone; log_err() in this file requires Ludwig's 3/8. If these are ever squashed together, log_err() is the better choice.
Not tested:
- SPL: SPL_FIT_REQUIRE_CONFIG_SIGS compiles through CONFIG_IS_ENABLED, but no SPL configuration was built or run. Compile coverage only.
- Host tools: mkimage and fit_check_sign build, but no fit_check_sign behaviour change was exercised. CONFIG_IS_ENABLED is false in the host build since tools/Makefile only defines CONFIG_FIT_SIGNATURE, so unchanged host behaviour is argued, not measured.
- Sandbox only: sandbox_defconfig on x86-64. No signed-boot hardware.
- Jonas's Rockchip setup was not reproduced.
No Fixes: tag. The early return is original behaviour rather than a regression. The oldest commit touching it in this path is commit b983cc2da0ba ("lib: rsa: decouple rsa from FIT image verification"), which moves the code from common/image-sig.c to common/image-fit-sig.c rather than introducing it. No introducing commit could be identified with enough confidence to tag one.
--- boot/Kconfig | 27 +++++++++++++++++++++++++++ boot/image-fit-sig.c | 15 +++++++++++++++ 2 files changed, 42 insertions(+)
boot/Kconfig +27 -0
@@ -137,6 +137,25 @@ config FIT_SIGNATURE format support in this case, enable it using CONFIG_LEGACY_IMAGE_FORMAT. +config FIT_REQUIRE_CONFIG_SIGS + bool "Fail verification when the control FDT has no /signature node" + depends on FIT_SIGNATURE + help + Without this option both required-signature gates return success + when the U-Boot control devicetree contains no "/signature" node. + Verified boot is then silently disabled: a FIT image whose + signatures are absent, malformed or invalid verifies successfully + and the only indication is a debug() message, which is compiled + out of a normal build. + + Enable this option to treat a missing "/signature" node, and a + "/signature" node which holds no keys marked required="conf", as a + verification failure instead. + + Say N if the same U-Boot binary must also run in setups which carry + no keys, or which enable FIT_SIGNATURE only for image hash + integrity checking rather than for signature enforcement. + config FIT_SIGNATURE_MAX_SIZE hex "Max size of signed FIT structures" depends on FIT_SIGNATURE
@@ -259,6 +278,14 @@ config SPL_FIT_SIGNATURE_MAX_SIZE device memory. Assure this size does not extend past expected storage space. +config SPL_FIT_REQUIRE_CONFIG_SIGS + bool "Fail verification when the SPL control FDT has no /signature node" + depends on SPL_FIT_SIGNATURE + select FIT_REQUIRE_CONFIG_SIGS + help + Enable the FIT_REQUIRE_CONFIG_SIGS behaviour in SPL. See the help text + of FIT_REQUIRE_CONFIG_SIGS for details. + config SPL_LOAD_FIT bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)" depends on SPL
boot/image-fit-sig.c +15 -0
@@ -201,6 +201,11 @@ int fit_image_verify_required_sigs(const void *fit, int image_noffset, *no_sigsp =1 ; key_node =fdt_subnode_offset (key_blob,0 ,FIT_SIG_NODENAME );if (key_node <0 ) { +if (CONFIG_IS_ENABLED (FIT_REQUIRE_CONFIG_SIGS )) { +printf ("No signature node in control FDT: %s\n" , +fdt_strerror (key_node)); +return -ENOENT ; + }debug ("%s: No signature node found: %s\n" , __func__,fdt_strerror (key_node));return 0 ;
@@ -684,6 +689,11 @@ static int fit_config_verify_required_keys(const void *fit, int conf_noffset,/* Work out what we need to verify */ key_node =fdt_subnode_offset (key_blob,0 ,FIT_SIG_NODENAME );if (key_node <0 ) { +if (CONFIG_IS_ENABLED (FIT_REQUIRE_CONFIG_SIGS )) { +printf ("No signature node in control FDT: %s\n" , +fdt_strerror (key_node)); +return -ENOENT ; + }debug ("%s: No signature node found: %s\n" , __func__,fdt_strerror (key_node));return 0 ;
@@ -735,6 +745,11 @@ static int fit_config_verify_required_keys(const void *fit, int conf_noffset,return -EPERM ; } +if (!reqd_sigs &&CONFIG_IS_ENABLED (FIT_REQUIRE_CONFIG_SIGS )) { +printf ("No required keys found for configuration verification\n" ); +return -EPERM ; + } +return 0 ; }
Signature · 1 line
2.53.0
PATCH v2 2/2 test: vboot: add coverage for a control FDT with no /signature node
In reply to Eva CrystalBuild a control devicetree with no "/signature" node and an unsigned FIT, then check that the boot is refused when CONFIG_FIT_REQUIRE_CONFIG_SIGS is enabled, and that the historical fail-open behaviour with a quiet console is kept when it is not.
--- test/py/tests/test_vboot.py | 96 +++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)
test/py/tests/test_vboot.py +96 -0
@@ -846,3 +846,99 @@ def test_fdt_add_pubkey(ubman, name, sha_algo, padding, sign_options, algo_arg): # keys created in test_vboot test test_add_pubkey(sha_algo, padding, sign_options) + + [email protected]('sandbox') [email protected]('fit_signature') [email protected]('dtc') [email protected]('fdtget') [email protected]('openssl') +def test_vboot_no_sig_node(ubman): + """Test a control FDT which contains no /signature node. + + Both required-signature gates in fit_image_verify_required_sigs() and + fit_config_verify_required_keys() look up the "/signature" node of the + U-Boot control devicetree. When that node is absent there are no keys + marked 'required', so nothing downstream can fail the image, and a FIT + whose signatures are absent or invalid verifies successfully. + + With CONFIG_FIT_REQUIRE_CONFIG_SIGS the missing node is an error and the + boot must be refused. Without it the historical fail-open behaviour is + kept, so that boards using FIT_SIGNATURE only for image hash integrity + keep booting and keep a quiet console. + + This works using sandbox only as it needs to control the device tree + used by U-Boot. + """ + sha_algo = 'sha256' + + def run_bootm(test_type, expect_string, boots): + """Run a 'bootm' command in U-Boot. + + Args: + test_type: A string identifying the test type. + expect_string: A string which is expected in the output. + boots: True if the image is expected to boot, False if the boot + is expected to be refused. + """ + ubman.restart_uboot() + with ubman.log.section('Verified boot %s %s' % (sha_algo, test_type)): + output = ubman.run_command_list( + ['host load hostfs - 100 %s' % fit, + 'fdt addr 100', + 'bootm 100']) + assert expect_string in ''.join(output) + if boots: + assert 'sandbox: continuing, as we cannot run' in ''.join(output) + else: + assert ('sandbox: continuing, as we cannot run' + not in ''.join(output)) + + tmpdir = os.path.join(ubman.config.result_dir, 'no-sig-node') + '/' + if not os.path.exists(tmpdir): + os.mkdir(tmpdir) + datadir = ubman.config.source_dir + '/test/py/tests/vboot/' + fit = '%stest.fit' % tmpdir + mkimage = ubman.config.build_dir + '/tools/mkimage' + dtc_args = '-I dts -O dtb -i %s' % tmpdir + dtb = '%ssandbox-u-boot.dtb' % tmpdir + + bcfg = ubman.config.buildconfig + require_config_sigs = bcfg.get('config_fit_require_config_sigs', False) + + # Create a kernel image filled with zeroes + with open('%stest-kernel.bin' % tmpdir, 'wb') as fd: + fd.write(500 * b'\0') + + # We need to use our own device tree file. Remember to restore it + # afterwards. + old_dtb = ubman.config.dtb + try: + ubman.config.dtb = dtb + + # Compile the control devicetree. sandbox-u-boot.dts holds no keys, + # and mkimage is deliberately not asked to add any, so the resulting + # blob has no /signature node at all. + dtc('sandbox-kernel.dts', ubman, dtc_args, datadir, tmpdir, dtb) + dtc('sandbox-u-boot.dts', ubman, dtc_args, datadir, tmpdir, dtb) + + # Confirm the premise of the test: no /signature node is present. + out = utils.run_and_log(ubman, 'fdtget -l %s /' % dtb) + assert 'signature' not in out + + # Build a FIT whose configuration signature has no 'value', i.e. it + # is unsigned. + ubman.log.action('%s: Test unsigned FIT with no keys in control FDT' + % sha_algo) + make_fit('sign-configs-%s.its' % sha_algo, ubman, mkimage, dtc_args, + datadir, fit) + + if require_config_sigs: + run_bootm('no signature node', 'No signature node in control FDT', + False) + else: + run_bootm('no signature node', 'Verifying Hash Integrity', True) + finally: + # Go back to the original U-Boot with the correct dtb. + ubman.config.dtb = old_dtb + ubman.restart_uboot()
Signature · 1 line
2.53.0