SFT-8316: prevented null truncation in op_return messages
What changed, and why it matters
This commit fixes a display bug in Passport's Bitcoin signing flow. When a transaction contains an OP_RETURN message with a hidden NUL (zero-value) byte, the device's screen would silently cut off everything after that byte. An attacker could craft a message that looks short or harmless on the device, while the real message the user is approving is actually longer or different. The fix now detects NUL bytes and shows the message as raw hex instead, so the full content is visible.
Treat as a low-to-moderate UI integrity issue. Review whether other user-facing string fields (memos, labels, address notes, etc.) are also rendered through LVGL without NUL handling. Consider a broader policy of hex-escaping or rejecting NUL bytes in any attacker-influenced display text.
Security signals we found
UI truncation of embedded NUL bytes can hide part of an OP_RETURN payload from the user
User-visible message may not match the data actually being signed
OP_RETURN messages are attacker-controlled data included in transactions
Fix is defensive: force hex display when NUL bytes are present
Evidence from the diff
The render_op_return_message() helper in sign_psbt_common_flow.py decides whether to display an OP_RETURN data payload as printable text or as hex. Previously it only checked whether any character was outside the printable ASCII range (‘!’ to ‘~’). Because the LVGL UI library truncates strings at embedded NUL bytes, a payload such as ‘A\x00B’ would render as just ‘A’ even though it is technically non-printable. The patch adds an explicit \x00 in message check, forcing any message containing a NUL byte to be displayed as hex. Unit tests confirm NUL-containing strings are now hex-encoded.
Changed components
ports/stm32/boards/Passport/modules/flows/sign_psbt_common_flow.pyOP_RETURN message rendering during PSBT signing flowInspect captured patch +5 / −1
### ports/stm32/boards/Passport/modules/flows/sign_psbt_common_flow.py
@@ -23,7 +23,8 @@ def render_op_return_message(message):
# message, so fall back to its bytes in hex.
if not message:
return '(empty)'
- if not any('!' <= char <= '~' for char in message):
+ # LVGL truncates text at NUL, even when printable characters follow it.
+ if '\x00' in message or not any('!' <= char <= '~' for char in message):
return b2a_hex(message.encode()).decode()
return escape_text(message)
### ports/stm32/boards/Passport/modules/tests/unit/sign_psbt.py
@@ -59,6 +59,9 @@ def assert_op_return_output(value, message, shown=None):
assert assert_op_return_output(1, '‘', 'e28098').endswith('\ne28098')
assert assert_op_return_output(1, '한글', 'ed959ceab880').endswith('\ned959ceab880')
assert assert_op_return_output(1, ' \n ', '200a20').endswith('\n200a20')
+assert assert_op_return_output(1, '\x00A', '0041').endswith('\n0041')
+assert assert_op_return_output(1, 'A\x00B', '410042').endswith('\n410042')
+assert assert_op_return_output(1, 'A\x00', '4100').endswith('\n4100')
# One drawable character is enough to show the text itself.
assert assert_op_return_output(1, 'a‘b').endswith('\na‘b')
Why this scored 49/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.