What changed, and why it matters
This commit fixes a bug in Electrum's support for Trezor hardware wallets. After a Trezor session times out or is closed, Electrum now forgets the old session ID. Previously it kept the stale session ID, so the next attempt to sign a transaction would crash with an InvalidSessionError instead of asking the user for their PIN again. It is a usability/reliability fix, not a direct theft-of-funds vulnerability, because the failure mode was a crash rather than an unauthorized transaction.
Treat as a normal reliability/usability fix. No urgent security response required, but include in release notes because it restores expected hardware-wallet authentication behavior after session timeout.
Security signals we found
Fixes a stale-session reference that caused InvalidSessionError on re-authentication
Ensures PIN re-prompt after session timeout/closure
Failure mode was denial-of-service (transaction signing crash), not unauthorized signing
No cryptographic bypass or privilege escalation present in diff
Evidence from the diff
In electrum/plugins/trezor/clientbase.py, the close() method now sets self._session = None in a finally block after locking the device and closing the session. Before, the stale session object remained referenced; subsequent trezorlib calls reused it and raised InvalidSessionError. The change ensures the next access re-initializes a session and re-prompts for PIN entry.
Changed components
electrum/plugins/trezor/clientbase.pyTrezor hardware wallet integrationSession management / PIN re-prompt flowInspect captured patch +8 / −5
diff --git a/electrum/plugins/trezor/clientbase.py b/electrum/plugins/trezor/clientbase.py
index e0f2f31..740e9c8 100644
--- a/electrum/plugins/trezor/clientbase.py
+++ b/electrum/plugins/trezor/clientbase.py
@@ -282,11 +282,14 @@ class TrezorClientBase(HardwareClientBase, Logger):
@runs_in_hwd_thread
def close(self):
'''Called when Our wallet was closed or the device removed.'''
- self.logger.info("locking: %s", self.client)
- self.client.lock()
- self.logger.info("closing: %s", self._session)
- if self._session is not None:
- self._session.close()
+ try:
+ self.logger.info("locking: %s", self.client)
+ self.client.lock()
+ self.logger.info("closing: %s", self._session)
+ if self._session is not None:
+ self._session.close()
+ finally:
+ self._session = None
@runs_in_hwd_thread
def is_uptodate(self):
Why this scored 25/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.