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

trezor: drop session after closing it

Public commit record

What the developer wrote

Authored by f321x

68/100 · Adequate
trezor: drop session after closing it

Set `TrezorClientBase._session = None` after closing a session
(e.g. after session timeout) so the next session access will prompt
for the pin on the device instead of throwing an `InvalidSessionError`
when trying to access the device.

E.g. when trying to sign a tx after the session timed out:
```
80.64 | I | plugins.trezor.clientbase.TrezorClientBase | timed out
80.64 | I | plugins.trezor.clientbase.TrezorClientBase | clear session: <electrum.plugins.trezor.clientbase.TrezorClientBase object at 0x7f24cd34f080>
80.64 | I | plugins.trezor.clientbase.TrezorClientBase | locking: <trezorlib.protocol_v1.TrezorClientV1 object at 0x7f24cd34e160>
80.90 | I | plugins.trezor.clientbase.TrezorClientBase | closing: SessionV1(id=d5e6015e501acf4b10b3a3e50f1f9307768e434330568e7d5e7b1babed066438)
112.83 | I | plugin.DeviceMgr | getting client for keystore
112.83 | I | plugin.DeviceMgr | end client for keystore
113.10 | I | plugin.DeviceMgr | getting client for keystore
113.10 | I | plugin.DeviceMgr | end client for keystore
113.11 | E | gui.qt.main_window.[trezor] | on_error
Traceback (most recent call last):
File "/var/home/user/code/code_vm/electrum/electrum/gui/common_qt/util.py", line 165, in run
result = task.task()
File "/var/home/user/code/code_vm/electrum/electrum/wallet.py", line 2822, in sign_transaction
k.sign_transaction(tmp_tx, password)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/var/home/user/code/code_vm/electrum/electrum/plugins/trezor/trezor.py", line 100, in sign_transaction
self.plugin.sign_transaction(self, tx, prev_tx)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/var/home/user/code/code_vm/electrum/electrum/plugin.py", line 1000, in wrapper
return run_in_hwd_thread(partial(func, *args, **kwargs))
File "/var/home/user/code/code_vm/electrum/electrum/plugin.py", line 993, in run_in_hwd_thread
return fut.result()
~~~~~~~~~~^^
File "/usr/lib64/python3.14/concurrent/futures/_base.py", line 454, in result
return self.__get_result()
~~~~~~~~~~~~~~~~~^^
File "/usr/lib64/python3.14/concurrent/futures/_base.py", line 396, in __get_result
raise self._exception
File "/usr/lib64/python3.14/concurrent/futures/thread.py", line 86, in run
result = ctx.run(self.task)
File "/usr/lib64/python3.14/concurrent/futures/thread.py", line 73, in run
return fn(*args, **kwargs)
File "/var/home/user/code/code_vm/electrum/electrum/plugins/trezor/trezor.py", line 344, in sign_transaction
signatures, _ = client.sign_tx(self.get_coin_name(),
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
inputs, outputs,
^^^^^^^^^^^^^^^^
...<3 lines>...
serialize=False,
^^^^^^^^^^^^^^^^
prev_txes=prev_tx)
^^^^^^^^^^^^^^^^^^
File "/var/home/user/code/code_vm/electrum/electrum/plugin.py", line 1000, in wrapper
return run_in_hwd_thread(partial(func, *args, **kwargs))
File "/var/home/user/code/code_vm/electrum/electrum/plugin.py", line 990, in run_in_hwd_thread
return func()
File "/var/home/user/code/code_vm/electrum/electrum/plugins/trezor/clientbase.py", line 356, in sign_tx
return trezorlib.btc.sign_tx(self.session, *args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/home/user/code/code_vm/electrum/env/lib64/python3.14/site-packages/trezorlib/tools.py", line 379, in wrapper
result = self.func(session, *args, **kwargs)
File "/var/home/user/code/code_vm/electrum/env/lib64/python3.14/site-packages/trezorlib/btc.py", line 329, in sign_tx
res = session.call(signtx, expect=messages.TxRequest)
File "/var/home/user/code/code_vm/electrum/env/lib64/python3.14/site-packages/trezorlib/client.py", line 113, in call
raise exceptions.InvalidSessionError(self.id)
trezorlib.exceptions.InvalidSessionError: b'\xd5\xe6\x01^P\x1a\xcfK\x10\xb3\xa3\xe5\x0f\x1f\x93\x07v\x8eCC0V\x8e}^{\x1b\xab\xed\x06d8'
```
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

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.

Recommended action

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

01

Fixes a stale-session reference that caused InvalidSessionError on re-authentication

02

Ensures PIN re-prompt after session timeout/closure

03

Failure mode was denial-of-service (transaction signing crash), not unauthorized signing

04

No cryptographic bypass or privilege escalation present in diff

Risk score

Why this scored 25/100

Our methodology →
Potential impact 5/30
Exploitability 2/25
Stealth signal 2/15
Affected reach 4/15
Confidence 8/10
Evidence quality 4/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.