test: only match Ledger "To" screen on the title row
What changed, and why it matters
This commit fixes a flaky automated test for Ledger hardware wallets. The test script was pressing an extra button because a randomly generated Bitcoin address happened to end in the letters 'To', which matched a screen-title rule. The fix narrows the rule so it only matches the word 'To' at the top of the screen, not inside wrapped address text. There is no security issue in the actual wallet software.
No security action needed. This is a test-only reliability fix. Reviewers may want to verify that other short-word rules in the automation file are similarly pinned to the title row or made multi-word to avoid future flaky failures.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is in HWI’s Speculos automation JSON used for Ledger emulator tests. A single regexp rule previously matched many screen titles including ‘To’ against any on-screen text fragment. Because base58 addresses can contain ‘T’ and ‘o’, an address ending in ‘To’ (e.g., mzmauywUy3WF1TX3YxzQMA5PR4zXqJVLTo) wrapped onto a new line triggered the rule, causing an extra right-button press and a subsequent 0x6985 ‘transaction canceled’ test failure. The patch splits the ‘To’ match into its own rule constrained to y=3 (the title row) and adds a README warning about short-word rules matching wrapped addresses.
Changed components
test/data/speculos-automation.jsontest/README.mdInspect captured patch +21 / −1
diff --git a/test/README.md b/test/README.md
index 1e1264e..099f9d0 100644
--- a/test/README.md
+++ b/test/README.md
@@ -311,6 +311,18 @@ $ cmake -Bbuild -H.
$ make -C build/
```
+### Automation rules
+
+The Ledger tests drive the emulator's buttons with
+`data/speculos-automation.json`. Speculos matches each rule against every
+text fragment drawn on the screen, so beware of this pitfall when editing
+it: screens can contain randomly generated base58 addresses, wrapped over
+several lines, and a rule matching a short word can accidentally match a
+wrapped address line. The resulting extra button press derails the rest of
+the flow. This happened with a rule for the "To" screen title when an
+address ended in "To". Keep rules multi-word where possible, or pin them to
+the title row with `"y": 3` like the "To" rule.
+
## Coldcard emulator
Clone the repository:
diff --git a/test/data/speculos-automation.json b/test/data/speculos-automation.json
index f17a9c6..31f69f7 100644
--- a/test/data/speculos-automation.json
+++ b/test/data/speculos-automation.json
@@ -28,7 +28,15 @@
]
},
{
- "regexp": "^(Address|Review|Amount|Fee|Confirm|The derivation|Derivation path|Reject if|The change path|Change path|Register wallet|Policy map|Key|Path|Public key|Spend from|Wallet name|Wallet policy|Descriptor template|Verify Bitcoin|To|Output|Warning).*",
+ "regexp": "^(Address|Review|Amount|Fee|Confirm|The derivation|Derivation path|Reject if|The change path|Change path|Register wallet|Policy map|Key|Path|Public key|Spend from|Wallet name|Wallet policy|Descriptor template|Verify Bitcoin|Output|Warning).*",
+ "actions": [
+ [ "button", 2, true ],
+ [ "button", 2, false ]
+ ]
+ },
+ {
+ "regexp": "^To.*",
+ "y": 3,
"actions": [
[ "button", 2, true ],
[ "button", 2, false ]
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.