SFT-7112: handled signing the single-lign message format, fixed message
What changed, and why it matters
This commit fixes how Passport firmware reads health-check and sign-message data from microSD cards and QR codes. Previously, the code only accepted messages split into exactly 2 or 3 lines and treated trailing blank lines as errors. The update also accepts a compact 'signmessage <path> ascii:<text>' single-line format and ignores trailing newlines. The change is described as a format/parser fix, not as a security fix, but a stricter parser could in principle have rejected legitimate messages or accepted malformed ones.
Treat as a functional/parser improvement unless further review shows that malformed single-line 'signmessage ...' inputs can bypass validation or cause unexpected signing behavior. Review validate_sign_text and get_addr_type_from_deriv for robustness against malicious subpaths, and consider adding tests for trailing-newline and malformed single-line inputs.
Security signals we found
Parser strictness relaxed: trailing newlines no longer cause rejection
New single-line command format accepted without explicit length or delimiter validation beyond simple split
Address type derived from user-supplied derivation path in new code path
No explicit input sanitization shown for subpath or text beyond existing validate_sign_text call
Commit does not mention security, vulnerability, CVE, or researcher attribution
Evidence from the diff
The patch modifies two flows: health_check_common_flow.py and health_check_microsd_flow.py. In health_check_microsd_flow.py, data.split(‘\n’) is replaced with data.splitlines(), which strips trailing newlines and handles different line endings. In health_check_common_flow.py, validate_lines() now first checks whether the first line starts with ‘signmessage ’ and, if so, parses the entire raw text as a single-line command, extracting subpath and ascii text. Otherwise it falls back to the original 2- or 3-line parsing. A new import get_addr_type_from_deriv is added to derive the address type from the derivation path in the single-line case. The commit title and message frame this as handling a new message format and fixing parser sensitivity to trailing newlines.
Changed components
ports/stm32/boards/Passport/modules/flows/health_check_common_flow.pyports/stm32/boards/Passport/modules/flows/health_check_microsd_flow.pyInspect captured patch +27 / −13
### ports/stm32/boards/Passport/modules/flows/health_check_common_flow.py
@@ -4,7 +4,7 @@
# health_check_common_flow.py - Scan and process a health check QR code in `crypto-request` format
from flows import Flow
-from wallets.utils import get_addr_type_from_string
+from wallets.utils import get_addr_type_from_deriv, get_addr_type_from_string
from public_constants import AF_CLASSIC
@@ -20,19 +20,33 @@ def __init__(self, lines, normal_signing=False):
async def validate_lines(self):
from pages import ErrorPage
from utils import validate_sign_text
- if len(self.lines) not in [2, 3]:
- await ErrorPage('{} format is invalid.'.format('Message' if self.normal_signing else 'Health check')).show()
- self.set_result(None)
- return
+ err_label = 'Message' if self.normal_signing else 'Health check'
+
+ if self.lines and self.lines[0].startswith('signmessage '):
+ raw = '\n'.join(self.lines)
+ parts = raw.split(' ', 2)
+ if len(parts) != 3 or not parts[2].startswith('ascii:'):
+ await ErrorPage('{} format is invalid.'.format(err_label)).show()
+ self.set_result(None)
+ return
+
+ self.subpath = parts[1]
+ self.text = parts[2][len('ascii:'):]
+
+ derived = get_addr_type_from_deriv(self.subpath)
+ if derived is not None:
+ self.addr_type = derived
+ else:
+ if len(self.lines) not in [2, 3]:
+ await ErrorPage('{} format is invalid.'.format(err_label)).show()
+ self.set_result(None)
+ return
- # Common function to validate the message
- self.text = self.lines[0]
- self.subpath = self.lines[1]
+ self.text = self.lines[0]
+ self.subpath = self.lines[1]
- if len(self.lines) == 3:
- self.addr_type = get_addr_type_from_string(self.lines[2])
- # print('text={}'.format(self.text))
- # print('subpath={}'.format(self.subpath))
+ if len(self.lines) == 3:
+ self.addr_type = get_addr_type_from_string(self.lines[2])
# Validate
(subpath, error) = validate_sign_text(self.text, self.subpath)
### ports/stm32/boards/Passport/modules/flows/health_check_microsd_flow.py
@@ -91,7 +91,7 @@ async def parse_message(self):
self.set_result(False)
return
- self.lines = data.split('\n')
+ self.lines = data.splitlines()
self.goto(self.common_flow)
async def common_flow(self):Why this scored 35/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.