AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 25 Bitcoin

fix(python): wait for the device to leave before reconnecting after a reboot

Public commit record

What the developer wrote

Authored by tychovrahe

85/100 · Strong
fix(python): wait for the device to leave before reconnecting after a reboot

After reboot_to_bootloader the pre-reboot device still answers for a moment,
so the reconnect loop could reach a device that is about to reboot and then
fail on the first message. Wait (bounded) for the device to leave before
waiting for it to come back.

Over USB, leaving means it stops enumerating; TrezorConnection.is_present
checks that without opening, since opening would claim the interface and
toggle screen recording.

Over BLE the link can outlive the reboot, and while the main MCU is not
accepting messages the nRF answers everything with Failure(Busy) on its own.
Reusing the link right away therefore got that Busy instead of the bootloader's
Features. There, the device is probed with a v1 Cancel on the same link: no
reply or Busy means it has left, a real reply means it is back.

[no changelog]

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a reliability bug in the Trezor Python library that manages firmware updates. After telling a Trezor device to reboot into bootloader mode, the old code immediately tried to reconnect. Because the pre-reboot device can still respond briefly, or because a Bluetooth link can stay alive while the main processor reboots, the reconnection could grab the wrong device state and fail. The fix waits for the device to truly leave and then come back before continuing. It also adds a timeout to Bluetooth writes so a stuck packet does not hang forever. There is no direct evidence this is a security vulnerability, but a failed or confused update flow could in theory be abused or cause user confusion.

Recommended action

Treat as a reliability/stability fix rather than an urgent security patch. Review whether the broad exception handling in the reconnect loop could mask errors that have security relevance, and verify that the new is_present() check cannot select a different unintended Trezor device on multi-device systems.

Security signals we found

01

Race condition between reboot command and reconnect loop

02

Stale BLE link can outlive MCU reboot and return Failure(Busy) instead of bootloader Features

03

Pre-reboot device briefly still answers, risking connection to wrong device state

04

Broad exception swallowing in reconnect loop (unchanged behavior, now wrapped in new wait logic)

05

BLE write now has a bounded timeout, preventing indefinite stalls

Risk score

Why this scored 25/100

Our methodology →
Potential impact 4/30
Exploitability 3/25
Stealth signal 3/15
Affected reach 5/15
Confidence 7/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.