fix(core): correct device menu refresh mechanism
What changed, and why it matters
This commit fixes a small logic ordering bug in the Trezor hardware wallet's on-device menu. Previously, the special 'RefreshMenu' action was checked only after the code tried to find a normal handler for the action. If 'RefreshMenu' had no handler, the device could raise a runtime error instead of refreshing the menu. The fix moves the refresh check before the handler lookup, so Bluetooth Low Energy (BLE) events that trigger a menu refresh work correctly. There is no direct evidence this is a security vulnerability; it appears to be a UI/functional bug.
Treat as a routine functional/UI fix. No urgent security action is indicated. If auditing, verify that no other sentinel actions are mishandled in the same loop and that BLE events cannot inject unexpected menu_result values.
Security signals we found
Logic-order bug in UI event loop
Potential RuntimeError instead of intended menu refresh
BLE-related event handling mentioned in changelog
Evidence from the diff
In core/src/apps/homescreen/device_menu.py, the handle_device_menu() loop previously looked up action in _MENU_HANDLERS before checking for the DeviceMenuResult.RefreshMenu sentinel. Because RefreshMenu is not in _MENU_HANDLERS, the code could raise RuntimeError(‘Unknown menu …’) instead of continuing the loop with init_submenu_idx = arg. The patch reorders the two blocks so the RefreshMenu sentinel is handled first. The changelog notes this fixes device menu refresh on BLE-related events for the T3W1 model. No cryptographic, authentication, or memory-safety code is touched.
Changed components
core/src/apps/homescreen/device_menu.pyTrezor Safe 3 / T3W1 device menu UIInspect captured patch +5 / −4
diff --git a/core/.changelog.d/6589.fixed b/core/.changelog.d/6589.fixed
new file mode 100644
index 00000000..2266c491
--- /dev/null
+++ b/core/.changelog.d/6589.fixed
@@ -0,0 +1 @@
+[T3W1] Fix device menu refresh on BLE-related events.
diff --git a/core/src/apps/homescreen/device_menu.py b/core/src/apps/homescreen/device_menu.py
index a1ae81ca..863531e0 100644
--- a/core/src/apps/homescreen/device_menu.py
+++ b/core/src/apps/homescreen/device_menu.py
@@ -164,15 +164,15 @@ async def handle_device_menu() -> None:
raise RuntimeError(f"Unknown menu {menu_result}")
action, arg, parent_submenu_idx = menu_result
- handler = _MENU_HANDLERS.get(action)
- if not handler:
- raise RuntimeError(f"Unknown menu {menu_result}")
-
# special handling
if action == DeviceMenuResult.RefreshMenu:
init_submenu_idx = arg
continue
+ handler = _MENU_HANDLERS.get(action)
+ if not handler:
+ raise RuntimeError(f"Unknown menu {menu_result}")
+
try:
if arg is None:
await handler()
Why this scored 17/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.