Close the FIT signature fail-open on the image gate
cover Close the FIT signature fail-open on the image gate
This follows up my report of 2026-09-08, "[SECURITY] FIT signature enforcement fails open when the control DTB has no /signature node":
https://lore.kernel.org/u-boot/CA+pz=k+hAU5dqbO4GOLJ0fRMRdyrq=kTSnwUc0OcR3r9PotUgg@mail.gmail.com/
Tom asked for a fix and a test following the sending_patches process, so here they are. Everything below was measured on sandbox at commit a44f46af0aa1 ("MAINTAINERS: tee: update Jens Wiklander's email address").
The fail-open
-------------
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. The only indication is a debug() call, compiled out of a normal build.
'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. The comment beside it in boot/image-fit.c is correct that only 'required' keys can fail an image, and that is precisely what makes a missing /signature node fatal to the security property rather than to the boot.
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!
Relationship to Ludwig Nussel's series
--------------------------------------
The same early return exists in the configuration path, at boot/image-fit-sig.c:686-690, and that half is already being addressed. Ludwig Nussel's "Improve FIT signature handling" series has been fixing it since April and is at v8:
v7 4/8, direct link:
https://lore.kernel.org/u-boot/20260618144742.v7.4.6d1d5d14140677a76a7cd7bb99a9088d8c8f480c@changeid/
v8 4/8 review thread:
https://lore.kernel.org/u-boot/[email protected]/
That series introduces CONFIG_FIT_REQUIRE_CONFIG_SIGS, closes the configuration gate, and also restructures the closing check at boot/image-fit-sig.c:733 to cover the case where /signature exists but holds no required="conf" keys, where reqd_sigs stays 0 and the check cannot fire. The v7 form was applied to u-boot/next on 2026-06-30 and then dropped after CI failed.
This series is complementary, not competing. v2 through v8 change only fit_config_verify_required_keys(); fit_image_verify_required_sigs() is untouched throughout. That image gate is what these patches close. The Kconfig symbol here is deliberately Ludwig's FIT_REQUIRE_CONFIG_SIGS rather than a new name, so that whichever lands first the other reduces to a smaller change rather than a conflicting one. If 4/8 lands first, all that remains of patch 1/2 is the image-gate hunk.
Kconfig name and default
------------------------
CONFIG_FIT_REQUIRE_CONFIG_SIGS, depends on FIT_SIGNATURE, default n, plus SPL_FIT_REQUIRE_CONFIG_SIGS which selects it.
Default n is a measured choice, not caution. Full test_vboot suite 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_vboot's first step is
test/py/tests/test_vboot.py:312
run_bootm(sha_algo, 'unsigned images', ' - OK' if algo_arg else 'dev-', True)
which boots an unsigned-images FIT against a devicetree that has no keys yet and asserts that it boots. That assertion encodes the old contract, so enforcing correctly breaks it:
E assert 'dev-' in "... No signature node in control FDT: FDT_ERR_NOTFOUND
Bad Data Hash ... ERROR -2: ... can't get kernel image!"
This is the same class of CI breakage that got v7 dropped from next. Making the option default y would require test_vboot to be restructured first, which is what Ludwig's 5/8 does. Until that lands, default n keeps the shipped configuration byte-for-byte unchanged in behaviour.
The console message is conditional
----------------------------------
The message is printed only when the option is enabled; the debug() call is kept otherwise. Jonas Karlman objected to making it unconditional:
https://lore.kernel.org/u-boot/[email protected]/
"Yes, printing a verbose error message for something that should not
always be treated as an error is an issue."
Rockchip enables FIT_SIGNATURE for image hash integrity alone and has no /signature node by design, so an unconditional message is noise on every boot there. Gating it means a board that has not asked for enforcement sees no change at all. 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 applies 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
----------
Being explicit, because some of this matters for review:
- SPL: SPL_FIT_REQUIRE_CONFIG_SIGS is added and compiles through CONFIG_IS_ENABLED, but I have not built or run any SPL configuration. Compile coverage only. It needs someone with SPL verified boot.
- Host tools: mkimage and fit_check_sign build with the patch, but I have not exercised any fit_check_sign behaviour change. CONFIG_IS_ENABLED is false in the host build since tools/Makefile only defines CONFIG_FIT_SIGNATURE, so host behaviour should be unchanged -- argued, not measured.
- Sandbox only. I have no signed-boot hardware. Everything above is sandbox_defconfig on x86-64.
- Jonas's Rockchip setup: not reproduced. I reasoned that the off path stays quiet and then measured that it does on sandbox, which is not the same as booting an RK3588.
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"), and that one moves the code from common/image-sig.c to common/image-fit-sig.c rather than introducing it. I could not identify an introducing commit with enough confidence to tag one, so I have not.
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
Quoted 161 lines · Eva Crystal
This follows up my report of 2026-09-08, "[SECURITY] FIT signature enforcement fails open when the control DTB has no /signature node":
https://lore.kernel.org/u-boot/CA+pz=k+hAU5dqbO4GOLJ0fRMRdyrq=kTSnwUc0OcR3r9PotUgg@mail.gmail.com/
Tom asked for a fix and a test following the
sending_patchesprocess, so here they are. Everything below was measured on sandbox at commita44f46af0aa1("MAINTAINERS: tee: update Jens Wiklander's email address").The fail-open
-------------
fit_image_verify_required_sigs()atboot/image-fit-sig.c:187looks 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. The only indication is a
debug()call, compiled out of a normal build.'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. The comment beside it inboot/image-fit.cis correct that only 'required' keys can fail an image, and that is precisely what makes a missing /signature node fatal to the security property rather than to the boot.With
CONFIG_FIT_REQUIRE_CONFIG_SIGS=ythe 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!Relationship to Ludwig Nussel's series
--------------------------------------The same early return exists in the configuration path, at boot/image-fit-sig.c:686-690, and that half is already being addressed. Ludwig Nussel's "Improve FIT signature handling" series has been fixing it since April and is at v8:
v7 4/8, direct link:
https://lore.kernel.org/u-boot/20260618144742.v7.4.6d1d5d14140677a76a7cd7bb99a9088d8c8f480c@changeid/v8 4/8 review thread:
https://lore.kernel.org/u-boot/[email protected]/That series introduces
CONFIG_FIT_REQUIRE_CONFIG_SIGS, closes the configuration gate, and also restructures the closing check atboot/image-fit-sig.c:733to cover the case where /signature exists but holds no required="conf" keys, wherereqd_sigsstays 0 and the check cannot fire. The v7 form was applied to u-boot/next on 2026-06-30 and then dropped after CI failed.This series is complementary, not competing. v2 through v8 change only
fit_config_verify_required_keys();fit_image_verify_required_sigs()is untouched throughout. That image gate is what these patches close. TheKconfigsymbol here is deliberately Ludwig'sFIT_REQUIRE_CONFIG_SIGSrather than a new name, so that whichever lands first the other reduces to a smaller change rather than a conflicting one. If 4/8 lands first, all that remains of patch 1/2 is the image-gate hunk.
Kconfigname and default
------------------------
CONFIG_FIT_REQUIRE_CONFIG_SIGS, depends onFIT_SIGNATURE, default n, plusSPL_FIT_REQUIRE_CONFIG_SIGSwhich selects it.Default n is a measured choice, not caution. Full
test_vbootsuite 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 failedThe 13 are not a defect in the patch. test_vboot's first step is
test/py/tests/test_vboot.py:312
run_bootm(sha_algo, 'unsigned images', ' - OK' if algo_arg else 'dev-', True)which boots an unsigned-images FIT against a devicetree that has no keys yet and asserts that it boots. That assertion encodes the old contract, so enforcing correctly breaks it:
E assert 'dev-' in "... No signature node in control FDT:
FDT_ERR_NOTFOUND
Bad Data Hash ... ERROR -2: ... can't get kernel image!"This is the same class of CI breakage that got v7 dropped from next. Making the option default y would require
test_vbootto be restructured first, which is what Ludwig's 5/8 does. Until that lands, default n keeps the shipped configuration byte-for-byte unchanged in behaviour.The console message is conditional
----------------------------------The message is printed only when the option is enabled; the
debug()call is kept otherwise. Jonas Karlman objected to making it unconditional:https://lore.kernel.org/u-boot/[email protected]/
"Yes, printing a verbose error message for something that should not
always be treated as an error is an issue."Rockchip enables
FIT_SIGNATUREfor image hash integrity alone and has no /signature node by design, so an unconditional message is noise on every boot there. Gating it means a board that has not asked for enforcement sees no change at all. 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 thanlog_err()so that this applies 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
----------Being explicit, because some of this matters for review:
- SPL:
SPL_FIT_REQUIRE_CONFIG_SIGSis added and compiles throughCONFIG_IS_ENABLED, but I have not built or run any SPL configuration. Compile coverage only. It needs someone with SPL verified boot.
- Host tools: mkimage andfit_check_signbuild with the patch, but I have not exercised anyfit_check_signbehaviour change.CONFIG_IS_ENABLEDis false in the host build sincetools/Makefileonly definesCONFIG_FIT_SIGNATURE, so host behaviour should be unchanged -- argued, not measured.
- Sandbox only. I have no signed-boot hardware. Everything above issandbox_defconfigon x86-64.
- Jonas's Rockchip setup: not reproduced. I reasoned that the off path stays quiet and then measured that it does on sandbox, which is not the same as booting an RK3588.No Fixes: tag
-------------
Quoted 6 lines
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"), and that one moves the code fromcommon/image-sig.ctocommon/image-fit-sig.crather than introducing it. I could not identify an introducing commit with enough confidence to tag one, so I have not.
This is a very long cover letter. It also doesn't fit our normal style (which you can see many examples of with "git log --merges"), can you please rewrite it to be more concise and fit the normal style? Thanks.
Signature · 1 line
Tom
PATCH 1/2 image-fit-sig: also require signatures on the image gate
In reply to Eva Crystalfit_image_verify_required_sigs() and fit_config_verify_required_keys() both look up the "/signature" node of the U-Boot control devicetree, and both return 0 when it is absent. There are then 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.
In the configuration path reqd_sigs also stays at 0, so the closing "if (reqd_sigs && !verified)" check never fires either.
On sandbox, 'iminfo' against a FIT with no keys at all in the control devicetree reports verification success:
## Checking hash(es) for FIT Image at 10400100 ...
Hash(es) for Image 0 (kernel): sha256+
Hash(es) for Image 1 (fdt-1): sha256+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.
The new console message is printed only when the option is enabled. Boards which enable FIT_SIGNATURE for image hash integrity alone, and which legitimately have no "/signature" node, keep both their existing behaviour and a quiet console.
The option defaults to n. Enabling it changes behaviour for existing
configurations: with CONFIG_FIT_REQUIRE_CONFIG_SIGS=y, 13 of the 32 sandbox test_vboot cases fail, because test_vboot's first step boots an unsigned-images FIT against a key-less devicetree and expects that to succeed. Making it default y would require test_vboot to be restructured first.
--- 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 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