chore(core): cancel device menu via UI result
What changed, and why it matters
This is a small internal cleanup change in the Trezor hardware wallet firmware. It changes how the on-device menu is closed when the user cancels: instead of throwing an internal exception, the menu now returns a normal 'cancelled' result code. There is no indication this fixes a security bug or changes user-visible behavior.
No security action required. Treat as routine code-quality maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies core/src/apps/homescreen/device_menu.py. The interact() call that displays the device menu is given raise_on_cancel=None, which stops it from raising an exception when the user cancels. The code then imports CANCELLED from trezorui_api and explicitly checks if menu_result is CANCELLED: return. Previously cancellation was handled by an exception path. This is a refactor to reduce log noise and clarify control flow; it does not alter access controls, cryptographic operations, or trust boundaries.
Changed components
core/src/apps/homescreen/device_menu.pyInspect captured patch +4 / −1
diff --git a/core/src/apps/homescreen/device_menu.py b/core/src/apps/homescreen/device_menu.py
index feb161c58..c68684b2f 100644
--- a/core/src/apps/homescreen/device_menu.py
+++ b/core/src/apps/homescreen/device_menu.py
@@ -3,7 +3,7 @@ import trezorble as ble
import trezorui_api
from trezor import TR, config, log, utils
from trezor.ui.layouts import interact
-from trezorui_api import DeviceMenuResult
+from trezorui_api import CANCELLED, DeviceMenuResult
BLE_MAX_BONDS = 8
@@ -83,6 +83,7 @@ async def handle_device_menu() -> None:
],
),
"device_menu",
+ raise_on_cancel=None,
)
# Root menu
if menu_result is DeviceMenuResult.BackupFailed and failed_backup:
@@ -267,5 +268,7 @@ async def handle_device_menu() -> None:
from trezor.utils import reboot_to_bootloader
reboot_to_bootloader(BootCommand.STOP_AND_WAIT)
+ elif menu_result is CANCELLED:
+ return
else:
raise RuntimeError(f"Unknown menu {menu_result}")
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.