Allowing for message signature the line feed (LF) character handled by NBGL (2 new tests)
What changed, and why it matters
This commit only changes automated test code for the Bitcoin app's message-signing feature. It adds a new test for messages containing a line feed (LF) character and updates an existing test to use a carriage return (CR) instead of a line feed. There is no change to the actual app code that runs on the Ledger device, so this commit does not introduce or fix a security vulnerability by itself.
No security action required. Treat as routine test maintenance. If investigating a potential security issue around message signing, review the corresponding application code change (not present in this commit) that motivated these test updates.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies tests/test_sign_message.py. It adds test_sign_message_eol() to verify signing a message containing LF characters on NBGL firmware, and changes test_sign_message_accept_non_ascii and test_sign_message_hash_reject to use ‘\r’ (CR) instead of ‘\n’ (LF) as the non-ASCII/control-character test case, with corresponding expected signature updates. No application source code is changed.
Changed components
tests/test_sign_message.pyInspect captured patch +13 / −3
diff --git a/tests/test_sign_message.py b/tests/test_sign_message.py
index 49fed33..acb97a0 100644
--- a/tests/test_sign_message.py
+++ b/tests/test_sign_message.py
@@ -19,6 +19,16 @@ def test_sign_message(navigator: Navigator, firmware: Firmware, client: RaggerCl
assert result == "IOR4YRVlmJGMx+H7PgQvHzWAF0HAgrUggQeRdnoWKpypfaAberpvF+XbOCM5Cd/ljogNyU3w2OIL8eYCyZ6Ru2k="
+def test_sign_message_eol(navigator: Navigator, firmware: Firmware, client: RaggerClient, test_name: str):
+ msg = "\nThe Times 03/Jan/2009 Chancellor\non brink of second bailout for banks."
+ path = "m/44'/1'/0'/0/0"
+ result = client.sign_message(msg, path, navigator,
+ instructions=message_instruction_approve(firmware),
+ testname=test_name)
+
+ assert result == "ILMgIpFxqZwrB5bgR/seis2N48jS7pmHViKcRYisIPBdDjhAzGDGP3HiLPcrYMlEOXJvdJ9/Mud/+fslM2KtKaM="
+
+
def test_sign_message_64bytes(navigator: Navigator, firmware: Firmware, client: RaggerClient, test_name: str):
# Version 2.2.2 introduced a bug where signing a 64 bytes message would fail; this test is to avoid regressions
msg = "a" * 64
@@ -71,7 +81,7 @@ def test_sign_message_reject(navigator: Navigator, firmware: Firmware, client: R
def test_sign_message_accept_non_ascii(navigator: Navigator, firmware: Firmware, client: RaggerClient, test_name: str):
# Test with a message that contains non ascii char
- message = "Hello\nworld!"
+ message = "Hello\rworld!"
res = client.sign_message(
message,
@@ -81,7 +91,7 @@ def test_sign_message_accept_non_ascii(navigator: Navigator, firmware: Firmware,
testname=test_name
)
- assert res == 'IGGk2UM12aQGtigJ7XCLJEXQl3bdKgx0G3CIt0ADSWknfAHqs+9+9OPZSjGrjyp46GjztGzUAnCa/DDMrSIAfbg='
+ assert res == 'ILXQPJapQ/OEy9f/ggRouI6HuAleQveIOBphNUCLlWNVQAml2Yx+885tsU0DKIxggsVq53o/fQRlosTPTQE/keE='
def test_sign_message_accept_too_long(navigator: Navigator, firmware: Firmware, client: RaggerClient, test_name: str):
@@ -101,7 +111,7 @@ def test_sign_message_accept_too_long(navigator: Navigator, firmware: Firmware,
def test_sign_message_hash_reject(navigator: Navigator, firmware: Firmware, client: RaggerClient, test_name: str):
with pytest.raises(ExceptionRAPDU) as e:
- client.sign_message("Hello\nworld!",
+ client.sign_message("Hello\rworld!",
"m/44'/1'/0'/0/0",
navigator,
instructions=message_instruction_reject(firmware),
Why this scored 15/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.