fix(core/caesar): reset button state on attach
What changed, and why it matters
This commit fixes two UI state-reset bugs in the Trezor hardware wallet's 'Caesar' layout. When a screen layout is restarted (an 'Attach' event), the code now forgets any button presses that happened while the layout was inactive and clears a stuck 'Shift' key state. Without the fix, a previously pressed button or held Shift could be incorrectly remembered when returning to a screen, potentially causing an unintended action or confusing the user interface. The commit itself does not describe this as a security fix, and no independent researcher is credited.
Treat as a low-to-moderate UI reliability fix. Review whether stale state from other input components is also reset on attach, and verify that the attach event is emitted consistently so the fix cannot be bypassed. Consider whether this could affect transaction confirmation flows and add regression tests for state reset on layout re-attachment.
Security signals we found
State not reset across component lifecycle transitions
Stale button-press state may be acted upon after layout re-attachment
Modifier/shift state persisted incorrectly across attach events
UI state inconsistency in hardware wallet firmware
Evidence from the diff
In button_controller.rs, an Event::Attach(_) handler now calls self.reset_state(ctx) so that stale button-state machine state is discarded when the component is re-attached. In page.rs, an Event::Attach(_) handler now clears shift_active and refreshes the button display. The root cause is that button events occurring while the layout was not active were retained across attach/detach cycles, and a modifier state (‘Shift’) was not reset. The patch prevents stale input state from influencing the newly attached layout.
Changed components
core/embed/rust/src/ui/layout_caesar/component/button_controller.rscore/embed/rust/src/ui/layout_caesar/component/page.rsTrezor firmware Caesar UI layoutInspect captured patch +11 / −0
### core/embed/rust/src/ui/layout_caesar/component/button_controller.rs
@@ -441,6 +441,12 @@ impl Component for ButtonController {
// We are matching event with `Event::Button` for a button action
// and `Event::Timer` for getting the expiration of HTC.
match event {
+ // The layout is (re)started, e.g. when going back to it. Button events
+ // that happened in the meantime went elsewhere, so forget the presses.
+ Event::Attach(_) => {
+ self.reset_state(ctx);
+ None
+ }
Event::Button(button_event) => {
let (new_state, event) = match self.state {
// _ _
### core/embed/rust/src/ui/layout_caesar/component/page.rs
@@ -273,6 +273,11 @@ where
fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
ctx.set_page_count(self.pager().total());
+ if matches!(event, Event::Attach(_)) && self.shift_active {
+ // The layout is (re)started - "Shift" is not held anymore.
+ self.shift_active = false;
+ self.update_buttons(ctx);
+ }
if let Some(menu_nav) = self.menu_nav {
if let Some(msg) = self.event_menu_nav(ctx, event, menu_nav) {
return Some(msg);Why this scored 49/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.