fix(M4): format-storage requires a board-id-derived confirmation token - #17
Closed
d33mobile wants to merge 1 commit into
Closed
fix(M4): format-storage requires a board-id-derived confirmation token#17d33mobile wants to merge 1 commit into
d33mobile wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d33mobile
force-pushed
the
fix/m4-format-auth
branch
from
August 4, 2026 16:56
1257a12 to
7ed9daa
Compare
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.
Finding (ISSUES.md M4 —
format-storageis unauthenticated and chains to fail-open admin)The fix
cmd_format_storage(serial/commands_system.c) no longer accepts the fixed literalCONFIRM. It now derives the confirmation token frompico_get_unique_board_id(): the operator must type the board's 16-hex uppercase unique id to proceed.Why this works even when storage is down — the mount-failure entry point is design intent and cannot rely on
login(storage is unavailable, socmd_loginrefuses). This remediation needs no storage and no clock. Crucially, while storage is unmounted the dispatcher (commands.c:110) allow-lists onlyformat-storage/help/?, sostatus(the only command that prints the board id) is not reachable, and the handler never echoes the token — it only echoes the operator's own keystrokes. A remote/blind attacker who reaches the console in the unmounted state therefore cannot learn the token. Reading it requires physical access to the device (via a probe, or a priorstatuswhile healthy). Input is uppercase-normalised for hex a-f; the read is bounded to the token length and the buffer is sizedPICO_UNIQUE_BOARD_ID_SIZE_BYTES * 2 + 1(16 hex + NUL), preserving the prior safe bounds.The existing
storage_is_mounted()gate is kept unchanged.Deferred to M1
The second M4 sub-item — "force a provisioning state after format in which the door cannot open until an admin key is enrolled" — overlaps M1 (the fail-open-admin cluster). M1's
cmd_loginrework already makes the only credential-free path a genuinely unprovisioned device that self-closes once an admin key is added, and the door already fails closed with no admin key / unset clock. This PR is kept focused on the confirm-token hardening to avoid duplicating M1; the provisioning-state item is covered there.Host-test status
The board-id path is only compiled compile-only in the coverage build; the
pico/unique_id.hhost stub already declarespico_get_unique_board_id(added forstatus), andharness_commandslinks a SPY forcmd_format_storage, so no stub/harness changes were needed. All CI-gated host gates pass (0):make -C test asan— 0make -C test valgrind— 0make -C test coverage— 0./ci --action=check(clang-format lint) — 0fuzz_*.charnesses untouched.verify-on-hw
The board-id read (
pico_get_unique_board_idagainst the real flash chip) and the post-format reboot into the unprovisioned state cannot be exercised on the host — confirm on hardware that the printed/typed token matches thestatusboard id and that the device reboots correctly after a successful format.