fix(python): do not warn about session id when in bootloader mode
What changed, and why it matters
This is a tiny fix in the Trezor Python library that stops an incorrect error message. When a Trezor device is in bootloader mode, it legitimately does not return a session ID, but the library was wrongly logging a scary 'session management is now broken' error. The patch simply skips that warning when the device reports it is in bootloader mode. There is no sign this is a security vulnerability or that it changes any actual security behavior.
No security action required. Treat as a normal bugfix / UX improvement. If reviewing, verify that bootloader_mode is a trustworthy device-reported flag and that normal firmware mode still warns on missing session_id as before.
Security signals we found
No security-relevant behavior change: only log message suppression
Condition tied to existing device-reported state (bootloader_mode)
No input parsing, memory handling, or authentication change
Evidence from the diff
In python/src/trezorlib/protocol_v1.py, the SessionV1._get_session_id method checks whether a Features response contains a session_id. Previously it logged an error whenever session_id was None. Because bootloader mode does not use sessions, the device returns None in that mode, causing a false-positive error log. The change adds ‘and not features.bootloader_mode’ to the condition, suppressing the warning only in bootloader mode. No cryptographic, protocol, or access-control logic is altered.
Changed components
python/src/trezorlib/protocol_v1.pySessionV1._get_session_idInspect captured patch +1 / −1
diff --git a/python/src/trezorlib/protocol_v1.py b/python/src/trezorlib/protocol_v1.py
index d7ac5941..46001fb2 100644
--- a/python/src/trezorlib/protocol_v1.py
+++ b/python/src/trezorlib/protocol_v1.py
@@ -134,7 +134,7 @@ class SessionV1(client.Session["TrezorClientV1", t.Optional[bytes]]):
)
features = messages.Features.ensure_isinstance(resp)
session_id = features.session_id
- if session_id is None:
+ if session_id is None and not features.bootloader_mode:
LOG.error(
"Trezor did not return a session ID. Session management is now broken."
)
Why this scored 19/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.