Merge pull request #727 from Foundation-Devices/SFT-8316-show-op-return-payloads-containing-null-as-hex
What changed, and why it matters
This update fixes a display issue on the Passport hardware wallet when showing Bitcoin OP_RETURN message data. Previously, if the message contained a null (zero-value) byte, the on-screen text would be cut off at that point, hiding anything after it. The device now shows the full message as hexadecimal instead. This matters because a user approving a transaction might only see part of an embedded message, which could be used to mislead them about what the transaction actually contains.
Treat as a low-severity UI fix with possible security relevance. Review whether other user-facing transaction fields (memos, labels, output descriptions) are also rendered through LVGL without NUL handling. No urgent firmware rollout required solely for this change, but include it in the next release.
Security signals we found
UI truncation of embedded transaction data could hide attacker-controlled content
OP_RETURN payloads are user-facing during transaction signing review
Patch adds explicit NUL-byte handling and regression tests
No cryptographic, signature, or key-handling code changed
Evidence from the diff
The commit changes render_op_return_message() in sign_psbt_common_flow.py so that any OP_RETURN payload containing a NUL byte (‘\x00’) is rendered as hex (b2a_hex) rather than as printable text. The previous logic only hex-encoded messages that contained no printable ASCII characters at all. Because the LVGL UI library truncates strings at NUL, a payload such as ‘A\x00B’ would display only ‘A’, hiding the trailing ‘B’. The patch adds explicit ‘\x00’ detection and unit tests for leading, middle, and trailing NUL bytes. This is a UI-truncation bug in transaction-review display logic, not a cryptographic flaw.
Changed components
ports/stm32/boards/Passport/modules/flows/sign_psbt_common_flow.pyports/stm32/boards/Passport/modules/tests/unit/sign_psbt.pyInspect 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 41/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.