Skip to content

apps: demonstrate MCUboot sysbuild signing-key custody problem#1

Open
JPHutchins wants to merge 1 commit into
mainfrom
example/app-relative-key-resolution-failure
Open

apps: demonstrate MCUboot sysbuild signing-key custody problem#1
JPHutchins wants to merge 1 commit into
mainfrom
example/app-relative-key-resolution-failure

Conversation

@JPHutchins

Copy link
Copy Markdown
Collaborator

What & why

Under sysbuild, a single SB_CONFIG_BOOT_SIGNATURE_KEY_FILE is propagated to two images that resolve relative key paths against different bases:

image symbol relative-path resolution
application CONFIG_MCUBOOT_SIGNATURE_KEY_FILE abs → APPLICATION_CONFIG_DIR (app) → WEST_TOPDIR
MCUboot CONFIG_BOOT_SIGNATURE_KEY_FILE abs → APPLICATION_CONFIG_DIR (mcuboot src) → MCUBOOT_DIR

So a key referenced relative to the application is not resolvable by the bootloader image — it anchors to the mcuboot module. The naive consequence is that signing keys (gitignored or not) get pushed into repos you don't own. This adds runnable example apps that demonstrate the failure and the workarounds.

The apps (apps/)

All verified on nrf52840dk/nrf52840, ECDSA-P256 (RSA is currently broken on mainBOOT_RSA_MBEDTLS_LEGACY vs the mbedtls→TF-PSA-Crypto transition).

app SB_CONFIG_BOOT_SIGNATURE_KEY_FILE result
app_relative_key keys/… (bare relative) fails — resolves into mcuboot
key_via_cmake_list_dir ${CMAKE_CURRENT_LIST_DIR}/… fails — resolves into zephyr
key_in_mcuboot_module bare relative + key copied into mcuboot builds by dirtying mcuboot
key_in_app_dir ${APP_DIR}/keys/… builds, key stays in this repo (+ Twister sample.yaml)

The two failing forms implicate the two unowned modules: bare-relative → mcuboot, ${CMAKE_CURRENT_LIST_DIR}zephyr. Putting the key at the workspace/repo root does not help (the bootloader never falls back to WEST_TOPDIR).

Finding

${APP_DIR} is the only relative form that keeps the key in the user-owned repo and resolves for both images — it is expanded once by string(CONFIGURE) in sysbuild scope (share/sysbuild/cmake/modules/sysbuild_extensions.cmake), so both images get the identical absolute path (no key mismatch). It is undocumented. The cross-image asymmetry is intentional (maintainers declined a WEST_TOPDIR bootloader fallback in mcuboot PR #2591), so the smallest correct upstream action is likely a docs PR. Full upstream position + citations in apps/FINDINGS.md; verified resolution matrix in apps/README.md.

Notes

  • Adds mcuboot to the west.yml import allowlist (needed for the sysbuild MCUboot examples).
  • Commits clearly-labeled insecure, demo-only ECDSA-P256 keys (insecure-ec-p256.pem) so the apps clone-and-build.

🤖 Generated with Claude Code

A single SB_CONFIG_BOOT_SIGNATURE_KEY_FILE feeds two images that resolve
relative key paths against different bases: the application image against
APPLICATION_CONFIG_DIR/WEST_TOPDIR, and the MCUboot image against
APPLICATION_CONFIG_DIR/MCUBOOT_DIR. A key referenced relative to the
application is therefore not resolvable by the bootloader image, which
pushes signing keys into unowned module trees (the custody problem).

Add apps/ with runnable sysbuild sub-apps (shared common/src/main.c),
README.md (empirically verified resolution matrix) and FINDINGS.md
(upstream position + citations). Verified on nrf52840dk/nrf52840, ECDSA-P256:

- app_relative_key       bare relative -> FAILS, resolves into mcuboot
- key_via_cmake_list_dir  ${CMAKE_CURRENT_LIST_DIR} -> FAILS, resolves into zephyr
- key_in_mcuboot_module   key copied into mcuboot -> builds, dirties the module
- key_in_app_dir          ${APP_DIR} -> builds, key stays in the app (+ twister test)

${APP_DIR} is the only relative form that keeps the key in the user-owned
repo and resolves for both images (expanded once in sysbuild scope at
share/sysbuild/cmake/modules/sysbuild_extensions.cmake), and it is
undocumented -- likely a docs PR upstream.

Add mcuboot to the west.yml import allowlist (needed for these examples).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 22, 2026 20:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants