SFT-7497: input validation in the firmware header path - #63
Closed
Jacksper13 wants to merge 1 commit into
Closed
Jacksper13 wants to merge 1 commit into
Jacksper13 wants to merge 1 commit into
Conversation
Tighten input handling so malformed local input produces an error rather than an unwind. MAX_PUBLIC_KEYS is the number of Foundation keys, so derive the index bound from the array as a strict upper bound and say so in its doc. Make the lookups return Option through a single checked helper. verify_signature() now verifies the header and returns VerifySignatureError::InvalidHeader rather than asserting on it, and maps a None lookup onto the matching index error. The CLI checks the file is at least HEADER_LEN bytes before slicing it. Nothing that verified successfully before changes. Note for downstream: VerifySignatureError gains a variant, and public_key1()/public_key2() return Option.
Jacksper13
force-pushed
the
fix/firmware-header-fail-closed
branch
from
September 29, 2026 12:52
ddb842e to
8f6a19c
Compare
Contributor
Author
|
Closed in favour of a clean branch. |
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.
Tightens input handling in
foundation-firmwareso malformed local input produces an error rather than an unwind.MAX_PUBLIC_KEYS's doc now says what it is — the number of keys, so a valid index is strictly less than it.public_key1()andpublic_key2()returnOption<PublicKey>through a single checked lookup.verify_signature()verifies the header and returnsVerifySignatureError::InvalidHeaderrather than asserting on it.HEADER_LENbytes before slicing it.Nothing that verified successfully before changes.
Downstream
VerifySignatureErrorgains a variant.passport2'sextmod/foundation-rust/src/firmware.rsmatches on it exhaustively, so bumping this dependency there needs an arm forInvalidHeader— mapping it to whateverFirmwareResultthe header errors already use.public_key1()/public_key2()change return type. Nothing outside this crate calls them today.Tests
In
firmware/tests/test-vectors.rs, built by mutating the parsedVALID_HEADERrather than adding fixtures: boundary and extreme indexes for both key fields, every in-range index, a user-signed header, and empty and truncated input.SFT-7497