AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 57 Bitcoin

SFT-7112: share one validation path between both message formats

Public commit record

What the developer wrote

Authored by Jack

83/100 · Strong
SFT-7112: share one validation path between both message formats

validate_lines() duplicated the text and path validation in each format
branch, and the empty-message guard was only ever added to the signmessage
branch. The legacy 2- and 3-line format therefore still assigned
self.text = self.lines[0] and called validate_sign_text() straight after, and
that opens with text[0] == ' ' under its default check_whitespace, so a file
beginning with a newline raised an uncaught IndexError.

Reachable from microSD and from QR: health_check_microsd_flow.py splits with
splitlines() and the guards above it only reject wholly empty content, not an
empty first line, and a 2-element list passes the length check.

Collapse the duplicated sequence into one validation path that runs for both
formats, with the empty check in front of it. Only the address-type derivation
stays branch-specific, since the legacy format carries its own type on the
third line while the Envoy format takes it from the path. That is the shape
originally proposed on the issue; splitting it per branch is what allowed one
copy to be fixed and the other missed.

Extend tests/unit/single_line_message.py with the legacy format: an empty first
line in both the 2- and 3-line shapes, in both signing modes, plus controls
that the legacy format still signs, still takes its address type from the third
line, and is still refused on an unusable path.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a bug where a specially crafted message file could crash the Passport firmware with an IndexError. If a file loaded from microSD or scanned via QR began with a blank line, the firmware would try to read the first character of an empty message and crash. The fix consolidates the message validation so the same empty-message check applies to both the newer Envoy format and the older 2- or 3-line format. It also adds tests to prevent the bug from returning.

Recommended action

Treat this as a low-to-moderate reliability/security fix. The crash is reachable from user-supplied microSD and QR inputs and could be used to deny service or disrupt signing workflows. Apply the patch and run the extended unit tests. Review other flows for duplicated validation logic that may have similar inconsistent guards.

Security signals we found

01

Uncaught IndexError from empty string indexing in message validation

02

Input reachable from untrusted sources: microSD card and QR code scans

03

Duplicated validation logic led to inconsistent guards between code branches

04

Fix includes regression tests for the missed edge case

Risk score

Why this scored 57/100

Our methodology →
Potential impact 12/30
Exploitability 14/25
Stealth signal 8/15
Affected reach 11/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.